"请问ModelScope如何在Api中调用呢? 我的代码是os.environ[""OPENAI_API_KEY""] = ""EMPTY""
os.environ[""OPENAI_BASE_URL""] = ""http://localhost:8000/v1""
from openai import OpenAI
client = OpenAI()
client = openai.Client()
response = client.chat.completions.create(
model=""qwen/Qwen2-7B"",
messages=[
{""role"": ""system"", ""content"": ""You are a helpful assistant.""},
{""role"": ""user"", ""content"": ""Tell me something about large language models.""},
]
)
print(""Chat response:"", response['choices'][0]['message']['content'])
。除了将os.environ[""OPENAI_BASE_URL""] = ""http://localhost:8000/v1""
改成您说的网址之外,-H ""Content-Type: application/json"" \在哪添加呢?"
ModelScope旨在打造下一代开源的模型即服务共享平台,为泛AI开发者提供灵活、易用、低成本的一站式模型服务产品,让模型应用更简单!欢迎加入技术交流群:微信公众号:魔搭ModelScope社区,钉钉群号:44837352