အကြောင်းအရာသို့ ကျော်သွားရန်
LangChain

Framework နှင့် SDK များ

LangChain ကို Shannon ဖြင့် အသုံးပြုခြင်း

Shannon ၏ base URL ဖြင့် ChatOpenAI ကို သုံးပါ။ chain၊ agent နှင့် tool binding များ မပြောင်းလဲဘဲ အလုပ်လုပ်သည်။

  • 2026 နို 7 တွင် စမ်းသပ်ထားသည်
  • OpenAI Chat Completions
  • ခန့်မှန်း 2 မိနစ်

LangChain အကြောင်း

LangChain သည် Python နှင့် JavaScript ဖြင့် language model များပေါ်တွင် application နှင့် agent များ တည်ဆောက်ရန် open-source framework ဖြစ်သည်။ langchain-openai package ၏ ChatOpenAI သည် base URL ကို လက်ခံသဖြင့် LangChain chain၊ agent နှင့် LangGraph graph များကို Shannon model များပေါ်တွင် run နိုင်သည်။

လိုအပ်သည်များ

Shannon API key တစ်ခု
Keys & usage စာမျက်နှာ
အခြေ URL
https://api.shannon-ai.com/v1 အဆုံးမှတ်: /v1/chat/completions
အောက်ပါ နမူနာအားလုံးသည် သင့်ရွေးချယ်မှုအတိုင်း ပြောင်းလဲသည်။

သတ်မှတ်ပုံ

  1. OpenAI integration ကို install လုပ်ပါ

    Shell
    pip install langchain-openai
  2. Model ကို ဖန်တီးပါ

    ChatOpenAI သည် Shannon ၏ base URL နှင့် key ကို လက်ခံသည်။ ၎င်းပေါ်တွင် တည်ဆောက်ထားသမျှ (chain၊ agent၊ LangGraph) လိုက်၍ အလုပ်လုပ်သည်။

    Python
    from langchain_openai import ChatOpenAI
    
    llm = ChatOpenAI(model="Kimi-K3-uncensored-NVFP4", base_url="https://api.shannon-ai.com/v1", api_key="YOUR_API_KEY")
    print(llm.invoke("Say hello to a dog in five words.").content)
  3. Tool များကို bind လုပ်ပါ

    Python
    def get_weather(city: str) -> str:
        """Weather for a city."""
        ...
    
    msg = llm.bind_tools([get_weather]).invoke("What is the weather in Rome?")
    print(msg.tool_calls)  # [{'name': 'get_weather', 'args': {'city': 'Rome'}, ...}]

အလုပ်လုပ်ကြောင်း စစ်ဆေးပါ

ပို့ရန်: ပထမနမူနာကို run ပါ။

မြင်ရမည့်အရာ: စကားလုံးငါးလုံးပါ နှုတ်ဆက်စကား၊ ဥပမာ “Hello, good dog, nice pup!”

LangChain နှင့် ကိုက်ညီသော model များ

အောက်ပါ id တိုင်းသည် LangChain ၏ လိုအပ်ချက်နှင့် ကိုက်ညီသည်။ ပထမ id သည် code နမူနာများတွင် default ဖြစ်သည်။

မော်ဒယ် IDContext အရွယ်အများဆုံး outputပုံ ထည့်သွင်းမှု
Kimi-K3-uncensored-NVFP4 1,022,976 262,144 ဟုတ်
Kimi-K3-uncensored-3BIT-REAP 225,280 225,280 ဟုတ်
shannon-3 196,608 65,536 ဟုတ်
shannon-coder-1 131,072 65,536 မဟုတ်

သိထားသင့်သည်များ

  • ChatOpenAI သည် reasoning_content ကို ဖယ်ထုတ်သည်။ လိုအပ်လျှင် reasoning ကို OpenAI SDK ဖြင့် တိုက်ရိုက် ဖတ်ပါ။
  • ChatAnthropic(base_url="https://api.shannon-ai.com", ...) သည် Anthropic format သို့ ရောက်သွားသည်။
  • LangChain ၏ retrieval တွင် embedding လိုအပ်ပြီး Shannon သည် ၎င်းကို မပံ့ပိုးပါ။ သီးခြား embedding model တစ်ခုနှင့် တွဲသုံးပါ။

