Coder Social home page Coder Social logo

Comments (2)

PantsuDango avatar PantsuDango commented on June 2, 2024

from dango-translator.

Ami0617 avatar Ami0617 commented on June 2, 2024

你好,感谢回复!
根据官方文档(learn.microsoft.com/en-us/azure/ai-services/openai/reference),
request的部分需要resource_name和deployment_name,api-version也需要指定
header和data的部分也与openai的文档所记载的参数有些不同
API_KEY需要在header中填写,没有Authorization的参数

data部分的话看起来也不需要指定model参数,
因为根据部署不同即YOUR_DEPLOYMENT_NAME不同模型也会不同

以下是我用于测试的curl和python的代码

curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/completions?api-version=2023-05-15\
-H "Content-Type: application/json"
-H "api-key: YOUR_API_KEY"
-d "{
"messages": [{"role":"system","content":"You are an AI assistant that helps people find information."}],
"max_tokens": 4000,
"temperature": 0.7,
"frequency_penalty": 0,
"presence_penalty": 0,
"top_p": 0.95,
"stop": null
}"

test.py

import os
import openai
openai.api_type = "azure"
openai.api_base = "https://YOUR_RESOURCE_NAME.openai.azure.com/"
openai.api_version = "2023-07-01-preview"
openai.api_key = os.getenv("OPENAI_API_KEY")

openai.api_key = API_KEY

response = openai.ChatCompletion.create(
engine="YOUR_DEPLOYMENT_NAME",
messages = [{"role":"system","content":"You are an AI assistant that helps people find information."}],
temperature=0.7,
max_tokens=4000,
top_p=0.95,
frequency_penalty=0,
presence_penalty=0,
stop=None)

from dango-translator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.