snowby666 / poe-api-wrapper

👾 A Python API wrapper for Poe.com. With this, you will have free access to GPT-4, Claude, Llama, Gemini, Mistral and more! 🚀
https://pypi.org/project/poe-api-wrapper/
GNU General Public License v3.0
858 stars 99 forks source link

Different messages sent concurrently return the same response #74

Closed victoryhb closed 3 months ago

victoryhb commented 11 months ago

Hi, thanks for the awesome library. When testing concurrent connections with the following code (adapted from your example code), I keep getting the same responses from Poe, even when the messages and bots are different.

client1 = PoeApi(token)
client2 = PoeApi(token)

def t1_send():
    for chunk in client1.send_message('a2', 'Nice to meet you'):
        pass
    print(chunk['text'])

def t2_send():
    for chunk in client2.send_message('chinchilla', 'What day is it today?'):
        pass
    print(chunk['text'])

t1 = threading.Thread(target=t1_send)
t2 = threading.Thread(target=t2_send)

t1.start()
t2.start()

t1.join()
t2.join()

The above code would, for example, print "Today is October 22, 2023." twice. I wonder if this is a problem with the library or is the way Poe works?

snowby666 commented 11 months ago

Hi, Can you try this new example?

client = PoeApi(token)

def t1_send():
    for chunk in client.send_message('a2', 'Nice to meet you. Write a 300 word essay about the moon'):
        print(chunk['response'], end='', flush=True)

def t2_send():
    for chunk in client.send_message('chinchilla', 'What day is it today? Write a 300 word essay about the sun'):
        print(chunk['response'], end='', flush=True)
t1 = threading.Thread(target=t1_send)
t2 = threading.Thread(target=t2_send)

t1.start()
t2.start()

t1.join()
t2.join()
victoryhb commented 11 months ago

Thanks for the new example. The code returns the correct responses, but the problem is that it does so sequentially, equivalent to sending the messages one by one, without the speed gains of threading (that's why I ask the question in the first place).

snowby666 commented 3 months ago

This is resolved in v1.5.6