也就是配置RWKV向外提供API访问权;并将openai的api_base改为本地访问地址。

# 设置 OpenAI 的 API 密钥
openai.api_key = "free"#os.getenv('OPENAI_API_KEY')
#老版本,过时了,1.2已经不支持了
openai.api_base = "http://127.0.0.1:8000/v1" #在这里设置即可,需要特别注意这里的/v1是必须的,否则报错。前面的地址注意替换即可。
# 加载 Spacy 的中文模型,用于句子的分割
nlp = spacy.load('zh_core_web_sm')
# 定义一个函数,用于在请求 OpenAI API 超过速率限制时进行重试
def request_with_retry(messages, max_tokens=500, max_requests=90, cooldown_seconds=60):
    while True:
        try:
            response = openai.ChatCompletion.create(
                model="RWKV-4-Raven-3B-v11-Eng49%-Chn49%-Jpn1%-Other1%-20230429-ctx4096",
                messages=messages,
                max_tokens=max_tokens,
                n=1,
             







![2024.9.9(极客大挑战 2019]EasySQL,[极客大挑战 2019]Knife)](https://i-blog.csdnimg.cn/direct/a3af68333eef4705aff32f7aa134546d.png)










