إكمالات الدردشة
تعرف على كيفية إنشاء النص أو معالجته باستخدام نقطة نهاية الإكمال الخاصة بواجهة API OpenAI .
سنغطي ما يلي...
نقطة نهاية إكمال الدردشة
يمكن استخدام نقطة نهاية إكمال الدردشة لتنفيذ العديد من المهام على النص، بما في ذلك التصنيف، والتوليد، والتحويل، وإكمال النص غير المكتمل، والردود الفعلية، وغيرها. تتلقى نقطة النهاية رسالة إدخال من المستخدم والدور المُسند إليه، وتُرجع كائن JSON.
استدعاء واجهة برمجة API للإكمالات
في مقطع الكود أدناه، نستخدم مكتبة openai
في Python. يمكن استخدام الدالة التالية لاستدعاء نقطة نهاية الإكمال:
from openai import OpenAIclient = OpenAI(api_key="{{YOUR_SECTEY_KEY}}")response = client.chat.completions.create(model="model_id",messages=[{"role": "system", "content": "..."},{"role": "user", "content": "..."}],)
فهم نقطة نهاية إكمال الدردشة
دعونا نلقي نظرة على نقطة نهاية إكمال الدردشة بمزيد من التفصيل، ومراجعة معلمات طلب ومعلمات استجابة .
معلمات الطلب
دعونا نرى بعض معلمات طلب الأساسية لهذه النقطة النهائية في الجدول أدناه:
Fields | Format | Type | Description |
| Array | Required | This is a list of messages comprising the conversation as of yet. |
| String | Required | This is the ID of the model that the chat completions endpoint will use. |
| Integer | Optional | This is the maximum number of tokens to generate in the chat completion. |
| Float | Optional | Which sampling temperature should be employed, ranging from |
| Float | Optional | Nucleus sampling is an alternative to temperature sampling in which the model evaluates the outcomes of tokens with top p probability mass. So, 0.1 indicates that only the top 10% probability mass tokens will be evaluated. Default value: |
| object | Optional | This is an object that specifies the format of the output. This parameter is compatible with the newer models. Setting to |
| Integer | Optional | It indicates the number of chat completions to generate. Default value: |
| Integer | Optional | This value decides whether to return the log probabilities of output tokens. This option is not available on the Default value: |
| String/array | Optional | This allows you to provide four sequences where the API will stop generating further tokens. Default value: |
| Float | Optional | A value range between -2.0 to 2.0. The positive value penalizes the new tokens if they exist in the text, increasing the possibility of generating new things. Default value: |
| Float | Optional | A value range between -2.0 to 2.0. The positive value penalizes the new tokens concerning their existing frequency in the text, decreasing the possibility of repeating the same words. Default value: |
ملاحظة : يمكنك معرفة المزيد عن وسيطة ...