个人可以建网站,西安市长安区建设局网站,龙炎电商软件,利搜网站排名软件笔者曾经写过 ChatGPT OpenAI API请求限制 尝试解决 Account deactivated. Please contact us through our help center at help.openai.com if you need assistance. 结果如何#xff1f; 没有啥用。目前发现一条曲线救国的方案。
1. 在官方 openai 库中使用
此处为最新Op…笔者曾经写过 ChatGPT OpenAI API请求限制 尝试解决 Account deactivated. Please contact us through our help center at help.openai.com if you need assistance. 结果如何 没有啥用。目前发现一条曲线救国的方案。
1. 在官方 openai 库中使用
此处为最新OpenAI包调用方式
from openai import OpenAIclient OpenAI(# #将这里换成你在orisound api keys拿到的密钥api_keysk-xxx,# 这里将官方的接口访问地址替换成orisound的入口地址base_urlhttps://orisound.cn/v1
)chat_completion client.chat.completions.create(messages[{role: user,content: Say this is a test,}],modelgpt-3.5-turbo,
)print(chat_completion)2. 在 LangChain 中使用
注意openai_api_base 的末尾要加上 /v1
from langchain.chat_models import ChatOpenAIllm ChatOpenAI(openai_api_basehttps://aihubmix.com/v1, # 注意末尾要加 /v1openai_api_keysk-3133f******fee269b71d,
)res llm.predict(hello)print(res)示例代码使用LLM进行预测 核心其实在于key和url的设置 方法有
使用环境变量来设置使用变量来传入使用手动设置环境变量
import os
import requests
import time
import json
import time
from langchain.llms import OpenAIAPI_SECRET_KEY 你在aihubmix的key;
BASE_URL https://aihubmix.com/v1; #aihubmix的base-urlos.environ[OPENAI_API_KEY] API_SECRET_KEY
os.environ[OPENAI_API_BASE] BASE_URLdef text():llm OpenAI(temperature0.9)text What would be a good company name for a company that makes colorful socks?print(llm(text))if __name__ __main__:text();运行后可以看到返回
Lively Socks.参考
https://aihubmix.com/about