Ngā kaiwhakahaere whaiaro, motuhake hoki
Whakamahia a smolagents me Shannon
Tohua te OpenAIServerModel a smolagents ki a Shannon, ā, whakahaerehia a ToolCallingAgent, CodeAgent rānei i runga i ngā model Shannon.
- I whakamātauria 7 Noe 2026
- OpenAI Chat Completions
- Tata ki te 2 meneti
Mō smolagents
He whare pukapuka kaitono iti a smolagents nā Hugging Face. Ka tuhi tētahi CodeAgent i te Python hei mahi, ā, ka whakamahi tētahi ToolCallingAgent i ngā karanga taputapu taketake. Ka uru mai ngā model mā ngā takai iti, ā, ka tango te mea hototahi-OpenAI i tētahi base URL, nō reira ka taea e ngā momo kaitono e rua te rere i runga i ngā model Shannon.
Ngā mea e hiahiatia ana
- He API key Shannon
- Ngā kī me te whakamahinga
- URL pūtake
-
https://api.shannon-ai.com/v1Pito mutunga:/v1/chat/completions - Ka whai ia wāhanga waehere i raro iho i tō kōwhiringa.
Whakaritea
-
Whakauruhia a smolagents me te OpenAI extra
Shellpip install 'smolagents[openai]' -
Hangaia te model me tētahi kaitono
Pythonfrom smolagents import OpenAIServerModel, ToolCallingAgent, tool model = OpenAIServerModel( model_id="Kimi-K3-uncensored-NVFP4", api_base="https://api.shannon-ai.com/v1", api_key="YOUR_API_KEY", ) @tool def get_weather(city: str) -> str: """Weather for a city. Args: city: The city name. """ return f"Sunny, 18 C in {city}" agent = ToolCallingAgent(tools=[get_weather], model=model, max_steps=4) print(agent.run("What is the weather in Oslo?"))
Tirohia kei te mahi
Tukuna: Run the sample.
Me kite koe i: Ka karanga te kaitono i te get_weather, ā, ka karanga i te final_answer, ka tā i te huarere i Oslo.
Ngā model e hāngai ana ki smolagents
Ka tutuki i ia id i raro iho ngā hiahia o smolagents. Ko te tuatahi te taunoa i ngā wāhanga waehere.
| Id tauira | Matapihi horopaki | Output nui rawa | Input whakaahua |
|---|---|---|---|
Kimi-K3-uncensored-NVFP4 | 1,022,976 | 262,144 | Āe |
Kimi-K3.1-Pro-uncensored-NVFP4 | 1,022,976 | 262,144 | Āe |
MiMo-V2.6-Pro-uncensored-NVFP4 | 1,022,976 | 131,072 | Āe |
Kimi-K3-uncensored-3BIT-REAP | 225,280 | 225,280 | Āe |
shannon-3 | 196,608 | 65,536 | Āe |
He pai kia mōhio
- Ka pānui a smolagents i te docstring o ia taputapu: e hiahiatia ana te wāhanga
Args:me tētahi rārangi mō ia tohutuhi, ki te kore ka puta he hapa i te@tool. - He tono kotahi ia hikoinga. Ka whakatepe te
max_stepsi te maha ka taea e tētahi kaitono. - Ka whakahaere te
CodeAgenti te Python i tuhia e te model i runga i tō mīhini; whakamahia ōna kōwhiringa pouaka onepū mō ngā mahi kāore e whakawhirinaki. - Ko
OpenAIModelte ingoa o te akomanga i ngā putanga hou; ka mahi tonu teOpenAIServerModelā, koia tā mātou i whakamahi ai.
Ngā tohutohu
- Ka whakamahi te
ToolCallingAgenti ngā karanga taputapu taketake; ka whakamahi teCodeAgenti te kuputuhi pāpaku, ā, ka mahi me tētahi model e ahatia. - Ka tuku te
agent.run(..., stream=True)i ia hikoinga i a ia e puta ana. - Ko te karanga tōtika i te model mā te
model.generate([...])he whakamātau hononga tere. - Ka tā ia hikoinga i ōna token input me output; i tā mātou mahi huarere e rua hikoinga, tata ki te 20,000 token input i runga i a
shannon-coder-1.
Te whakatika raruraru
| Tohu | Take | Whakatika |
|---|---|---|
404 Not Found | Kāore te api_base e whai /v1. | Whakamahia https://api.shannon-ai.com/v1. |
| "Reached max steps" | Me nui ake ngā hikoinga i te max_steps mō te mahi. | Whakanuia te max_steps, whakamāmātia rānei te mahi. |
401 Unauthorized | Kei te ngaro te key, kua hē te pato, kua hurihia rānei. | Tāruatia anō te key mai i Keys & usage; ka tīmata ki te sk-. |
context_length_exceeded, te karere "prompt is too long" rānei | He roa ake te kōrero i te matapihi horopaki o te model. | Tīmatahia he kōrerorero hou, tukuna te taputapu kia whakamāmā, kōwhiria rānei he model he nui ake te matapihi. |
insufficient_quota | Kāore e rawaka tō toenga hei utu i te tono. | Tāpiri nama, huri mahere rānei; kāore te tono e ngana anō ko ia anake. |
Ngā pātai
Ka mahi a smolagents me Shannon?
Āe, mā te OpenAIServerModel(api_base="https://api.shannon-ai.com/v1").
Ko tēhea momo kaitono hei whakamahi māku?
Te ToolCallingAgent me tētahi model mai i te kaitīpako, i te mea ka karanga taputapu taketake katoa; i whakamātauria e mātou.