labteral / chatgpt-python Goto Github PK
View Code? Open in Web Editor NEWUnofficial Python SDK for OpenAI's ChatGPT
Home Page: https://labteral.github.io/chatgpt-python/
License: GNU General Public License v3.0
Unofficial Python SDK for OpenAI's ChatGPT
Home Page: https://labteral.github.io/chatgpt-python/
License: GNU General Public License v3.0
Hey, I am trying to ask ChatGPT something but I get an Error everytime.
My Code is:
from chatgpt import Conversation
convo = Conversation(access_token="INSERT API TOKEN HERE")
print("> Design a a Blog in HTML")
try:
print(convo.chat("Design a Blog in HTML"))
except Exception as error:
message = error.message
code = error.code
print(f"Error Code {code} \nMessage: \n{error.message}")
(btw I put an API Token from https://beta.openai.com/account/api-keys there)
And my Output is
Error Code ChatgptErrorCodes.UNKNOWN_ERROR
Message:
\n
I dont really get why the Error Message is "\n" and if I run it without the try/except statement, I get following Error.
> Design a a Blog in HTML
Traceback (most recent call last):
File "c:\Users\Collin\OneDrive\Desktop\chatgpt-bot\main.py", line 6, in <module>
print(convo.chat("Design a Blog in HTML"))
File "C:\Users\Collin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\chatgpt\chatgpt.py", line 420, in chat
raise ChatgptError(
chatgpt.errors.ChatgptError: \n
Any help would be appreciated!
HTTPError Traceback (most recent call last)
/usr/local/lib/python3.8/dist-packages/chatgpt/authentication.py in login(self, username, password)
ChatgptError: Login error. Try again or use interceptor.js as explained in the documentation.
Hello.
It seems like you have copied code from https://github.com/rawandahmad698/PyChatGPT/blob/master/src/pychatgpt/classes/openai.py & https://github.com/rawandahmad698/PyChatGPT/blob/master/src/pychatgpt/classes/openai.py#L128
Here Additionally, You have stolen 4-6 days of work on finding the right steps, using the right tools. Without proper licensing/crediting.
to mask this, you also invoke a private function in tls-client here And I'd like to remind you that tls-client is also licensed in MIT.
https://github.com/FlorianREGAZ/Python-Tls-Client/blob/master/LICENSE
https://github.com/rawandahmad698/PyChatGPT/blob/master/LICENSE
PyChatGPT is licensed under MIT, This would mean that you
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
Please also credit the original source. Failing to do so will result in a Takedown Strike
To whom it may concern,
I, Rawand Ahmed Shaswar, am writing to report an instance of copyright infringement. I am the owner and creator of the copyrighted work "PyChatGPT," which is a Python module that allows users to automate the regeneration of access tokens for the ChatGPT service. This work is available on GitHub at [https://github.com/rawandahmad698/PyChatGPT/blob/master/src/pychatgpt/classes/openai.py#L73] and is licensed under the MIT license.
It has come to my attention that my work has been copied and published without attribution by a user on GitHub under the username @labteral. The infringing work, which can be found at [https://github.com/labteral/chatgpt-python/blob/master/chatgpt/chatgpt.py#L42], includes modifications to the original code, such as renamed variables and functions, but the overall structure and methods used in the code remain the same as my original work.
I have made attempts to contact @labteral and resolve this issue, but he has not responded. I am therefore requesting that the infringing work be removed and that @labteral be required to attribute the original work to me and include a copy of the MIT license in any future publications of the code.
I swear, under penalty of perjury, that the information in this notice is accurate and that I am the owner or am authorized to act on behalf of the owner of an exclusive right that is allegedly infringed.
Sincerely,
Rawand Ahmed Shaswar
Date: 1670520017
It takes time to respond and is canceled.
Is it possible to set a timeout?
Got the following error when running the example code:
OSError: /usr/local/lib/python3.10/dist-packages/tls_client/dependencies/tls-client-amd64.so: cannot open shared object file: No such file or directory
Thanks for the update - excited to try streaming.
Neither .stream nor .chat are working for me since the last update though:
conversation.chat(query)
Traceback (most recent call last):
File "", line 1, in
File "/home/runner/replitappname/venv/lib/python3.8/site-packages/chatgpt/chatgpt.py", line 412, in chat
raise ChatgptError(
chatgpt.errors.ChatgptError: \n
`
Traceback (most recent call last):
File "/Users/kevin/project_golang/src/github.com/IPM/python/chatgpt_wrapper/chatgptcli.py", line 11, in
for chunk in conversation.stream("We are going to start a conversation. I will speak English and you will speak Portuguese."):
File "/Users/kevin/opt/anaconda3/envs/naslibenv/lib/python3.7/site-packages/chatgpt/chatgpt.py", line 267, in stream
response = self.chat(message, retry_on_401, True, True)
File "/Users/kevin/opt/anaconda3/envs/naslibenv/lib/python3.7/site-packages/chatgpt/chatgpt.py", line 410, in chat
return self.chat(message, False, direct_response=direct_response, stream=stream)
File "/Users/kevin/opt/anaconda3/envs/naslibenv/lib/python3.7/site-packages/chatgpt/chatgpt.py", line 421, in chat
exception_message, exception_code)
chatgpt.errors.ChatgptError: Login error. Try again or use interceptor.js as explained in the documentation.
`
Hello,
I get the following error "No access token. Please, provide an access_token or email and password through the constructor/config file" when trying to use the module. I am on Windows and have my credentials file here: "D:\Windows\Desktop\pycharm.config\chatgpt". The credentials file is named "config.json". And here is a photo of the env variable with the name "CHATGPT_HOME"
I followed every step in the documentation and also checked if the credentails work and they do, but I still get the error. How can that be?
I think they are removing or changing the endpoint location.
appuser@adab2bb37b36:/workspaces/gottithebot$ python -m chatgpt
> Write a blog about Augmented Reality for a 7 year old
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/chatgpt/chatgpt.py", line 352, in chat
response = self._session.request(
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/chatgpt/sessions.py", line 84, in request
response.raise_for_status()
File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://chat.openai.com/backend-api/conversation
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/usr/local/lib/python3.11/site-packages/chatgpt/__main__.py", line 30, in <module>
main()
File "/usr/local/lib/python3.11/site-packages/chatgpt/__main__.py", line 26, in main
print(conversation.chat(message), end='\n\n')
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/chatgpt/chatgpt.py", line 383, in chat
exception_message = str(reason).split(
^^^^^^^^^^^^^^^^^^
IndexError: list index out of range
% chatgpt
summary 500 words about israel
ERROR: Login error. Try again or use interceptor.js as explained in the documentation.
exit
After installing chatgpt and running it, I get:
OSError: dlopen(/Users/me/anaconda3/lib/python3.9/site-packages/tls_client/dependencies/tls-client-x86.dylib, 6): no suitable image found. Did find:
/Users/me/anaconda3/lib/python3.9/site-packages/tls_client/dependencies/tls-client-x86.dylib: cannot load 'tls-client-x86.dylib' (load command 0x80000034 is unknown)
/Users/me/anaconda3/lib/python3.9/site-packages/tls_client/dependencies/tls-client-x86.dylib: cannot load 'tls-client-x86.dylib' (load command 0x80000034 is unknown)
Is there an additional dependency?
i have this error chatgpt.errors.ChatgptError: Login error. Try again or use interceptor.js as explained in the documentation.
when i run the script
I'm curious about the cause (and potential fix) on the large difference in quality between this tool and the online tool at openai.com. Here's an example dialogue:
User: Could you give me a brief explanation of Michel Foucault's Discipline and Punish?
Bot: Some response
User How does it differ from his earlier works?
Bot (openai.com):
Discipline and Punish is one of Michel Foucault's later works, and it differs from his earlier works in several ways. In his earlier works, such as The History of Madness (1961) and The Order of Things (1966), Foucault focuses on the emergence of modern forms of knowledge and the ways in which these forms of knowledge shape and are shaped by social, political, and cultural forces.
Discipline and Punish, on the other hand, shifts the focus from knowledge to power. In this book, Foucault examines the ways in which power is exercised and enforced in society, and the effects of this power on individuals and social groups. He argues that power is not just a matter of laws and institutions, but is also present in the everyday practices and interactions of individuals.
...
Bot (chatgpt-python):
Michel Foucault's Discipline and Punish is a book that explores the ways in which modern societies use punishment to control and regulate individuals. The book is divided into two parts: the first part examines the historical development of the prison system, while the second part explores the broader implications of this development for modern society.
The latter response seems confused by the user's prompt and fails to provide an answer to the question, something the former succeeds at. This discrepancy is consistent across a variety of prompts.
using python 3.10
my code was
from chatgpt import Conversation
conversation = Conversation()
print(
conversation.chat("Hello!")
)
I got
Traceback (most recent call last):
File "...", line 6, in <module>
conversation.chat("Hello!")
File "C:\Program Files\Python\Python310\lib\site-packages\chatgpt\chatgpt.py", line 83, in chat
error_message = json.loads(payload)['detail']
File "C:\Program Files\Python\Python310\lib\json\__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "C:\Program Files\Python\Python310\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Program Files\Python\Python310\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)
I stored the result of interceptor.js in config.json
correcly before I run the code.
It was
{
"access_token":"...",
"conversation_id":"...",
"parent_message_id":"..."
}
I would suggest to add some controls so that if a user downloads the module with pip don't face to a ModuleNotFoundError
When running:
(venv) PS C:\Users\Nesin\PycharmProjects\chatgpt-python> python -m chatgpt
I get this error:
C:\Users\Nesin\PycharmProjects\chatgpt-python\venv\Scripts\python.exe: No module named chatgpt.main; 'chatgpt' is a package and cannot be directly executed
How can I solve this?
Some countries like China, Hk, They need proxy access to chatgpt
How to use a proxy in chatgpt-python like socks5, http proxy and so on.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.