langchain
ما الذي تفعله
تشرح هذه المهارة LangChain، وهو إطار شائع لبناء تطبيقات فوق نماذج اللغة. وهي موجهة للمطورين الذين يبنون روبوتات محادثة أو وكلاء أو تطبيقات توليد معزز بالاسترجاع.
متى تستخدمها
- ✓عندما تريد وكيلًا يستخدم الأدوات ويفكر خطوة بخطوة.
- ✓عندما تبني خط RAG فوق مستنداتك الخاصة.
- ✓عندما تريد التبديل بين نماذج OpenAI وAnthropic وGoogle دون إعادة كتابة التطبيق.
رابط المهارة
https://github.com/Orchestra-Research/AI-Research-SKILLs/blob/main/14-agents/langchain/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“ابنِ روبوت محادثة يتذكر حديثنا ويستطيع البحث في مستنداتي عن الإجابات.”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
تنشئ كائن نموذج من حزمة مزود، ثم تجمع الأوامر والأدوات والذاكرة والمسترجعات في سلسلة أو وكيل. وتعرض المهارة النمط الأساسي لاستدعاء النموذج وإضافة الأدوات.
المحتوى التقني (ملف SKILL.md الأصلي)
النص الأصلي من المؤلف، مباشرة من GitHub.
LangChain - Build LLM Applications with Agents & RAG
The most popular framework for building LLM-powered applications.
When to use LangChain
Use LangChain when:
- Building agents with tool calling and reasoning (ReAct pattern)
- Implementing RAG (retrieval-augmented generation) pipelines
- Need to swap LLM providers easily (OpenAI, Anthropic, Google)
- Creating chatbots with conversation memory
- Rapid prototyping of LLM applications
- Production deployments with LangSmith observability
Metrics:
- 119,000+ GitHub stars
- 272,000+ repositories use LangChain
- 500+ integrations (models, vector stores, tools)
- 3,800+ contributors
Use alternatives instead:
- LlamaIndex: RAG-focused, better for document Q&A
- LangGraph: Complex stateful workflows, more control
- Haystack: Production search pipelines
- Semantic Kernel: Microsoft ecosystem
Quick start
Installation
# Core library (Python 3.10+)
pip install -U langchain
# With OpenAI
pip install langchain-openai
# With Anthropic
pip install langchain-anthropic
# Common extras
pip install langchain-community # 500+ integrations
pip install langchain-chroma # Vector store
Basic LLM usage
from langchain_anthropic import ChatAnthropic
# Initialize model
llm = ChatAnthropic(model="claude-sonnet-4-5-20250929")
# Simple completion
response = llm.invoke("Explain quantum computing in 2 sentences")
print(response.content)
Create an agent (ReAct pattern)
from langchain.agents import create_agent
from langchain_anthropic import ChatAnthropic
# Define tools
def get_weather(city: str) -> str:
"""Get current weather for a city."""
return f"It's sunny in {city}, 72°F"
def search_web(query: str) -> str:
"""Search the web for information."""
return f"Search results for: {query}"
# Create agent (<10 lines!)
agent = create_agent(
model=ChatAnthropic(model="claude-sonnet-4-5-20250929"),
tools=[get_weather, search_web],
system_prompt="You are a helpful assistant. Use tools when needed."
)
# Run agent
result = agent.invoke({"messages": [{"role": "user", "content": "What's the weather in Paris?"}]})
print(result["messages"][-1].content)
Core concepts
1. Models - LLM abstraction
from langchain_openai import ChatOpenAI
from langchain_anthropic import ChatAnthropic
from langchain_google_genai import ChatGoogleGenerativeAI
# Swap providers easily
llm = ChatOpenAI(model="gpt-4o")
llm = ChatAnthropic(model="claude-sonnet-4-5-20250929")
llm = ChatGoogleGenerativeAI(model="gemini-2.0-flash-exp")
# Streaming
for chunk in llm.stream("Write a poem"):
print(chunk.content, end="", flush=True)
2. Chains - Sequential operations
from langchain.chains import LLMChain
from langchain.prompts import PromptTemplate
# Define prompt template
prompt = PromptTemplate(
input_variables=["topic"],
template="Write a 3-sentence summary about {topic}"
)
# Create chain
chain = LLMChain(llm=llm, prompt=prompt)
# Run chain
result = chain.run(topic="machine learning")
3. Agents - Tool-using reasoning
ReAct (Reasoning + Acting) pattern:
from langchain.agents import create_tool_calling_agent, AgentExecutor
from langchain.tools import Tool
# Define custom tool
calculator = Tool(
name="Calculator",
func=lambda x: eval(x),
description="Useful for math calculations. Input: valid Python expression."
)
# Create agent with tools
agent = create_tool_calling_agent(
llm=llm,
tools=[calculator, search_web],
prompt="Answer questions using available tools"
)
# Create executor
agent_executor = AgentExecutor(agent=agent, tools=[calculator], verbose=True)
# Run with reasoning
result = agent_executor.invoke({"input": "What is 25 * 17 + 142?"})
4. Memory - Conversation history
from langchain.memory import ConversationBufferMemory
from langchain.chains import ConversationChain
# Add memory to track conversation
memory = ConversationBufferMemory()
conversation = ConversationChain(
llm=llm,
memory=memory,
verbose=True
)
# Multi-turn conversation
conversation.predict(input="Hi, I'm Alice")
conversation.predict(input="What's my name?") # Remembers "Alice"
RAG (Retrieval-Augmented Generation)
Basic RAG pipeline
from langchain_community.document_loaders import WebBaseLoader
from langchain.text_splitter import RecursiveCharacterTextSplitt
الأسئلة الشائعة
ما إصدار Python المطلوب؟
تقول المهارة Python بإصدار 3.10 أو أحدث.
أي مزودين تدعم؟
تذكر المهارة OpenAI وAnthropic وGoogle، إضافة إلى أكثر من 500 تكامل.
هل هناك تتبع للإنتاج؟
نعم. تذكر المهارة LangSmith للمراقبة في الإنتاج.
التفاصيل
الوصف الأصلي من المؤلف
Framework for building LLM-powered applications with agents, chains, and RAG. Supports multiple providers (OpenAI, Anthropic, Google), 500+ integrations, ReAct agents, tool calling, memory management, and vector store retrieval. Use for building chatbots, question-answering systems, autonomous agents, or RAG applications. Best for rapid prototyping and production deployments.
الشعبية
- نجوم GitHub
- 14k
- الترتيب
- #11222
- الترخيص
- MIT
- آخر تحديث
- 10/10/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
autoresearch
14kيرشد وكيلك خلال مشروع بحث كامل في الذكاء الاصطناعي، من مراجعة الأدبيات إلى التجارب والكتابة، بدورة متكررة من الاختبار والمراجعة.
prompt-guard
14kيتيح لوكيلك فحص النصوص بحثًا عن محاولات حقن الأوامر وكسر القيود قبل وصولها إلى تطبيق الذكاء الاصطناعي، باستخدام مصنّف Meta الصغير.
pytorch-fsdp2
14kيوضح لوكيلك كيفية إضافة تجزئة PyTorch FSDP2 إلى سكربت التدريب، حتى تُقسَّم النماذج الكبيرة على عدة وحدات معالجة رسومية وتُحفظ بشكل صحيح.
ml-training-recipes
14kيمنح وكيلك وصفات تدريب مجربة للشبكات العصبية، تشمل اختيار النموذج والمحسّنات ومعدلات التعلم ومعالجة قفزات الخسارة.
مهارات مشابهة
add-model-provider
394kتتيح لوكيلك ربط مزوّد نموذج ذكاء اصطناعي جديد بـ OpenClaw باستخدام أوامر إعداد آمنة، وإبقاء مفاتيح API خارج النص العادي، وإجراء اختبار حي.
acp-router
394kيساعد وكيلك على إرسال مهمة إلى مساعد برمجة مثل Claude Code أو Cursor عبر OpenClaw، فيعمل العمل داخل تلك الأداة.
browser-automation
394kتعلّم وكيلك التحكم في صفحات الويب خطوة بخطوة، بما في ذلك تسجيل الدخول والتبويبات والتعافي عندما تتوقف الصفحة عن الاستجابة.