chatanywhere / GPT_API_free

Free ChatGPT API Key,免费ChatGPT API,支持GPT4 API(免费),ChatGPT国内可用免费转发API,直连无需代理。可以搭配ChatBox等软件/插件使用,极大降低接口使用成本。国内即可无限制畅快聊天。

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

我代码中用的是gpt-3.5-turbo没错,但报错卻显示免费API限制使用gpt-3.5-turbo,gpt-4 和 embeddings模型

chyc307 opened this issue · comments

你好,
谢谢您提供免费的转接API供大家使用,
我想把此API编写成一个Discord的功能指令,使用python语言,如下:

import openai
openai.api_key='sk-pp'
openai.api_base='https://api.chatanywhere.tech/v1'

class ChatGPT(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        
    @commands.command()
    async def gpt(self, ctx, *, query: str):
        try:
            completion = openai.Completion.create(model="gpt-3.5-turbo", messages=query)
            await ctx.reply(completion.choices[0].message.content)

        except Exception as e:
            await ctx.reply(f"An error occurred: {str(e)}")

可以看到我在代码中使用的模型为gpt-3.5-turbo,但是他的回应如下:
!gpt 您好,今天天气真好
An error occurred: 免费API限制使用gpt-3.5-turbo,gpt-4 和 embeddings模型,如有更多需求,请访问 https://buyca.top/ 购买付费API。The free account is limited to use gpt-3.5-turbo, gpt-4 and embeddings. If you have additional requirements, please visit https://buyca.top/ to purchase a premium key.

想请问我是否忽略了什么? 另外我没办法直接使用from openai import OpenAI的方式,

  File "C:\Users\user\DiscordBot\cogs\main.py", line 18, in <module>
     from openai import OpenAI
ImportError: cannot import name 'OpenAI' from 'openai' (C:\Users\user\anaconda3\lib\site-packages\openai\__init__.py) 

所以直接用import openai来执行。 我也不确定是否与你们使用的是相同的版本,但应该是最新版本。

非常感谢

openai.Completion.create是调用OpenAI基础模型的方法
调用GPT应该使用openai.ChatCompletion.create