Comments (5)
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.
你没有修改base url吧
from gpt_api_free.
改了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.
@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.
@gogogo314 你使用的免费key 免费key只能用embedding和gpt3
from gpt_api_free.
Related Issues (20)
- 本地调试是返回中文内容,放到另一个主机上就返回英文内容了
- zotero-gpt中使用出错 提示“Incorrect API key provided" HOT 1
- token计算问题.app,查询后台,计算示例网页各自的结果都不同. HOT 3
- 支持Obsidian吗? HOT 1
- [Enhancement] 什么时候计划集成gpt-4o呢? HOT 2
- [Enhancement]请问能否支持dbever HOT 4
- demo.py报错chunk.choices[0].delta.content list index out of range HOT 1
- 免费的api key不支持官方的API HOT 1
- 现在的价格还有折扣吗? HOT 1
- 使用langchain写这个免费的gpt的接口 好像一直连不上 HOT 2
- API key调用失败 HOT 2
- VIP通道响应速度会不会比普通KEY快? HOT 5
- zotero gpt的askpdf功能失效,但是换用了openai的官方api后是可以用的,所以排除了zotero gpt插件的问题 HOT 6
- 作者您好,zotero使用gpt无法翻译 HOT 1
- 免费API报错403 HOT 4
- https://chatanywhere.cn/进不去了 HOT 1
- 请问。。 HOT 1
- 免费API在调用gpt-3.5-turbo时经常返回如下错误,只要gpt试图调用tool call就会这样,如果不调用tool call,直接response就正常 HOT 2
- langchain_openai调用返回403 HOT 2
- 请问我们支持转发 openai 的 assistants 吗? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gpt_api_free.