acheong08 / ChatGPT

Reverse engineered ChatGPT API
GNU General Public License v2.0
28.01k stars 4.48k forks source link

Add recipient.py module for managing message recipients #1361

Closed Yan-Zero closed 1 year ago

Yan-Zero commented 1 year ago

This commit adds a new module, recipient.py, which provides a framework for managing multiple message recipients in a Python application. The module defines two basic classes: 'Recipient' and 'RecipientManager', both of which can be extended to implement custom message recipients. The 'RecipientMeta' metaclass is used to set the default recipient name if it is not provided.

In addition, the 'PythonRecipient' class was added to the recipient.py module, along with the 'RecipientMeta' metaclass. The 'PythonRecipient' class is a custom recipient that allows users to run Python code in a sandboxed environment. the plugin test file (plugin.test.py) was modified to use the new 'Recipient' class.

The typings.py module was also updated to use an enum class for ErrorType, and to fix the 'Colors' class. The 'Colors' class now checks for the presence of the 'NO_COLOR' environment variable and sets its class properties accordingly.

Finally, the version in setup.py was changed to directly use the version attribute in src\revChatGPT__init__.py.

acheong08 commented 1 year ago

Hello, Contributor! We've changed your target branch to dev branch, which is better for maintenance! Please make sure you've read our contributing guide and we look forward to reviewing your Pull request shortly ✨

Yan-Zero commented 1 year ago

Requires dedicated documentation in wiki. A bit confusing

Okay, I finish the whole work now.


        ChatGPT - A command-line interface to OpenAI's ChatGPT (https://chat.openai.com/chat)
        Repo: github.com/acheong08/ChatGPT
        Version: 4.2.6

Type '!help' to show a full list of commands
Press Esc followed by Enter or Alt+Enter to send a message.

You: 
!switch python
Plugin python has been enabled

You: 
Please calculate 8! + 15! - 12! by using python.

Chatbot: 
Sure, here's the Python code to calculate 8! + 15! - 12!:

```python
import math

result = math.factorial(8) + math.factorial(15) - math.factorial(12)
print(result)

When this code is executed, it imports the built-in math module and uses its factorial() function to calculate the factorials of 8, 15, and 12. It then adds the first two factorials and subtracts the third to get the final result, which is printed to the console.

The output of the above code will be:

130943022520

You: !reset Chat session successfully reset. You: Please calculate 8! + 15! - 12! by using python.

Chatbot:

Calculation of 8! + 15! - 12! using Python

def factorial(n): if n == 0: return 1 else: return n * factorial(n-1)

result = factorial(8) + factorial(15) - factorial(12) print(result)

python:

1307195406720

Chatbot: The result of 8! + 15! - 12! is 1307195406720.

You: Wow!

Chatbot: Yes, Python is a powerful language for performing mathematical calculations and it can handle very large numbers with ease. If you have any more questions, feel free to ask!

You: !reset Chat session successfully reset. You: !switch python Plugin python has been disabled

You: Wow! WHO ARE YOU?

Chatbot: Hello! I am ChatGPT, a large language model trained by OpenAI. I am designed to generate human-like responses to a wide variety of prompts and questions, using natural language processing and machine learning algorithms. You can ask me anything you like and I will do my best to provide a helpful and informative answer.

You:

Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x000002482185B190>



The GPT may ignore the plugin sometime, so we need to reset the conversation and try again.
acheong08 commented 1 year ago

Thank you so much