အကြံပြုချက်များ

  1. app ထဲရှိ ChatOpenAI အားလုံး argument မလိုဘဲ Shannon ကို သုံးစေရန် environment တွင် OPENAI_BASE_URL နှင့် OPENAI_API_KEY ကို သတ်မှတ်ပါ။
  2. with_structured_output(MySchema, method="function_calling") ဖြင့် type သတ်မှတ်ထားသော ရလဒ်များ တောင်းပါ- ၎င်းသည် picker ရှိ model အားလုံး ပံ့ပိုးသော tool call များမှတစ်ဆင့် သွားသည် (LangChain ၏ ပုံသေ method မှာ json_schema ဖြစ်သည်)။
  3. ကြာရှည်လည်ပတ်သော job များအတွက် ChatOpenAI သို့ max_retries နှင့် timeout ကို ပေးပါ။
  4. အဖြေများကို ရေးသလို ပြရန် model.stream(...) သို့မဟုတ် astream(...) ကို သုံးပါ။

ပြဿနာဖြေရှင်းခြင်း

လက္ခဏာအကြောင်းရင်းဖြေရှင်းနည်း
404 Not Found base_url တွင် /v1 မပါပါ။ https://api.shannon-ai.com/v1 ကို သုံးပါ။
tool_calls သည် ဗလာဖြစ်နေသည် စာသားဖြင့် ဖြေလိုက်သော model။ picker ရှိ model တစ်ခုကို သုံးပါ၊ ၎င်းတို့အားလုံး tool များကို ခေါ်နိုင်သည်။
401 Unauthorized Key မရှိခြင်း၊ စာလုံးပေါင်းမှားခြင်း သို့မဟုတ် လဲလှယ်ပြီးသွားခြင်း ဖြစ်သည်။ Keys & usage မှ key ကို ထပ်မံကူးယူပါ။ ၎င်းသည် sk- ဖြင့် စတင်သည်။
context_length_exceeded သို့မဟုတ် "prompt is too long" စာတို စကားပြောဆိုမှုသည် model ၏ context window ထက် ပိုရှည်နေသည်။ chat အသစ် စတင်ပါ၊ tool ကို ချုံ့ခွင့်ပေးပါ သို့မဟုတ် window ပိုကြီးသော model ကို ရွေးပါ။
insufficient_quota သင့် လက်ကျန်ငွေသည် request အတွက် ပေးချေရန် မလုံလောက်ပါ။ Top up ပြုလုပ်ပါ သို့မဟုတ် plan ပြောင်းပါ။ request ကို အလိုအလျောက် ပြန်မပို့ပါ။

မေးခွန်းများ

LangChain သည် Shannon နှင့် အလုပ်လုပ်ပါသလား။

လုပ်ပါသည်၊ base_url="https://api.shannon-ai.com/v1" ပါသော ChatOpenAI မှတစ်ဆင့် ဖြစ်သည်။

LangGraph အလုပ်လုပ်ပါသလား။

လုပ်ပါသည်- LangGraph agent များသည် တူညီသော ChatOpenAI model ကို လက်ခံသည်။

သင့်ဘာသာကို ရွေးချယ်ပါ

ဘာသာအားလုံးသည် တန်းတူဖြစ်သည်။ သင်အသုံးပြုလိုသော ဘာသာကို ရွေးပါ။

ဥရောပ

အရှေ့အလယ်ပိုင်းနှင့် မြောက်အာဖရိက

တောင်အာရှ

အရှေ့တောင်အာရှ

အရှေ့အာရှ

ဗဟိုအာရှနှင့် ကော့ကေးဆပ်

အာဖရိက

သမုဒ္ဒရာဒေသ

ဖန်တီးထားသော နှင့် ဂန္ထဝင်