Thuta Learning
ရှာဖွေရန်
IntermediateAIadvanced

Chains (LLMChain)

စိတ်လျှော့ပါ။ ဒီခန်းကို စာအုပ်လိုမဟုတ်ဘဲ စကားပြောသလိုပဲ၊ နားလည်လွယ်အောင် ရှင်းပါမယ်။

Chains များသည် LangChain ၏ core concept ဖြစ်သည်။ ၎င်းသည် components များ (e.g., prompt template, model, output parser) ကို အဆင့်ဆင့် (chain) ချိတ်ဆက်ပေးသည်။ LLMChain သည် အခြေခံအကျဆုံး chain ဖြစ်သည်။

python
from langchain_openai import ChatOpenAI
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain

llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0)
prompt = PromptTemplate.from_template(
    "What is the best name for a company that makes {product}?"
)

# Create an LLMChain
chain = LLMChain(llm=llm, prompt=prompt)

# Run the chain
response = chain.invoke({"product": "colorful socks"})
print(response)
You should see
{'product': 'colorful socks', 'text': 'SoleMates'}
Chains (LLMChain) | Thuta Learning