ida_copilot
ida_copilot copied to clipboard
如何修改openai的apibase?
openai的免费api限速限制的太厉害了,换了国内套皮api,自己改了很久没弄出来,请问如何正确的修改apibase? plugins\ida_copilot\copilot.py
class ChatCloseAI(ChatOpenAI):
def __init__(self, temperature=0.2, model='gpt-3.5-turbo-0613'):
# 设置新的API基础URL和API密钥
self.api_base_url = 'https://api.openai-proxy.org'
self.api_key = '1111111111111'
super().__init__(temperature=temperature, model=model)
def _create_headers(self):
# 使用新的API密钥创建请求头
return {
'Content-Type': 'application/json',
'Authorization': f'Bearer {self.api_key}'
}
# 在初始化agent时使用新的ChatCloseAI类
agent = initialize_agent(
agent_type=AgentType.OPENAI_MULTI_FUNCTIONS,
llm=ChatCloseAI(temperature=temperature, model=model),
tools=tools,
verbose=True,
)
这个链接可能会有帮助