
اندماج ميتا's موديلات Llama 4 مع Microsoft's يفتح إطار عمل AutoGen إمكانيات جديدة لإنشاء أنظمة ذكية وفعالة AI الوكلاء. عند دمج هذه التقنيات، تُمكّن المطورين من بناء تطبيقات قادرة على معالجة اللغة الطبيعية، وفهم الصور، والتفكير في المشكلات المعقدة، والتعاون مع وكلاء آخرين لإنجاز المهام.
اللاما 4 يوفر إمكانيات متعددة الوسائط رائعة ونوافذ سياقية واسعة النطاق، بينما إنشاء تلقائي يوفر إطارًا منظمًا لتنظيم وكلاء متعددين في سير عمل تعاوني. معًا، يشكلون مجموعة أدوات قوية للجيل القادم AI التطبيقات.
يشرح هذا الدليل عملية بناء AI الوكلاء الذين يستخدمون هذه الأدوات، مع أمثلة عملية للكود واستراتيجيات التنفيذ للمطورين من جميع مستويات المهارة.
ماذا يجعل اللاما 4 و إنشاء تلقائي التطابق المثالي؟
مييتااا's تبرز عائلة Llama 4 في AI العالم مع قدرات متعددة الوسائط الأصلية ونهج الاندماج المبكر. عند دمجه مع AutoGen—Microsoft's إطار عمل لبناء أنظمة محادثة متعددة الوكلاء—يمكن للمطورين إنشاء AI الوكلاء الذين يفكرون ويتعاونون ويتكيفون بكفاءة.
تقدم موديلات Llama 4، بما في ذلك طرازات Scout وMaverick، معالجة متعددة الوسائط بالاندماج المبكر الذي يُعامل النصوص والصور وإطارات الفيديو كتسلسل واحد من الرموز منذ البداية. هذه الإمكانية، مقترنة بـ AutoGen's هندسة وكيل مرنة، تمكن من إنشاء AI نظم والتي يمكنها:
اسمحوا's إنشاء نظام عملي متعدد الوكلاء يوضح هذه القدرات من خلال إنشاء مولد مقترحات المشروع الذي يحلل متطلبات العميل ويولد مقترحات وظائف مخصصة.
بناء عملي AI نظام الوكيل
اسمحوا's إنشاء نظام متعدد الوكلاء يساعد المستقلين على إعداد مقترحات عمل مُخصصة. سيعمل نظامنا على:
- جمع متطلبات العميل
- جمع مؤهلات المستقلين
- إنشاء مقترحات احترافية بأسعار مناسبة.
الخطوة 0: إعداد بيئتك
أولاً، قم بتثبيت الحزم اللازمة:
الثعبان
pip install autogen-agentchat~=0.2
pip تثبيت ipython

