iuiaoin / wechat-gptbot

A wechat robot based on ChatGPT with no risk, very stable! 🚀
MIT License
579 stars 113 forks source link

[Feat]: 能否支持一下自定义gpt 接口的超时时间 #108

Open goxofy opened 7 months ago

goxofy commented 7 months ago

Search for answers in existing issues

Feature description

No response

Motivation

No response

QAbot-zh commented 7 months ago

openai库有超时参数:https://github.com/openai/openai-python/blob/main/src/openai/_client.py#L49 ,在config里添加timeout配置,应该是可以的:

class ChatGPTBot:
    def __init__(self):
        openai.api_key = conf().get("openai_api_key")
        api_base = conf().get("openai_api_base")
        proxy = conf().get("proxy")
        if api_base:
            openai.api_base = api_base
        if proxy:
            openai.proxy = proxy
        self.name = self.__class__.__name__
        self.args = {
            "model": conf().get("model"),
            "temperature": conf().get("temperature"),
            "timeout": conf().get("timeout"),   # 这里添加了timeout参数
        }