当前位置:   article > 正文

OpenAi 翻译_openai的翻译api

openai的翻译api

将英文文本翻译成法文、西班牙文和日文。

将其翻译成 1. 法语,2. 西班牙语和 3. 日语:你们有哪些房间可用?1. 

示例响应 

 Quels sont les chambres que vous avez disponibles?2. Qué habitaciones tienes disponibles?3.どの部屋ガ利用可能ですか?

Python
 

  1. import os
  2. import openai
  3. openai.api_key = os.getenv("OPENAI_API_KEY")
  4. response = openai.Completion.create(
  5. model="text-davinci-003",
  6. prompt="Translate this into 1. French, 2. Spanish and 3. Japanese:\n\nWhat rooms do you have available?\n\n1.",
  7. temperature=0.3,
  8. max_tokens=100,
  9. top_p=1.0,
  10. frequency_penalty=0.0,
  11. presence_penalty=0.0
  12. )

 JavaScript

  1. const { Configuration, OpenAIApi } = require("openai");
  2. const configuration = new Configuration({
  3. apiKey: process.env.OPENAI_API_KEY,
  4. });
  5. const openai = new OpenAIApi(configuration);
  6. const response = await openai.createCompletion({
  7. model: "text-davinci-003",
  8. prompt: "Translate this into 1. French, 2. Spanish and 3. Japanese:\n\nWhat rooms do you have available?\n\n1.",
  9. temperature: 0.3,
  10. max_tokens: 100,
  11. top_p: 1.0,
  12. frequency_penalty: 0.0,
  13. presence_penalty: 0.0,
  14. });
  1. curl https://api.openai.com/v1/completions \
  2. -H "Content-Type: application/json" \
  3. -H "Authorization: Bearer $OPENAI_API_KEY" \
  4. -d '{
  5. "model": "text-davinci-003",
  6. "prompt": "Translate this into 1. French, 2. Spanish and 3. Japanese:\n\nWhat rooms do you have available?\n\n1.",
  7. "temperature": 0.3,
  8. "max_tokens": 100,
  9. "top_p": 1.0,
  10. "frequency_penalty": 0.0,
  11. "presence_penalty": 0.0
  12. }'

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/寸_铁/article/detail/855909
推荐阅读
相关标签
  

闽ICP备14008679号