الخطوة 1: تكوين الوصول إلى واجهة برمجة التطبيقات
سنستخدم واجهة برمجة التطبيقات Together للوصول إلى Llama 4:
python
import os
import autogen
from IPython.display import display, Markdown
# Load API key from file
with open("together_ai_api.txt") as file:
LLAMA_API_KEY = file.read().strip()
os.environ["LLAMA_API_KEY"] = LLAMA_API_KEY
# Configure LLM settings
llm_config = {
"config_list": [
{
"model": "meta-llama/Llama-4-Scout", # Use Scout for efficiency
"api_key": os.environ.get("LLAMA_API_KEY"),
"base_url": "https://api.together.xyz/v1",
}
],
"temperature": 0.2, # Lower for more consistent outputs
"timeout": 180
}
الخطوة 2: إنشاء وكلاء متخصصين
يتطلب نظامنا ثلاثة وكلاء متميزين بأدوار محددة:
وكيل إدخال العميل
python
# Agent 1: Interfaces with the human user
client_agent = autogen.UserProxyAgent(
name="Client_Input_Agent",
human_input_mode="ALWAYS", # Always gets input from human
max_consecutive_auto_reply=1,
is_termination_msg=lambda x: x.get("content", "").rstrip().endswith("TERMINATE"),
system_message="""Act as the primary contact between the human user and other agents.
First, collect initial project details (requirements, timeline, budget).
When asked questions by the Scope Architect, relay user's answers about skills and experience.
Type TERMINATE when the proposal is satisfactory or the user wants to stop."""
)
يعمل هذا الوكيل كجسر بين المستخدم البشري و AI النظام، جمع المعلومات وتقديم الناتج النهائي.
وكيل مهندس النطاق
python
# Agent 2: Analyzes requirements and asks qualifying questions
scope_architect_agent = autogen.AssistantAgent(
name="Scope_Architect",
llm_config=llm_config,
max_consecutive_auto_reply=1,
system_message="""You are a Scope Architect who analyzes project requirements.
After receiving initial details from Client_Input_Agent, ask targeted questions about:
- The freelancer's relevant past projects and experience
- Their key skills and tools for this specific project
- Estimated completion time for the described work
Once you have sufficient information, create a concise summary of BOTH
the project requirements AND freelancer qualifications for the Rate Recommender."""
)
يعمل مهندس النطاق كمحلل للمتطلبات، حيث يقوم بجمع المعلومات المهمة اللازمة للحصول على اقتراح دقيق.
وكيل التوصية بالسعر
python
# Agent 3: Creates structured proposal with pricing
rate_recommender_agent = autogen.AssistantAgent(
name="Rate_Recommender",
llm_config=llm_config,
max_consecutive_auto_reply=1,
system_message="""Generate professional project proposals based on gathered information.
Wait for the Scope Architect's complete summary before proceeding.
Include these sections in your proposal:
1. Custom Introduction: Personalized greeting referencing client and project
2. Project Scope & Timeline: Clear deliverables with timeline estimates
3. Pricing Options: 2-3 tiers (hourly/fixed/retainer) with justification
4. Next Steps: Brief suggestion for kickoff discussion
Format using proper markdown. Avoid commentary - deliver only the final proposal."""
)
يقوم هذا الوكيل بإنتاج المنتج النهائي، وتحويل المعلومات المجمعة إلى اقتراح منظم.
الخطوة 3: إنشاء وكيل مساعد (اختياري)
python
# Optional helper to initiate the conversation
user_proxy = autogen.UserProxyAgent(
name="user_proxy",
max_consecutive_auto_reply=1,
llm_config=llm_config,
system_message="Initiate the conversation between agents."
)
الخطوة 4: إعداد الدردشة الجماعية
الآن سنقوم بإنشاء بيئة المحادثة حيث يمكن للوكلاء التعاون:
python
# Group Chat Configuration
groupchat = autogen.GroupChat(
agents=[client_agent, scope_architect_agent, rate_recommender_agent],
messages=[],
max_round=4, # Prevent infinite loops
speaker_selection_method="round_robin", # Orderly participation
)
# Conversation Manager
manager = autogen.GroupChatManager(
groupchat=groupchat,
llm_config=llm_config,
system_message="""Direct the conversation flow through these steps:
1. Client_Input_Agent shares project details
2. Scope_Architect asks qualifying questions
3. Client_Input_Agent provides freelancer information
4. Scope_Architect summarizes all information
5. Rate_Recommender creates the final proposal
End when the proposal is complete or Client_Input_Agent says TERMINATE."""
)
يضمن هذا الإعداد تدفقًا منظمًا للمحادثة مع أدوار ومسؤوليات واضحة.
الخطوة 5: بدء المحادثة
اسمحوا's ابدأ سير عمل الوكيل الخاص بنا:
python
# Begin the proposal generation process
print("Starting the proposal generation process...")
print("Please provide project details when prompted.")
initial_message = """
Begin the proposal creation process:
1. First collect project details from the user
2. Then gather freelancer qualifications
3. Finally generate a professional proposal
"""
user_proxy.initiate_chat(
manager,
message=initial_message
)
الخطوة 6: استخراج الاقتراح النهائي
بمجرد انتهاء المحادثة، سنقوم باستخراج الاقتراح النهائي وعرضه:
python
# Find and display the proposal
chat_history = manager.chat_messages[client_agent]
final_proposal = None
for msg in reversed(chat_history):
if msg.get("role") == "assistant" and msg.get("name") == rate_recommender_agent.name:
if "Introduction" in msg.get("content", ""):
final_proposal = msg
break
if final_proposal:
proposal_text = final_proposal.get("content", "Proposal not found.")
try:
display(Markdown(proposal_text))
except NameError:
print("\n--- FINAL PROPOSAL ---\n")
print(proposal_text)
else:
print("Could not find the final proposal in the conversation.")
تقنيات مُحسّنة لبناء أفضل AI وسيط عقاري

