Skip to content

Commit 60f23ac

Browse files
authored
🌐 Update translations via Co-op Translator
1 parent 8b4ed65 commit 60f23ac

File tree

153 files changed

+14996
-7578
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+14996
-7578
lines changed

translations/ar/04-tool-use/README.md

Lines changed: 60 additions & 53 deletions
Large diffs are not rendered by default.
Lines changed: 188 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<!--
22
CO_OP_TRANSLATOR_METADATA:
33
{
4-
"original_hash": "f82a3992438bcc028a2569c5fed828a9",
5-
"translation_date": "2025-11-07T09:21:09+00:00",
4+
"original_hash": "91d6061e402489603f2ec8b528cae59b",
5+
"translation_date": "2025-11-18T16:38:36+00:00",
66
"source_file": "04-tool-use/code_samples/04-dotnet-agent-framework.md",
77
"language_code": "ar"
88
}
@@ -13,107 +13,250 @@ CO_OP_TRANSLATOR_METADATA:
1313

1414
يستعرض هذا الدفتر أنماط دمج الأدوات على مستوى المؤسسات باستخدام إطار عمل Microsoft Agent في .NET مع نماذج GitHub. ستتعلم كيفية بناء وكلاء متقدمين باستخدام أدوات متعددة ومتخصصة، مستفيدًا من قوة الكتابة القوية في C# وميزات .NET على مستوى المؤسسات.
1515

16-
**قدرات الأدوات المتقدمة التي ستتقنها:**
16+
### القدرات المتقدمة للأدوات التي ستتقنها
17+
1718
- 🔧 **هيكلية متعددة الأدوات**: بناء وكلاء بقدرات متعددة ومتخصصة
18-
- 🎯 **تنفيذ آمن للأدوات**: الاستفادة من التحقق أثناء وقت الترجمة في C#
19+
- 🎯 **تنفيذ آمن للأنواع**: الاستفادة من التحقق أثناء وقت الترجمة في C#
1920
- 📊 **أنماط أدوات المؤسسات**: تصميم أدوات جاهزة للإنتاج ومعالجة الأخطاء
20-
- 🔗 **تركيب الأدوات**: دمج الأدوات لإنشاء تدفقات عمل معقدة للأعمال
21+
- 🔗 **تركيب الأدوات**: دمج الأدوات لإنشاء تدفقات عمل تجارية معقدة
2122

2223
## 🎯 فوائد هيكلية الأدوات في .NET
2324

2425
### ميزات أدوات المؤسسات
26+
2527
- **التحقق أثناء وقت الترجمة**: الكتابة القوية تضمن صحة معلمات الأدوات
2628
- **حقن التبعيات**: تكامل حاوية IoC لإدارة الأدوات
27-
- **أنماط Async/Await**: تنفيذ غير محظور للأدوات مع إدارة الموارد بشكل صحيح
28-
- **تسجيل منظم**: تكامل تسجيل مدمج لمراقبة تنفيذ الأدوات
29+
- **أنماط Async/Await**: تنفيذ الأدوات بدون حظر مع إدارة الموارد بشكل صحيح
30+
- **التسجيل المنظم**: تكامل التسجيل المدمج لمراقبة تنفيذ الأدوات
2931

3032
### أنماط جاهزة للإنتاج
33+
3134
- **معالجة الاستثناءات**: إدارة شاملة للأخطاء باستخدام استثناءات محددة
3235
- **إدارة الموارد**: أنماط التخلص المناسبة وإدارة الذاكرة
33-
- **مراقبة الأداء**: مقاييس مدمجة ومؤشرات الأداء
34-
- **إدارة التكوين**: تكوين آمن مع التحقق
36+
- **مراقبة الأداء**: مقاييس مدمجة وعدادات الأداء
37+
- **إدارة التكوين**: تكوين آمن للأنواع مع التحقق
3538

3639
## 🔧 الهيكلية التقنية
3740

3841
### مكونات الأدوات الأساسية في .NET
42+
3943
- **Microsoft.Extensions.AI**: طبقة تجريد موحدة للأدوات
4044
- **Microsoft.Agents.AI**: تنسيق أدوات على مستوى المؤسسات
4145
- **تكامل نماذج GitHub**: عميل API عالي الأداء مع تجميع الاتصالات
4246

