Skip to content
This repository has been archived by the owner on Aug 10, 2023. It is now read-only.

Commit

Permalink
Update docs for devs
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Cheong authored Dec 5, 2022
1 parent 6cbb383 commit c019c66
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,16 @@ config = {
chatbot = Chatbot(config, conversation_id=None)
chatbot.reset_chat() # Forgets conversation
chatbot.refresh_session() # Uses the session_token to get a new bearer token
resp = chatbot.get_chat_response(prompt) # Sends a request to the API and returns the response by OpenAI
resp = chatbot.get_chat_response(prompt, output="text") # Sends a request to the API and returns the response by OpenAI
resp['message'] # The message sent by the response
resp['conversation_id'] # The current conversation id
resp['parent_id'] # The ID of the response

response = requests.post("https://chat.openai.com/backend-api/conversation", headers=self.headers, data=json.dumps(data), stream=True) # This returns a stream of text (live update)

for message in response: # You have to loop through the response stream
print(line['message']) # Same format as text return type
...
```
This can be imported to projects for bots and much more. You can have multiple independent conversations by keeping track of the conversation_id.

Expand Down

0 comments on commit c019c66

Please sign in to comment.