File size: 535 Bytes
c914190
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import poe
import logging


class Chatbot:
    def __init__(self, token, bot_name: str = "chinchilla"):
        self.bot_name = bot_name
        try:
            poe.logger.setLevel(logging.INFO)
            self.client = poe.Client(token)

        except Exception as e:
            print(e)

    def query_from_api(self, query):
        response = ""
        for chunk in self.client.send_message(self.bot_name, query, with_chat_break=True):
            word = chunk["text_new"]
            response += word

        return response