binary-husky / binary-husky/void-terminal
不好使啊,大兄弟
- Dominant language
- Python
- Stars
- 19
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
# Env setup:
```
pip install void-terminal
```
# 使用的代码:
```
import void_terminal as vt
# For more available configurations (including network proxy, api, using chatglm etc.),
# see config.py of in the mother project:
# https://github.com/binary-husky/gpt_academic.git
vt.set_conf(key="API_KEY", value="sk-xxxxxxxxxxxxxx") #key已经改成我的了。
vt.set_conf(key="LLM_MODEL", value="gpt-3.5-turbo")
chat_kwargs = vt.get_chat_default_kwargs()
chat_kwargs['inputs'] = 'Hello, world!'
result = vt.get_chat_handle()(**chat_kwargs)
print('\n*************\n' + result + '\n*************\n' )
```
# Result: Error!
```
(gptac_venv) C:\Users\libin\Desktop\work\code\LLM\gpt_academic-master\void-terminal>python test_1.py
None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used.
gpt-3.5-turbo : 0 : Hello, world! ..........
Traceback (most recent call last):
File "C:\Users\libin\Desktop\work\code\LLM\gpt_academic-master\void-terminal\test_1.py", line 10, in
result = vt.get_chat_handle()(**chat_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\libin\anaconda3\envs\gptac_venv\Lib\site-packages\void_terminal\request_llms\bridge_all.py", line 597, in predict_no_ui_long_connection
return method(inputs, llm_kwargs, history, sys_prompt, observe_window, console_slience)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\libin\anaconda3\envs\gptac_venv\Lib\site-packages\void_terminal\request_llms\bridge_chatgpt.py", line 115, in predict_no_ui_long_connection
raise RuntimeError("OpenAI rejected the request:" + error_msg)
RuntimeError: OpenAI rejected the request:{"object":"error","message":"Unauthorized.1 bad forward key {sk-xxxxxxx}","code":40002}
```
# Key确认是好使的:
```
import os
import openai
openai.api_key = "sk-xxxxxx"
# openai.organization = os.getenv("OPENAI_ORGANIZATION")
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who won the world series in 2020?"},
{"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
{"role": "user", "content": "Where was it played?"}
]
)
print(response['choices'][0]['message']['content'])
```
Result:
```
The 2020 World Series was played in Arlington, Texas at the Globe Life Field, which is the home stadium of the Texas Rangers.
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the failure with test_1.py and compare its configuration with the direct openai.ChatCompletion example. Inspect the installed request_llms/bridge_all.py and bridge_chatgpt.py paths shown in the traceback, along with the referenced config.py. Done means the package accepts the same valid key and completes the gpt-3.5-turbo request without the unauthorized forward-key error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 45/100