Whakamahia a OpenAI Agents SDK me Shannon
Takaia tētahi kiritaki AsyncOpenAI kua tohua ki a Shannon ki te OpenAIChatCompletionsModel ka whakahaere i ngā kaiwhakaahei Agents SDK i runga i ngā model Shannon.
- I whakamātauria 7 Noe 2026
- OpenAI Chat Completions
- Tata ki te 2 meneti
Mō OpenAI Agents SDK
Ko te OpenAI Agents SDK he anga Python iti mō ngā kaiwhakaahei me ngā tool, ngā tuku i waenga i ngā kaiwhakaahei me ngā taiapa. Ka mahi me tētahi model i muri i te hōputu Chat Completions mā te OpenAIChatCompletionsModel, no reira ka taea e ngā kaiwhakaahei i hangaia ki a ia 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
-
Whakaurua te SDK
Shellpip install openai-agents -
Hangaia te model me tētahi kaiwhakaahei me tētahi tool
Ka aukati te
set_tracing_disabled(True)i te SDK i te tuku tohu-whai ki OpenAI, ka rahua mēnā kāore he key OpenAI.Pythonimport asyncio from openai import AsyncOpenAI from agents import Agent, OpenAIChatCompletionsModel, Runner, function_tool, set_tracing_disabled set_tracing_disabled(True) client = AsyncOpenAI(base_url="https://api.shannon-ai.com/v1", api_key="YOUR_API_KEY") model = OpenAIChatCompletionsModel(model="Kimi-K3-uncensored-NVFP4", openai_client=client) @function_tool def get_weather(city: str) -> str: """Weather for a city.""" return f"Sunny, 18 C in {city}" agent = Agent(name="Weather", instructions="Use the tool for weather.", model=model, tools=[get_weather]) async def main(): result = await Runner.run(agent, "What is the weather in Oslo?") print(result.final_output) asyncio.run(main()) -
Rere i tētahi whakahaerenga
Pythonfrom openai.types.responses import ResponseTextDeltaEvent async def stream(): result = Runner.run_streamed(agent, "Name three colours a cat can be.") async for event in result.stream_events(): if event.type == "raw_response_event" and isinstance(event.data, ResponseTextDeltaEvent): print(event.data.delta, end="", flush=True) asyncio.run(stream())
Tirohia kei te mahi
Tukuna: Whakahaerehia te tauira kaiwhakaahei.
Me kite koe i: Ka karanga te kaiwhakaahei i te get_weather ka whakautu ki te huarere i Oslo.
Ngā model e hāngai ana ki OpenAI Agents SDK
Ka tutuki i ia id i raro iho ngā hiahia o OpenAI Agents SDK. 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-uncensored-3BIT-REAP | 225,280 | 225,280 | Āe |
shannon-3 | 196,608 | 65,536 | Āe |
shannon-coder-1 | 131,072 | 65,536 | Kāo |
He pai kia mōhio
- Tukuna te model ki ia kaiwhakaahei hei
OpenAIChatCompletionsModel. Ka tuku tētahi ingoa model noa i te tono ki te Responses API a OpenAI me ō tautuhinga OpenAI. - Ki te kore te
set_tracing_disabled(True), ka whakamātau te SDK ki te tuku i ngā tohu-whai ki OpenAI ka tuhi hapa. - E rua ngā tono i tētahi karanga tool: te karanga, ka te whakautu i tuhia mai i tana hua.
Ngā tohutohu
- Ka waiho a Shannon hei taunoa mō ia kaiwhakaahei mā te
set_default_openai_client(client)me teset_default_openai_api("chat_completions"). - Ka mahi hoki te
OpenAIResponsesModel, i te mea ka whakahaere a Shannon i te/v1/responses; tukuna te kōrero katoa i ia wā, i te mea kāore e tiakina ngā whakautu. - Ka mahi pēnei ano ngā tuku i waenga i ngā kaiwhakaahei; hoatu te model Shannon ki ia kaiwhakaahei.
Te whakatika raruraru
| Tohu | Take | Whakatika |
|---|---|---|
He 401 e whakahua ana i a OpenAI | I whakamahia e tētahi kaiwhakaahei kāore he model= te kiritaki OpenAI taunoa. | Hoatu te model Shannon ki ia kaiwhakaahei, tautuhia rānei te kiritaki taunoa. |
| Ngā hapa tuku tohu-whai i te rangitaki | Kua whakahohea te tohu-whai. | Karangahia te set_tracing_disabled(True). |
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 te OpenAI Agents SDK me Shannon?
Āe, mā te OpenAIChatCompletionsModel i runga i tētahi kiritaki AsyncOpenAI me te base_url="https://api.shannon-ai.com/v1".
Ka mahi ngā tool me te rere?
Āe; i whakahaere mātou i tētahi karanga tool me tētahi whakahaerenga rere.