YUNOVA · AI Agents
Module 13: Agents in production
Deploying an AI agent as an API
Key points
- Agent को API बनाने से कोई भी app, website या service HTTP request भेजकर उसे इस्तेमाल कर सकती है।
- Python में FastAPI से endpoint बनाया जाता है, जो request लेकर agent चलाता है और जवाब JSON में लौटाता है।
- Request validation के लिए Pydantic models और लंबे जवाबों के लिए streaming इस्तेमाल हो सकती है।
- API keys environment variables में रखें और endpoint पर authentication व rate limit लगाएँ।
LLM observability with Langfuse
Key points
- Observability मतलब production में agent के हर run को देखना: prompts, जवाब, tool calls, समय, tokens और cost।
- Langfuse एक open-source LLM observability tool है, जिसे self-host भी किया जा सकता है।
- LangSmith LangChain टीम का इसी तरह का tool है; दोनों में tracing और evaluation की सुविधा है।
- Traces से धीमे steps, महँगे calls और गलत जवाबों को ढूँढकर सुधारा जाता है।
Prompt injection attacks and defence
Key points
- Hidden prompt injection में web pages, emails या documents के अंदर छिपे निर्देश agent को गलत काम करवाने की कोशिश करते हैं।
- बाहर से आए content को data मानें, निर्देश नहीं, और उसे prompt में अलग से चिह्नित करें।
- Agent को कम से कम permissions दें और जोखिम वाले actions से पहले human approval रखें।
- कोई एक उपाय पूरी सुरक्षा नहीं देता; कई परतों वाली सुरक्षा (defence in depth) अपनाएँ।