Peke ki ngā ihirangi
Instructor

Ngā framework me ngā SDK

Whakamahia a Instructor me Shannon

Whakapaipai i tētahi kiritaki OpenAI kua tohua ki a Shannon ki a Instructor ka whiwhi i ngā ahanoa Pydantic mai i ngā model Shannon, katoa, rere rānei.

  • I whakamātauria 7 Noe 2026
  • OpenAI Chat Completions
  • Tata ki te 1 meneti

Mō Instructor

Ka huri a Instructor i ngā whakautu model hei ahanoa Pydantic kua manatokohia: ka tukuna he response_model ka whiwhi i ngā raraunga momotuhia, me te whakamātau anō ina rahua te manatoko. Ka takai i te kiritaki OpenAI, no reira mā te tohu i taua kiritaki ki a Shannon ka whiwhi i te output whakaritea mai 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/v1 Pito mutunga: /v1/chat/completions
Ka whai ia wāhanga waehere i raro iho i tō kōwhiringa.

Whakaritea

  1. Whakaurua a Instructor

    Shell
    pip install instructor openai
  2. Whiwhia he ahanoa momotuhia

    Ka tono te Mode.TOOLS i te ahanoa mā tētahi karanga tool, e tautokona ana e ngā model Shannon.

    Python
    import instructor
    from openai import OpenAI
    from pydantic import BaseModel
    
    client = instructor.from_openai(
        OpenAI(base_url="https://api.shannon-ai.com/v1", api_key="YOUR_API_KEY"),
        mode=instructor.Mode.TOOLS,
    )
    
    class Cat(BaseModel):
        name: str
        colour: str
        age_years: int
    
    cat = client.chat.completions.create(
        model="Kimi-K3-uncensored-NVFP4",
        response_model=Cat,
        messages=[{"role": "user", "content": "Tom is a grey cat, 4 years old."}],
    )
    print(cat)  # name='Tom' colour='grey' age_years=4
  3. Rere i tētahi ahanoa wāhanga

    Python
    for partial in client.chat.completions.create_partial(
        model="Kimi-K3-uncensored-NVFP4",
        response_model=Cat,
        messages=[{"role": "user", "content": "Make up a cat: name, colour, age in years."}],
    ):
        print(partial)

Tirohia kei te mahi

Tukuna: Whakahaerehia te tauira tuatahi.

Me kite koe i: name='Tom' colour='grey' age_years=4

Ngā model e hāngai ana ki Instructor

Ka tutuki i ia id i raro iho ngā hiahia o Instructor. Ko te tuatahi te taunoa i ngā wāhanga waehere.

Id tauiraMatapihi horopakiOutput nui rawaInput 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

  • Ko te Mode.TOOLS te aratau hei whakamahi me Shannon; ka whakawhirinaki ki ngā karanga tool, ka mahia e ia model o te kaikōwhiri.
  • Takaia tō ake kiritaki ki te from_openai pēnei i te whakaaturanga, kia ko ngā mea a Shannon te base URL me te key.

Ngā tohutohu

  1. Ka pātai anō te max_retries=2 i runga i te create ki te model ina rahua te manatoko, i te utu o tētahi tono mō ia whakamātau anō.
  2. Ka whakahoki te create_iterable i tētahi rārangi ahanoa mai i tētahi whakautu kotahi, hei tauira ia ngeru i tētahi wāhanga tuhi.
  3. Ka takai hoki a Instructor i te kiritaki Anthropic (instructor.from_anthropic), ka taea te tohu ki a Shannon me te base_url="https://api.shannon-ai.com"; i whakamātauria e mātou te ara OpenAI.

Te whakatika raruraru

TohuTakeWhakatika
InstructorRetryException Kāore te whakautu i manatoko whai muri i ngā whakamātau anō. Whakaūkuia ngā momo āpure a te model, whakanuia rānei te max_retries.
404 Not Found Kāore i te whai te base_url i te /v1. Whakamahia https://api.shannon-ai.com/v1.
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 Instructor me Shannon?

Āe: takaia te OpenAI(base_url="https://api.shannon-ai.com/v1") ki te instructor.from_openai.

Ka mahi te rere?

Āe; ka whakaputa te create_partial i te ahanoa i a ia e whakatutukia ana, i whakamātauria e mātou.

Kōwhiria tō reo

He ōrite ngā reo katoa. Kōwhiria te reo e hiahia ana koe ki te whakamahi.

Ūropi

Te Rāwhiti Waenga me Āwherika ki te Raki

Āhia ki te Tonga

Āhia ki te Tonga-ma-Rāwhiti

Āhia ki te Rāwhiti

Āhia Waenga me Kōkahu

Āwherika

Te Moana-nui-a-Kiwa

Reo Hanga me te Reo Tawhito