Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f1c6fa5
Start work on run results
aymeric-roucher May 16, 2025
46eb7c8
Create Timing and Usage objects
aymeric-roucher May 16, 2025
f4c8acb
Improve usage class, add property caculations
aymeric-roucher May 19, 2025
bbf194d
Revert deletion of step callbacks after max steps error
aymeric-roucher May 19, 2025
962922f
Rename attributes to token_usage
aymeric-roucher May 19, 2025
8dd6730
Update gradio UI for token usage
aymeric-roucher May 19, 2025
b076d11
Merge branch 'main' into add-run-results
aymeric-roucher May 19, 2025
795f76e
Fix gradio chatbot as much as possible
aymeric-roucher May 19, 2025
c7be43b
Fix gradio chatbot by escaping HTML tags
aymeric-roucher May 19, 2025
3446f7e
Pass monitoring tests
aymeric-roucher May 19, 2025
816466a
Pass more tests
aymeric-roucher May 19, 2025
9343611
Revert default LLM upgrade
aymeric-roucher May 19, 2025
7a944b3
Remove sleep
aymeric-roucher May 19, 2025
4de35e9
Re-add last_input_token_count attribute for Model
aymeric-roucher May 20, 2025
d476420
Add tests
aymeric-roucher May 20, 2025
f93846c
Pass tests
aymeric-roucher May 20, 2025
eefc8a8
Pass memory test
aymeric-roucher May 20, 2025
55bd6c7
Pass agents test
aymeric-roucher May 20, 2025
3b796d9
Revert model change in GAIA
aymeric-roucher May 20, 2025
4e6b593
Update src/smolagents/models.py
aymeric-roucher May 20, 2025
4c92beb
Update src/smolagents/monitoring.py
aymeric-roucher May 20, 2025
a87ef70
Update src/smolagents/monitoring.py
aymeric-roucher May 20, 2025
18b1849
Revert suggestion to avoid None durations
aymeric-roucher May 20, 2025
582a09e
Use post-init suggestion for TokenUsage, property for Timing
aymeric-roucher May 20, 2025
e25715e
Re-add deprecated token count increment in stream methods
aymeric-roucher May 20, 2025
3a321e7
Fix dict conversion error
aymeric-roucher May 20, 2025
6dc4c6d
Test ActionStep.dict()
aymeric-roucher May 20, 2025
56117ad
Fix edge case
aymeric-roucher May 20, 2025
dbdb3fa
Fix even more tests
aymeric-roucher May 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions examples/agent_from_any_llm.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
from smolagents import InferenceClientModel, LiteLLMModel, OpenAIServerModel, TransformersModel, tool
from smolagents.agents import CodeAgent, ToolCallingAgent
from smolagents import (
CodeAgent,
InferenceClientModel,
LiteLLMModel,
OpenAIServerModel,
ToolCallingAgent,
TransformersModel,
tool,
)


# Choose which inference type to use!

available_inferences = ["hf_api", "hf_api_provider", "transformers", "ollama", "litellm", "openai"]
chosen_inference = "hf_api_provider"
available_inferences = ["inference_client", "transformers", "ollama", "litellm", "openai"]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aligns this with the new name since #1198.

chosen_inference = "inference_client"

print(f"Chose model: '{chosen_inference}'")

if chosen_inference == "hf_api":
model = InferenceClientModel(model_id="meta-llama/Llama-3.3-70B-Instruct")

elif chosen_inference == "hf_api_provider":
model = InferenceClientModel(provider="together")
if chosen_inference == "inference_client":
model = InferenceClientModel(model_id="meta-llama/Llama-3.3-70B-Instruct", provider="nebius")
Copy link
Collaborator Author

@aymeric-roucher aymeric-roucher May 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specify provider "nebius" since they don't error out when using tool_call="required"


elif chosen_inference == "transformers":
model = TransformersModel(model_id="HuggingFaceTB/SmolLM2-1.7B-Instruct", device_map="auto", max_new_tokens=1000)
Expand Down
3 changes: 2 additions & 1 deletion examples/gradio_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
name="example_agent",
description="This is an example agent.",
step_callbacks=[],
stream_outputs=False,
stream_outputs=True,
return_full_result=True,
)

GradioUI(agent, file_upload_folder="./data").launch()
10 changes: 8 additions & 2 deletions examples/inspect_multiagent_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,24 @@


# Then we run the agentic part!
model = InferenceClientModel()
model = InferenceClientModel(provider="nebius")

search_agent = ToolCallingAgent(
tools=[WebSearchTool(), VisitWebpageTool()],
model=model,
name="search_agent",
description="This is an agent that can do web search.",
return_full_result=True,
)

manager_agent = CodeAgent(
tools=[],
model=model,
managed_agents=[search_agent],
return_full_result=True,
)
manager_agent.run("If the US keeps it 2024 growth rate, how many years would it take for the GDP to double?")
run_result = manager_agent.run(
"If the US keeps it 2024 growth rate, how many years would it take for the GDP to double?"
)
print("Here is the token usage for the manager agent", run_result.token_usage)
print("Here are the timing informations for the manager agent:", run_result.timing)
6 changes: 4 additions & 2 deletions examples/multi_llm_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
model_list=llm_loadbalancer_model_list,
client_kwargs={"routing_strategy": "simple-shuffle"},
)
agent = CodeAgent(tools=[WebSearchTool()], model=model, stream_outputs=True)
agent = CodeAgent(tools=[WebSearchTool()], model=model, stream_outputs=True, return_full_results=True)

agent.run("How many seconds would it take for a leopard at full speed to run through Pont des Arts?")
full_result = agent.run("How many seconds would it take for a leopard at full speed to run through Pont des Arts?")

print(full_result)
Loading