تحويل

تعرف على كيفية ترجمة النص وتلخيصه وتحويله إلى رموز تعبيرية باستخدام API OpenAI .

سنغطي ما يلي...

Overview

The chat completions endpoint has the ability to translate from one language to another language, summarize the text, and convert the text to emojis or vice versa.

Press + to interact
Transformation
Transformation

نقوم إدخال نص المطالبة ومعلمات طلب في نموذج OpenAI API لتحويل النص.

Press + to interact
Completions: text transformation
Completions: text transformation

Translation

The OpenAI API can translate from one language to another language.

Let’s see how to provide the prompt to translate from English to other languages.

Translate this into 1. French, 2. Spanish and 3. Japanese.

We provide an online learning platform made by developers, created for developers.

Example

Let’s try the above example in the code widget below:

Press + to interact
Python
#Translating from english to other languages
from openai import OpenAI
client = OpenAI(api_key="{{SECRET_KEY}}")
response = client.chat.completions.create(
model="gpt-3.5-turbo",
response_format={ "type": "json_object" },
messages=[
{"role": "system", "content": "Translate this into 1. French, 2. Spanish and 3. Japanese. Provide output in json"},
{"role": "user", "content": "We provide an online learning platform made by developers, created for developers."}
],
temperature=0,
max_tokens=130,
top_p=1.0,
)
print(response.choices[0].message.content)

In the code above, temperature is set to 0 because we don’t need randomness in the ...