Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

userinputtool() Prompts Not Displaying in Gradio Interface #805

Open
lucia-ramos opened this issue Feb 26, 2025 · 2 comments
Open

userinputtool() Prompts Not Displaying in Gradio Interface #805

lucia-ramos opened this issue Feb 26, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@lucia-ramos
Copy link

Describe the bug
I have developed a solution using SmolAgents that incorporates an agent with multiple tools (Python functions). Specifically, I utilize UserInputTool() to request missing parameters when executing a function. This approach ensures that the agent doesn't fabricate or assume parameters.

However, I've encountered an issue where the prompts from UserInputTool() are displayed in the terminal instead of the Gradio interface, this is beacause this tool uses input(). As a result, users interacting with the agent through the Gradio UI cannot see or respond to these prompts, which disrupts the intended user experience.

Source code (https://github.com/huggingface/smolagents/blob/v1.9.2/src/smolagents/default_tools.py):
class UserInputTool(Tool):
name = "user_input"
description = "Asks for user's input on a specific question"
inputs = {"question": {"type": "string", "description": "The question to ask the user"}}
output_type = "string"

def forward(self, question):
    user_input = input(f"{question} => Type your answer here:")
    return user_input

Code to reproduce the error
The code simplified would be something like this:

from smolagents import tool, CodeAgent, GradioUI, UserInputTool
#tools definition
...

agent = CodeAgent(
tools=[check_status_vm, ping_vm, UserInputTool()],
model=model,
verbosity_level=2,
description="Solve IT issues with tools. If it needs a missing parameter to execute a tool, it will use UserInputTool to ask the user for it.",
max_steps=6, add_base_tools=True, planning_interval=3
)
GradioUI(agent).launch()

Expected behavior
When a function requiring additional parameters is invoked, the UserInputTool() prompts should appear within the Gradio interface.

Packages version:
smolagents==1.9.2

@lucia-ramos lucia-ramos added the bug Something isn't working label Feb 26, 2025
@albertvillanova
Copy link
Member

Thanks, @lucia-ramos.

Maybe @yvrjsharma has an opinion on whether it would be feasible to add a gradio component for the UserInputTool.

@yvrjsharma
Copy link
Member

This should ideally be possible with the chatbot style of the gradio UI. Let me try to reproduce this to understand it better. Thanks for bringing this to my attention, @albertvillanova.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants