Giter Site home page Giter Site logo

密钥失效 about gpt_api_free HOT 5 CLOSED

chatanywhere avatar chatanywhere commented on June 26, 2024
密钥失效

from gpt_api_free.

Comments (5)

gogogo314 avatar gogogo314 commented on June 26, 2024

import os
os.environ['OPENAI_API_KEY'] = 'sk-*******Vb7'
from langchain.llms import OpenAI
llm = OpenAI(model_name="text-davinci-003", max_tokens=1024)
llm("怎么评价人工智能")

这是我的代码

from gpt_api_free.

chatanywhere avatar chatanywhere commented on June 26, 2024

你没有修改base url吧

from gpt_api_free.

MrRace avatar MrRace commented on June 26, 2024

改了base url一样报错:

import os
from langchain.llms import OpenAI
os.environ['OPENAI_API_KEY'] ="sk-XXXX"
# os.environ['HTTP_PROXY'] = "http://api.chatanywhere.com.cn"
# os.environ['HTTPS_PROXY'] = "http://api.chatanywhere.com.cn"
os.environ['OPENAI_API_BASE'] = 'https://api.chatanywhere.com.cn/v1'
llm = OpenAI(model_name="text-davinci-003", max_tokens=1024)
llm("怎么评价人工智能")

from gpt_api_free.

gogogo314 avatar gogogo314 commented on June 26, 2024

@chatanywhere 还是不行
https://api.chatanywhere.com.cn/v1和https://api.chatanywhere.cn/v1,我都试了
我用的
我用的是 @MrRace 的代码

报错:
`Retrying langchain.llms.openai.completion_with_retry.._completion_with_retry in 4.0 seconds as it raised APIError: HTTP code 401 from API (limit to use gpt-3.5-turbo and embeddings
).
Retrying langchain.llms.openai.completion_with_retry.._completion_with_retry in 4.0 seconds as it raised APIError: HTTP code 401 from API (limit to use gpt-3.5-turbo and embeddings
).
Retrying langchain.llms.openai.completion_with_retry.._completion_with_retry in 4.0 seconds as it raised APIError: HTTP code 401 from API (limit to use gpt-3.5-turbo and embeddings
).
Retrying langchain.llms.openai.completion_with_retry.._completion_with_retry in 8.0 seconds as it raised APIError: HTTP code 401 from API (limit to use gpt-3.5-turbo and embeddings
).
Retrying langchain.llms.openai.completion_with_retry.._completion_with_retry in 10.0 seconds as it raised APIError: HTTP code 401 from API (limit to use gpt-3.5-turbo and embeddings
).
Traceback (most recent call last):
File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\openai\api_requestor.py", line 753, in interpret_response_line
data = json.loads(rbody)
File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\json_init
.py", line 346, in loads
return _default_decoder.decode(s)
File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\陈旭坤\Desktop\kor\use_example.py", line 9, in
llm("怎么评价人工智能")
File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\langchain\llms\base.py", line 363, in call
self.generate([prompt], stop=stop, callbacks=callbacks, **kwargs)
File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\langchain\llms\base.py", line 225, in generate
output = self._generate_helper(
File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\langchain\llms\base.py", line 176, in _generate_helper
raise e
File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\langchain\llms\base.py", line 163, in _generate_helper
self.generate(
File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\langchain\llms\openai.py", line 336, in generate
response = completion_with_retry(self, prompt=prompts, **params)
File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\langchain\llms\openai.py", line 106, in completion_with_retry
return completion_with_retry(**kwargs)
File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\tenacity_init
.py", line 289, in wrapped_f
return self(f, *args, **kw)
File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\tenacity_init
.py", line 379, in call
do = self.iter(retry_state=retry_state)
File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\tenacity_init
.py", line 325, in iter
raise retry_exc.reraise()
File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\tenacity_init
.py", line 158, in reraise
raise self.last_attempt.result()
File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\concurrent\futures_base.py", line 439, in result
return self.__get_result()
File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\concurrent\futures_base.py", line 391, in __get_result
raise self.exception
File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\tenacity_init
.py", line 382, in call
result = fn(*args, **kwargs)
File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\langchain\llms\openai.py", line 104, in _completion_with_retry
return llm.client.create(**kwargs)
File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\openai\api_resources\completion.py", line 25, in create
return super().create(*args, **kwargs)
File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 153, in create
response, _, api_key = requestor.request(
File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\openai\api_requestor.py", line 298, in request
resp, got_stream = self._interpret_response(result, stream)
File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\openai\api_requestor.py", line 700, in _interpret_response
self._interpret_response_line(
File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\openai\api_requestor.py", line 755, in _interpret_response_line
raise error.APIError(
openai.error.APIError: HTTP code 401 from API (limit to use gpt-3.5-turbo and embeddings
)`

from gpt_api_free.

chatanywhere avatar chatanywhere commented on June 26, 2024

@gogogo314 你使用的免费key 免费key只能用embedding和gpt3

from gpt_api_free.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.