في حين أن تنفيذنا الأساسي يعمل بشكل جيد، فإليك بعض الأساليب المتقدمة لجعل تنفيذك AI عملاء أكثر قوة:
A.تكامل الأدوات الخارجية
تتمثل إحدى نقاط قوة AutoGen في قدرتها على تزويد الوكلاء بأدوات خارجية. إليك كيفية منح نظام التوصية بالسعر إمكانيات أبحاث السوق :
python
# Define function for market research
def research_market_rates(job_type, experience_level):
"""Access external data for pricing information"""
# This would typically connect to an API or database
# Using simple dictionary for demonstration
rate_data = {
"web_development": {
"beginner": "$30-50/hr",
"intermediate": "$50-90/hr",
"expert": "$90-200/hr"
},
"data_analysis": {
"beginner": "$25-45/hr",
"intermediate": "$45-85/hr",
"expert": "$85-180/hr"
}
}
# Retrieve appropriate rate range
try:
return rate_data[job_type][experience_level]
except KeyError:
return "Rate information not available for this combination"
# Configure LLM with function
rate_recommender_config = {
**llm_config,
"functions": [
{
"name": "research_market_rates",
"description": "Find current market rates for specific job types and experience levels",
"parameters": {
"type": "object",
"properties": {
"job_type": {
"type": "string",
"enum": ["web_development", "data_analysis", "content_writing", "graphic_design"]
},
"experience_level": {
"type": "string",
"enum": ["beginner", "intermediate", "expert"]
}
},
"required": ["job_type", "experience_level"]
}
}
]
}
# Update the Rate Recommender with function capabilities
rate_recommender_agent = autogen.AssistantAgent(
name="Rate_Recommender",
llm_config=rate_recommender_config,
system_message="""Generate proposals with accurate market-based pricing.
Use the research_market_rates function to get current pricing information."""
)
# Register the function with the agent
rate_recommender_agent.register_function(
function_map={"research_market_rates": research_market_rates}
)
يتيح هذا التحسين لموصي الأسعار الوصول إلى بيانات التسعير الخارجية، مما يجعل المقترحات أكثر دقة وتنافسية.
B. تنفيذ الذاكرة الدائمة
تساعد إضافة إمكانيات الذاكرة الوكلاء على الحفاظ على السياق عبر التفاعلات المتعددة:
python
# Create a simple memory system for agents
class AgentMemory:
def __init__(self):
self.memories = {}
def store(self, agent_name, key, value):
"""Save information to agent memory"""
if agent_name not in self.memories:
self.memories[agent_name] = {}
self.memories[agent_name][key] = value
def retrieve(self, agent_name, key=None):
"""Get information from agent memory"""
if agent_name not in self.memories:
return None
if key:
return self.memories[agent_name].get(key)
else:
return self.memories[agent_name]
# Initialize memory
memory = AgentMemory()
# Example of storing client information
def process_client_input(message):
"""Extract and store client information"""
# This would typically use more sophisticated parsing
if "budget:" in message.lower():
budget = message.split("budget:")[1].strip().split("\n")[0]
memory.store("client", "budget", budget)
if "timeline:" in message.lower():
timeline = message.split("timeline:")[1].strip().split("\n")[0]
memory.store("client", "timeline", timeline)
return message
# Add memory hook to client agent
def memory_hook(recipient, messages, sender, config):
"""Process and store incoming messages"""
if sender.name == "Client_Input_Agent" and messages:
process_client_input(messages[0].get("content", ""))
return False, None # Continue normal processing
# Register the hook
client_agent.register_hook("memory_hook", memory_hook)
يساعد نظام الذاكرة هذا العملاء على تذكر المعلومات المهمة طوال المحادثة، حتى عندما لا يتم ذكرها صراحةً في الرسائل الأخيرة.
تطبيقات عملية تتجاوز توليد المقترحات
يمكن تكييف الهندسة المعمارية التي بنيناها مع العديد من سيناريوهات الأعمال الأخرى:
أ. خط إنتاج المحتوى
تعديل وكلاءنا للتعامل مع سير عمل إنتاج المحتوى:
ب. نظام تحليل محركات البحث
إنشاء أداة تحسين محركات البحث المتخصصة مع هؤلاء الوكلاء:
ج. أتمتة دعم العملاء
تحويل الهندسة المعمارية إلى نظام دعم:
نصائح لتحسين الأداء
جاهز للإنتاج AI أنظمة الوكلاء:
- اختيار النموذج الذكي: استخدم نماذج خفيفة الوزن للمهام البسيطة (الاستقبال والتوجيه) واحتفظ بالنماذج الأكبر للمهام المعقدة (إنشاء الاقتراح والتسعير).
- تنفيذ التخزين المؤقت: قم بتخزين الاستجابات المتكررة لتقليل مكالمات واجهة برمجة التطبيقات وتحسين وقت الاستجابة:
python
# Simple cache implementation
response_cache = {}
def get_cached_response(query_key, generator_function, ttl=3600):
"""Get cached response or generate new one"""
if query_key in response_cache:
timestamp, response = response_cache[query_key]
if time.time() - timestamp < ttl:
return response
# Generate fresh response
new_response = generator_function()
response_cache[query_key] = (time.time(), new_response)
return new_response
المعالجة الدفعية: بالنسبة للمهام المستقلة، قم بمعالجتها بالتوازي بدلاً من التسلسل:
python
import asyncio
async def run_parallel_research():
task1 = asyncio.create_task(research_agent.async_run("Research topic A"))
task2 = asyncio.create_task(research_agent.async_run("Research topic B"))
task3 = asyncio.create_task(research_agent.async_run("Research topic C"))
results = await asyncio.gather(task1, task2, task3)
return results
الميزة التقنية لـ Llama 4 لـ AI وسيط عقاري
اللاما 4's الميزات المحددة تجعلها مناسبة بشكل خاص لتطبيقات الوكيل:
- هندسة الاندماج المبكر متعددة الوسائط يتيح للوكلاء معالجة النصوص والصور معًا بشكل طبيعي، على عكس الأساليب السابقة التي أبقت الوسائط منفصلة.
- تصميم مزيج من الخبراء يتيح للنموذج تنشيط المعلمات ذات الصلة فقط لكل مهمة، مما يجعل الاستجابات أسرع وأكثر دقة.
- معالجة استثنائية للسياق الطويل (ما يصل إلى 10 ملايين رمز في Scout) يتيح للوكلاء الحفاظ على سجل المحادثة والإشارة إلى المستندات الطويلة دون فقدان التماسك.
- قدرات متعددة اللغات عبر 12 لغة مدعومة رسميًا، تجعل الوكلاء متاحين للمستخدمين العالميين.
هسه، يمكنك إنشاء AI الوكلاء الذين لا يفهمون الطلبات ويستجيبون لها فحسب، بل يتعاونون بنشاط لحل المشكلات المعقدة - ويمثلون حقًا الجيل القادم من AI التطبيقات.
أهم الأسئلة الشائعة
ما الذي يجعل Llama 4 مختلفًا عن نماذج اللغات الأخرى؟
يستخدم لاما 4 نهج دمج مبكر للمعالجة متعددة الوسائط، وهندسة "مزيج الخبراء" المتفرقة لتحقيق الكفاءة. يتعامل مع النصوص والصور والفيديو كتسلسل رمزي واحد، ويُفعّل فقط نماذج "الخبراء" الفرعية ذات الصلة لكل مُدخل.
هل يمكن أن يعمل AutoGen مع LLMs أخرى غير Llama 4؟
نعم، AutoGen لا يعتمد على نموذج ويمكنه العمل مع العديد من برامج الماجستير في القانون بما في ذلك برامج OpenAI النماذج، والنماذج الأنثروبية، وغيرها من النماذج مفتوحة المصدر مثل ميسترال AI أو DeepSeek.
هل البناء AI هل يحتاج العملاء إلى مهارات برمجة متقدمة؟
ليس بالضرورة. بفضل معرفة أساسية بلغة بايثون وفهمك لماجستير إدارة الأعمال، يمكنك إعداد وتشغيل سير عمل الوكلاء. يُبسط AutoGen عملية إنشاء وتنسيق وكلاء متعددين.
هل يمكن لهذه AI هل يتم تشغيل الوكلاء على الأجهزة المحلية؟
نعم، يدعم AutoGen التكامل مع أجهزة LLM المحلية من خلال أدوات مثل Ollama، مما يسمح لك بتشغيل الوكلاء على الأجهزة الخاصة بك.
كيف أتعامل مع مفاتيح API بشكل آمن في الإنتاج؟
خزّن مفاتيح واجهة برمجة التطبيقات (API) في متغيرات بيئية أو مخازن آمنة بدلاً من الكود. استخدم مصادقة وتشفيرًا مناسبين لعمليات النشر في الإنتاج.
هل يمكنني توسيع نطاق الوكلاء باستخدام أدوات وواجهات برمجة تطبيقات مخصصة؟
بالتأكيد. يتيح لك AutoGen ربط الوكلاء بواجهات برمجة التطبيقات الخارجية وقواعد البيانات والأدوات المخصصة، مما يتيح لهم التفاعل مع مختلف الأنظمة والخدمات.
قراءات موصى بها:
خاتمة
ابني AI يتيح استخدام Llama 4 وAutoGen إمكانياتٍ رائعةً لإنشاء أنظمة ذكية وتعاونية قادرة على معالجة المهام المعقدة. اللاما 4's الذكاء المتعدد الوسائط والتوليد التلقائي's إطار عمل مرن للوكيل يوفر للمطورين أدوات قوية لإنشاء AI الوكلاء الذين يمكنهم التفكير والتعاون والتكيف مع السيناريوهات المختلفة.
يُظهر مشروعنا النموذجي - مُولّد اقتراحات متعدد الوكلاء - تطبيقًا عمليًا واحدًا فقط لهذه التقنيات. ويمكن تطبيق المبادئ نفسها على نساعدك في بناء AI وكلاء لإنشاء المحتوى, تحليل البيانات، خدمة العملاء، والبحث، وإدارة المشاريع، والعديد من المجالات الأخرى.
عندما تقوم ببناء منزلك الخاص AI تذكروا أيها العملاء الذين يستخدمون Llama 4 وAutoGen المبادئ الأساسية التالية:


