File size: 15,832 Bytes
566d03e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
"""
Native Arabic Function Schemas
==============================

Bilingual function definitions with Arabic names, descriptions, and examples.
"""

NATIVE_ARABIC_SCHEMAS = [
    # Financial Services - الخدمات المالية
    {
        "name": "transfer_money",
        "name_ar": "تحويل_أموال",
        "description": "Transfer money between bank accounts",
        "description_ar": "تحويل أموال بين الحسابات البنكية",
        "parameters": {
            "type": "object",
            "properties": {
                "from_account": {
                    "type": "string",
                    "description": "Source account number",
                    "description_ar": "رقم الحساب المصدر",
                    "examples_ar": ["SA0380000000608010167519"]
                },
                "to_account": {
                    "type": "string",
                    "description": "Destination account number",
                    "description_ar": "رقم الحساب المستقبل"
                },
                "amount": {
                    "type": "number",
                    "description": "Amount to transfer",
                    "description_ar": "المبلغ المراد تحويله"
                },
                "currency": {
                    "type": "string",
                    "description": "Currency code",
                    "description_ar": "رمز العملة",
                    "enum": ["SAR", "AED", "EGP", "KWD", "QAR"],
                    "examples_ar": ["ريال سعودي", "درهم إماراتي", "جنيه مصري"]
                }
            },
            "required": ["from_account", "to_account", "amount"]
        }
    },
    {
        "name": "check_balance",
        "name_ar": "استعلام_رصيد",
        "description": "Check account balance",
        "description_ar": "الاستعلام عن رصيد الحساب",
        "parameters": {
            "type": "object",
            "properties": {
                "account_number": {
                    "type": "string",
                    "description": "Account number to check",
                    "description_ar": "رقم الحساب للاستعلام"
                }
            },
            "required": ["account_number"]
        }
    },
    {
        "name": "pay_bill",
        "name_ar": "دفع_فاتورة",
        "description": "Pay a utility or service bill",
        "description_ar": "دفع فاتورة خدمات",
        "parameters": {
            "type": "object",
            "properties": {
                "bill_type": {
                    "type": "string",
                    "description": "Type of bill",
                    "description_ar": "نوع الفاتورة",
                    "enum": ["electricity", "water", "telecom", "internet"],
                    "enum_ar": ["كهرباء", "مياه", "اتصالات", "إنترنت"]
                },
                "account_id": {
                    "type": "string",
                    "description": "Bill account/subscriber ID",
                    "description_ar": "رقم المشترك"
                },
                "amount": {
                    "type": "number",
                    "description": "Amount to pay",
                    "description_ar": "المبلغ المراد دفعه"
                }
            },
            "required": ["bill_type", "account_id"]
        }
    },

    # Government Services - الخدمات الحكومية
    {
        "name": "renew_id",
        "name_ar": "تجديد_هوية",
        "description": "Renew national ID card",
        "description_ar": "تجديد بطاقة الهوية الوطنية",
        "parameters": {
            "type": "object",
            "properties": {
                "id_number": {
                    "type": "string",
                    "description": "National ID number",
                    "description_ar": "رقم الهوية الوطنية"
                },
                "reason": {
                    "type": "string",
                    "description": "Reason for renewal",
                    "description_ar": "سبب التجديد",
                    "enum": ["expiry", "damaged", "lost", "data_update"],
                    "enum_ar": ["انتهاء الصلاحية", "تالفة", "مفقودة", "تحديث بيانات"]
                }
            },
            "required": ["id_number"]
        }
    },
    {
        "name": "book_appointment",
        "name_ar": "حجز_موعد",
        "description": "Book an appointment at a government office",
        "description_ar": "حجز موعد في جهة حكومية",
        "parameters": {
            "type": "object",
            "properties": {
                "service_type": {
                    "type": "string",
                    "description": "Type of service",
                    "description_ar": "نوع الخدمة"
                },
                "location": {
                    "type": "string",
                    "description": "Preferred location/branch",
                    "description_ar": "الفرع المفضل",
                    "examples_ar": ["الرياض - العليا", "جدة - الحمراء"]
                },
                "date": {
                    "type": "string",
                    "description": "Preferred date (YYYY-MM-DD)",
                    "description_ar": "التاريخ المفضل"
                },
                "time_slot": {
                    "type": "string",
                    "description": "Preferred time slot",
                    "description_ar": "الفترة الزمنية",
                    "enum": ["morning", "afternoon"],
                    "enum_ar": ["صباحي", "مسائي"]
                }
            },
            "required": ["service_type", "date"]
        }
    },

    # E-commerce - التجارة الإلكترونية
    {
        "name": "search_product",
        "name_ar": "البحث_عن_منتج",
        "description": "Search for products in the store",
        "description_ar": "البحث عن منتجات في المتجر",
        "parameters": {
            "type": "object",
            "properties": {
                "query": {
                    "type": "string",
                    "description": "Search query",
                    "description_ar": "كلمات البحث"
                },
                "category": {
                    "type": "string",
                    "description": "Product category",
                    "description_ar": "فئة المنتج",
                    "examples_ar": ["إلكترونيات", "ملابس", "أجهزة منزلية"]
                },
                "min_price": {
                    "type": "number",
                    "description": "Minimum price",
                    "description_ar": "الحد الأدنى للسعر"
                },
                "max_price": {
                    "type": "number",
                    "description": "Maximum price",
                    "description_ar": "الحد الأقصى للسعر"
                },
                "sort_by": {
                    "type": "string",
                    "description": "Sort order",
                    "description_ar": "ترتيب حسب",
                    "enum": ["price_asc", "price_desc", "rating", "newest"],
                    "enum_ar": ["السعر تصاعدي", "السعر تنازلي", "التقييم", "الأحدث"]
                }
            },
            "required": ["query"]
        }
    },
    {
        "name": "add_to_cart",
        "name_ar": "إضافة_للسلة",
        "description": "Add a product to shopping cart",
        "description_ar": "إضافة منتج إلى سلة التسوق",
        "parameters": {
            "type": "object",
            "properties": {
                "product_id": {
                    "type": "string",
                    "description": "Product identifier",
                    "description_ar": "معرف المنتج"
                },
                "quantity": {
                    "type": "integer",
                    "description": "Quantity to add",
                    "description_ar": "الكمية",
                    "default": 1
                },
                "size": {
                    "type": "string",
                    "description": "Product size if applicable",
                    "description_ar": "المقاس"
                },
                "color": {
                    "type": "string",
                    "description": "Product color if applicable",
                    "description_ar": "اللون"
                }
            },
            "required": ["product_id"]
        }
    },

    # Healthcare - الرعاية الصحية
    {
        "name": "book_doctor_appointment",
        "name_ar": "حجز_موعد_طبيب",
        "description": "Book an appointment with a doctor",
        "description_ar": "حجز موعد مع طبيب",
        "parameters": {
            "type": "object",
            "properties": {
                "specialty": {
                    "type": "string",
                    "description": "Medical specialty",
                    "description_ar": "التخصص الطبي",
                    "examples_ar": ["طب عام", "طب أطفال", "طب باطني", "طب عيون", "طب أسنان"]
                },
                "doctor_name": {
                    "type": "string",
                    "description": "Specific doctor name (optional)",
                    "description_ar": "اسم الطبيب (اختياري)"
                },
                "hospital": {
                    "type": "string",
                    "description": "Hospital or clinic name",
                    "description_ar": "اسم المستشفى أو العيادة"
                },
                "date": {
                    "type": "string",
                    "description": "Preferred date",
                    "description_ar": "التاريخ المفضل"
                },
                "reason": {
                    "type": "string",
                    "description": "Reason for visit",
                    "description_ar": "سبب الزيارة"
                }
            },
            "required": ["specialty", "date"]
        }
    },
    {
        "name": "get_lab_results",
        "name_ar": "نتائج_التحاليل",
        "description": "Retrieve laboratory test results",
        "description_ar": "استرجاع نتائج التحاليل المخبرية",
        "parameters": {
            "type": "object",
            "properties": {
                "patient_id": {
                    "type": "string",
                    "description": "Patient ID or file number",
                    "description_ar": "رقم المريض أو الملف"
                },
                "test_type": {
                    "type": "string",
                    "description": "Type of test",
                    "description_ar": "نوع التحليل",
                    "examples_ar": ["تحليل دم شامل", "تحليل سكر", "وظائف كلى", "وظائف كبد"]
                },
                "date_from": {
                    "type": "string",
                    "description": "Start date for results",
                    "description_ar": "تاريخ البداية"
                }
            },
            "required": ["patient_id"]
        }
    },

    # Travel & Transportation - السفر والنقل
    {
        "name": "book_flight",
        "name_ar": "احجز_رحلة",
        "description": "Book a flight between cities",
        "description_ar": "حجز رحلة طيران بين المدن",
        "parameters": {
            "type": "object",
            "properties": {
                "origin": {
                    "type": "string",
                    "description": "Departure city",
                    "description_ar": "مدينة المغادرة",
                    "examples_ar": ["القاهرة", "الرياض", "دبي", "جدة"]
                },
                "destination": {
                    "type": "string",
                    "description": "Arrival city",
                    "description_ar": "مدينة الوصول"
                },
                "date": {
                    "type": "string",
                    "description": "Travel date",
                    "description_ar": "تاريخ السفر"
                },
                "return_date": {
                    "type": "string",
                    "description": "Return date (optional)",
                    "description_ar": "تاريخ العودة (اختياري)"
                },
                "passengers": {
                    "type": "integer",
                    "description": "Number of passengers",
                    "description_ar": "عدد المسافرين",
                    "default": 1
                },
                "class": {
                    "type": "string",
                    "description": "Travel class",
                    "description_ar": "درجة السفر",
                    "enum": ["economy", "business", "first"],
                    "enum_ar": ["اقتصادية", "أعمال", "أولى"]
                }
            },
            "required": ["origin", "destination", "date"]
        }
    },

    # Weather - الطقس
    {
        "name": "get_weather",
        "name_ar": "احصل_على_الطقس",
        "description": "Get weather information for a city",
        "description_ar": "الحصول على معلومات الطقس لمدينة",
        "parameters": {
            "type": "object",
            "properties": {
                "city": {
                    "type": "string",
                    "description": "City name",
                    "description_ar": "اسم المدينة",
                    "examples_ar": ["القاهرة", "دبي", "الرياض", "بيروت", "عمان"]
                },
                "days": {
                    "type": "integer",
                    "description": "Number of forecast days",
                    "description_ar": "عدد أيام التوقعات",
                    "default": 1
                }
            },
            "required": ["city"]
        }
    }
]


def get_schema_by_name(name: str, use_arabic: bool = False) -> dict:
    """Get a schema by its name (English or Arabic)."""
    for schema in NATIVE_ARABIC_SCHEMAS:
        if schema['name'] == name or schema.get('name_ar') == name:
            if use_arabic:
                # Return Arabic-ified version
                return {
                    'name': schema.get('name_ar', schema['name']),
                    'description': schema.get('description_ar', schema['description']),
                    'parameters': schema['parameters']
                }
            return schema
    return None


def get_schemas_by_category(category: str) -> list:
    """Get all schemas in a category."""
    category_map = {
        'financial': ['transfer_money', 'check_balance', 'pay_bill'],
        'government': ['renew_id', 'book_appointment'],
        'ecommerce': ['search_product', 'add_to_cart'],
        'healthcare': ['book_doctor_appointment', 'get_lab_results'],
        'travel': ['book_flight'],
        'weather': ['get_weather'],
    }

    names = category_map.get(category, [])
    return [get_schema_by_name(name) for name in names if get_schema_by_name(name)]