43-
### خط تنفيذ الأدوات
44-
```
45-
User Request → Agent Analysis → Tool Selection → Type Validation
46-
↓ ↓ ↓
47-
Parameter Binding → Tool Execution → Result Processing → Response
47+
### خط أنابيب تنفيذ الأدوات
48+
49+
```mermaid
50+
graph LR
51+
A[User Request] --> B[Agent Analysis]
52+
B --> C[Tool Selection]
53+
C --> D[Type Validation]
54+
B --> E[Parameter Binding]
55+
E --> F[Tool Execution]
56+
C --> F
57+
F --> G[Result Processing]
58+
D --> G
59+
G --> H[Response]
4860
```
4961

5062
## 🛠️ فئات الأدوات والأنماط
5163

5264
### 1. **أدوات معالجة البيانات**
65+
5366
- **التحقق من المدخلات**: الكتابة القوية مع تعليقات البيانات
54-
- **عمليات التحويل**: تحويل البيانات وتنسيقها بشكل آمن
67+
- **عمليات التحويل**: تحويل البيانات وتنسيقها بشكل آمن للأنواع
5568
- **منطق الأعمال**: أدوات الحساب والتحليل الخاصة بالمجال
5669
- **تنسيق المخرجات**: إنشاء استجابات منظمة
5770

5871
### 2. **أدوات التكامل**
72+
5973
- **موصلات API**: تكامل خدمات RESTful باستخدام HttpClient
6074
- **أدوات قواعد البيانات**: تكامل Entity Framework للوصول إلى البيانات
6175
- **عمليات الملفات**: عمليات نظام الملفات الآمنة مع التحقق
6276
- **الخدمات الخارجية**: أنماط تكامل الخدمات الخارجية
6377

6478
### 3. **أدوات المساعدة**
79+
6580
- **معالجة النصوص**: أدوات التلاعب بالنصوص وتنسيقها
6681
- **عمليات التاريخ/الوقت**: حسابات التاريخ/الوقت مع مراعاة الثقافة
6782
- **أدوات رياضية**: حسابات دقيقة وعمليات إحصائية
6883
- **أدوات التحقق**: التحقق من قواعد الأعمال والتحقق من البيانات
6984

70-
## ⚙️ المتطلبات والإعداد
85+
هل أنت مستعد لبناء وكلاء على مستوى المؤسسات بقدرات أدوات قوية وآمنة للأنواع في .NET؟ لنبدأ في تصميم حلول احترافية! 🏢⚡
7186

72-
**بيئة التطوير:**
73-
- .NET 9.0 SDK أو أعلى
74-
- Visual Studio 2022 أو VS Code مع امتداد C#
75-
- الوصول إلى API نماذج GitHub
87+
## 🚀 البدء
7688

77-
**حزم NuGet المطلوبة:**
78-
```xml
79-
<PackageReference Include="Microsoft.Extensions.AI" Version="9.9.0" />
80-
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="9.9.0-preview.1.25458.4" />
81-
<PackageReference Include="DotNetEnv" Version="3.1.1" />
82-
```
89+
### المتطلبات الأساسية
8390

84-
**تكوين البيئة (ملف .env):**
85-
```env
86-
GITHUB_TOKEN=your_github_personal_access_token
87-
GITHUB_ENDPOINT=https://models.inference.ai.azure.com
88-
GITHUB_MODEL_ID=gpt-4o-mini
89-
```
91+
- [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) أو أعلى
92+
- [رمز الوصول إلى API لنماذج GitHub](https://docs.github.com/github-models/github-models-at-scale/using-your-own-api-keys-in-github-models)
9093

91-
جاهز لبناء وكلاء على مستوى المؤسسات بقدرات أدوات قوية وآمنة في .NET؟ لنبدأ في تصميم حلول احترافية! 🏢⚡
94+
### متغيرات البيئة المطلوبة
9295

93-
## 💻 تنفيذ الكود
96+
```bash
97+
# zsh/bash
98+
export GH_TOKEN=<your_github_token>
99+
export GH_ENDPOINT=https://models.github.ai/inference
100+
export GH_MODEL_ID=openai/gpt-5-mini
101+
```
94102

95-
يتوفر التنفيذ الكامل لـ C# في الملف المرافق `04-dotnet-agent-framework.cs`. يوضح هذا التطبيق الفردي لـ .NET:
103+
```powershell
104+
# PowerShell
105+
$env:GH_TOKEN = "<your_github_token>"
106+
$env:GH_ENDPOINT = "https://models.github.ai/inference"
107+
$env:GH_MODEL_ID = "openai/gpt-5-mini"
108+
```
96109

97-
- تحميل متغيرات البيئة لتكوين نماذج GitHub
98-
- تعريف أدوات مخصصة باستخدام طرق C# مع السمات
99-
- إنشاء وكيل AI مع تكامل الأدوات
100-
- إدارة سلاسل المحادثات
101-
- تنفيذ طلبات الوكيل مع استدعاء الأدوات
110+
### مثال على الكود
102111

103-
لتشغيل المثال:
112+
لتشغيل مثال الكود،
104113

105114
```bash
106-
chmod +x 04-dotnet-agent-framework.cs
115+
# zsh/bash
116+
chmod +x ./04-dotnet-agent-framework.cs
107117
./04-dotnet-agent-framework.cs
108118
```
109119

110-
أو باستخدام CLI الخاص بـ .NET:
120+
أو باستخدام dotnet CLI:
111121

112122
```bash
113-
dotnet run 04-dotnet-agent-framework.cs
123+
dotnet run ./04-dotnet-agent-framework.cs
124+
```
125+
126+
راجع [`04-dotnet-agent-framework.cs`](../../../../04-tool-use/code_samples/04-dotnet-agent-framework.cs) للحصول على الكود الكامل.
127+
128+
```csharp
129+
#!/usr/bin/dotnet run
130+
131+
#:package Microsoft.Extensions.AI@10.*
132+
#:package Microsoft.Agents.AI.OpenAI@1.*-*
133+
134+
using System.ClientModel;
135+
using System.ComponentModel;
136+
137+
using Microsoft.Agents.AI;
138+
using Microsoft.Extensions.AI;
139+
140+
using OpenAI;
141+
142+
// Tool Function: Random Destination Generator
143+
// This static method will be available to the agent as a callable tool
144+
// The [Description] attribute helps the AI understand when to use this function
145+
// This demonstrates how to create custom tools for AI agents
146+
[Description("Provides a random vacation destination.")]
147+
static string GetRandomDestination()
148+
{
149+
// List of popular vacation destinations around the world
150+
// The agent will randomly select from these options
151+
var destinations = new List<string>
152+
{
153+
"Paris, France",
154+
"Tokyo, Japan",
155+
"New York City, USA",
156+
"Sydney, Australia",
157+
"Rome, Italy",
158+
"Barcelona, Spain",
159+
"Cape Town, South Africa",
160+
"Rio de Janeiro, Brazil",
161+
"Bangkok, Thailand",
162+
"Vancouver, Canada"
163+
};
164+
165+
// Generate random index and return selected destination
166+
// Uses System.Random for simple random selection
167+
var random = new Random();
168+
int index = random.Next(destinations.Count);
169+
return destinations[index];
170+
}
171+
172+
// Extract configuration from environment variables
173+
// Retrieve the GitHub Models API endpoint, defaults to https://models.github.ai/inference if not specified
174+
// Retrieve the model ID, defaults to openai/gpt-5-mini if not specified
175+
// Retrieve the GitHub token for authentication, throws exception if not specified
176+
var github_endpoint = Environment.GetEnvironmentVariable("GH_ENDPOINT") ?? "https://models.github.ai/inference";
177+
var github_model_id = Environment.GetEnvironmentVariable("GH_MODEL_ID") ?? "openai/gpt-5-mini";
178+
var github_token = Environment.GetEnvironmentVariable("GH_TOKEN") ?? throw new InvalidOperationException("GH_TOKEN is not set.");
179+
180+
// Configure OpenAI Client Options
181+
// Create configuration options to point to GitHub Models endpoint
182+
// This redirects OpenAI client calls to GitHub's model inference service
183+
var openAIOptions = new OpenAIClientOptions()
184+
{
185+
Endpoint = new Uri(github_endpoint)
186+
};
187+
188+
// Initialize OpenAI Client with GitHub Models Configuration
189+
// Create OpenAI client using GitHub token for authentication
190+
// Configure it to use GitHub Models endpoint instead of OpenAI directly
191+
var openAIClient = new OpenAIClient(new ApiKeyCredential(github_token), openAIOptions);
192+
193+
// Define Agent Identity and Comprehensive Instructions
194+
// Agent name for identification and logging purposes
195+
var AGENT_NAME = "TravelAgent";
196+
197+
// Detailed instructions that define the agent's personality, capabilities, and behavior
198+
// This system prompt shapes how the agent responds and interacts with users
199+
var AGENT_INSTRUCTIONS = """
200+
You are a helpful AI Agent that can help plan vacations for customers.
201+
202+
Important: When users specify a destination, always plan for that location. Only suggest random destinations when the user hasn't specified a preference.
203+
204+
When the conversation begins, introduce yourself with this message:
205+
"Hello! I'm your TravelAgent assistant. I can help plan vacations and suggest interesting destinations for you. Here are some things you can ask me:
206+
1. Plan a day trip to a specific location
207+
2. Suggest a random vacation destination
208+
3. Find destinations with specific features (beaches, mountains, historical sites, etc.)
209+
4. Plan an alternative trip if you don't like my first suggestion
210+
211+
What kind of trip would you like me to help you plan today?"
212+
213+
Always prioritize user preferences. If they mention a specific destination like "Bali" or "Paris," focus your planning on that location rather than suggesting alternatives.
214+
""";
215+
216+
// Create AI Agent with Advanced Travel Planning Capabilities
217+
// Initialize complete agent pipeline: OpenAI client → Chat client → AI agent
218+
// Configure agent with name, detailed instructions, and available tools
219+
// This demonstrates the .NET agent creation pattern with full configuration
220+
AIAgent agent = openAIClient
221+
.GetChatClient(github_model_id)
222+
.CreateAIAgent(
223+
name: AGENT_NAME,
224+
instructions: AGENT_INSTRUCTIONS,
225+
tools: [AIFunctionFactory.Create(GetRandomDestination)]
226+
);
227+
228+
// Create New Conversation Thread for Context Management
229+
// Initialize a new conversation thread to maintain context across multiple interactions
230+
// Threads enable the agent to remember previous exchanges and maintain conversational state
231+
// This is essential for multi-turn conversations and contextual understanding
232+
AgentThread thread = agent.GetNewThread();
233+
234+
// Execute Agent: First Travel Planning Request
235+
// Run the agent with an initial request that will likely trigger the random destination tool
236+
// The agent will analyze the request, use the GetRandomDestination tool, and create an itinerary
237+
// Using the thread parameter maintains conversation context for subsequent interactions
238+
await foreach (var update in agent.RunStreamingAsync("Plan me a day trip", thread))
239+
{
240+
await Task.Delay(10);
241+
Console.Write(update);
242+
}
243+
244+
Console.WriteLine();
245+
246+
// Execute Agent: Follow-up Request with Context Awareness
247+
// Demonstrate contextual conversation by referencing the previous response
248+
// The agent remembers the previous destination suggestion and will provide an alternative
249+
// This showcases the power of conversation threads and contextual understanding in .NET agents
250+
await foreach (var update in agent.RunStreamingAsync("I don't like that destination. Plan me another vacation.", thread))
251+
{
252+
await Task.Delay(10);
253+
Console.Write(update);
254+
}
114255
```
115256

116257
---
117258

259+
<!-- CO-OP TRANSLATOR DISCLAIMER START -->
118260
**إخلاء المسؤولية**:
119-
تم ترجمة هذا المستند باستخدام خدمة الترجمة بالذكاء الاصطناعي [Co-op Translator](https://github.com/Azure/co-op-translator). بينما نسعى لتحقيق الدقة، يرجى العلم أن الترجمات الآلية قد تحتوي على أخطاء أو عدم دقة. يجب اعتبار المستند الأصلي بلغته الأصلية المصدر الموثوق. للحصول على معلومات حاسمة، يُوصى بالترجمة البشرية الاحترافية. نحن غير مسؤولين عن أي سوء فهم أو تفسيرات خاطئة ناتجة عن استخدام هذه الترجمة.
261+
تمت ترجمة هذا المستند باستخدام خدمة الترجمة بالذكاء الاصطناعي [Co-op Translator](https://github.com/Azure/co-op-translator). بينما نسعى لتحقيق الدقة، يرجى العلم أن الترجمات الآلية قد تحتوي على أخطاء أو عدم دقة. يجب اعتبار المستند الأصلي بلغته الأصلية المصدر الموثوق. للحصول على معلومات حاسمة، يُوصى بالترجمة البشرية الاحترافية. نحن غير مسؤولين عن أي سوء فهم أو تفسيرات خاطئة ناتجة عن استخدام هذه الترجمة.
262+
<!-- CO-OP TRANSLATOR DISCLAIMER END -->

0 commit comments

Comments
 (0)