Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support HTTP via server_chat() #77

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

reycn
Copy link

@reycn reycn commented Dec 9, 2022

Description

In this PR, I add a new function server_chat() within the class Chat to support HTTP interactions:

  • GET and POST supported
  • Async supported
  • Conversations based on HTTP, not yet
  • Special characters management, not yet

Please note that:

  1. the properties and the initialization of class Chat is changed to circumvent router issues introduced by Fastapi decorations;
  2. current version lacks special characters management, so some requests containing unusual characters (e.g. /) might not be properly parsed (will be fixed later).

Augmented requirements:

  • uvicron, to enable server
  • fastapi, to create api

Usage and design

from pychatgpt import Chat

chat = Chat(email="email", password="password")
chat.server_chat() # host:str="127.0.0.1", port:int=8000
Click to toggle HTTP requests and answers >>
  1. GET http://host:port/{prompt} returns a JSONResponse
{
    "answer": "{answer}",
    "conversation": "{conversation_id}"
}
  1. POST http://host:port/ with an application/json body of
{
    "prompt": "{prompt}",
    "conversation": "{conversation_id}" (optional)
}

returns a JSONResponse

{
    "answer": "{answer}",
    "conversation": "{conversation_id}"
}

Note: conversation not implemented yet

@rawandahmad698
Copy link
Owner

I'll wait until it's finished then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants