Yönlendirme ve Koşullu Zincirler
Her isteği daha uygun alt zincire göndererek girdiye göre dinamik biçimde yol seçen zincirler oluşturun; böylece daha akıllı ve dallanan iş akışları elde edin.
Yönlendirme ve Koşullu Zincirler, CoddyKit'te ücretsiz bir AI Agents with LangChain & Autonomous Workflows dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, AI Agents with LangChain & Autonomous Workflows öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. AI Agents with LangChain & Autonomous Workflows kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
Beyond Straight-Line Chains
Sequential chains always run the same steps in order. But real workflows branch: a billing question and a coding question need different handling.
This lesson covers routing chains that choose a path based on the input.
What a Router Does
A router inspects the input, decides which destination chain best fits, and forwards the input there. It is a dispatcher in front of several specialist chains.
input -> router -> { billing_chain | code_chain | general_chain }Defining Destination Chains
Each destination is a normal chain tuned for one kind of task, with its own prompt and configuration.
billing = LLMChain(llm=llm, prompt=billing_prompt)
coding = LLMChain(llm=llm, prompt=coding_prompt)Describing Each Route
The router needs to know what each destination is for. Provide a name and a short description so it can match an input to the right one.
routes = [
{'name': 'billing', 'description': 'invoices, refunds, payments'},
{'name': 'coding', 'description': 'programming and debugging help'}
]LLM-Based Routing
One approach asks the LLM itself to classify the input and name the destination. It is flexible and handles fuzzy intent, but adds a model call and some unpredictability.
# router prompt asks model to output: {'destination': 'billing', 'input': ...}Rule-Based Routing
When intent is clear from structure, a deterministic function can route faster and cheaper than an LLM.
def route(query):
if 'refund' in query.lower():
return 'billing'
return 'general'The Default Route
Some inputs match no specialist. Always provide a default destination so the chain never fails on an unexpected request.
default_chain = LLMChain(llm=llm, prompt=general_prompt)Composing the Router Chain
LangChain's routing chain ties the router, the destination map, and the default together into a single callable that picks the path automatically.
from langchain.chains.router import MultiPromptChain
chain = MultiPromptChain(
router_chain=router,
destination_chains={'billing': billing, 'coding': coding},
default_chain=default_chain)Handling Misroutes
Routing is a prediction and can be wrong. Log the chosen destination, let a destination decline and fall back, and monitor misroute rates so you can refine descriptions over time.
LLM vs Rule-Based Tradeoffs
Choose your router by the situation:
- Rules: fast, cheap, deterministic; brittle for fuzzy intent
- LLM: flexible, handles nuance; slower, costs a call, less predictable
Hybrids use rules first and fall back to the LLM.
A Routing Workflow
Putting it together:
- Build specialist destination chains
- Describe each route clearly
- Choose rule-based, LLM-based, or hybrid routing
- Always include a default and monitor misroutes
Quick Check
Test your understanding of routing chains.
Recap
You learned to build branching, conditional chains.
- A router dispatches input to specialist destination chains
- Routing can be rule-based, LLM-based, or hybrid
- Clear route descriptions improve accuracy
- Always include a default and monitor misroutes
Sıkça Sorulan Sorular
“Yönlendirme ve Koşullu Zincirler” dersi ücretsiz mi?
Evet — “Yönlendirme ve Koşullu Zincirler” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve AI Agents with LangChain & Autonomous Workflows kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. AI Agents with LangChain & Autonomous Workflows kursu toplamda 4 dersten oluşur.
“Yönlendirme ve Koşullu Zincirler” dersinde ne öğreneceğim?
Her isteği daha uygun alt zincire göndererek girdiye göre dinamik biçimde yol seçen zincirler oluşturun; böylece daha akıllı ve dallanan iş akışları elde edin. AI Agents with LangChain & Autonomous Workflows ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
AI Agents with LangChain & Autonomous Workflows öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te AI Agents with LangChain & Autonomous Workflows, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.
“Yönlendirme ve Koşullu Zincirler” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu AI Agents with LangChain & Autonomous Workflows dersinde kod yazıp çalıştırabilir miyim?
Evet. Her AI Agents with LangChain & Autonomous Workflows dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- LangChain Zincirlerine Giriş
- Sıralı ve Basit Zincirler
- Zincir Mantığını Özelleştirme
- Yönlendirme ve Koşullu Zincirler