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

Different messages sent concurrently return the same response #74

Closed
victoryhb opened this issue Oct 22, 2023 · 3 comments
Closed

Different messages sent concurrently return the same response #74

victoryhb opened this issue Oct 22, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@victoryhb
Copy link

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
Copy link
Owner

snowby666 commented Oct 22, 2023

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
Copy link
Author

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 snowby666 added the enhancement New feature or request label Jun 20, 2024
@snowby666
Copy link
Owner

This is resolved in v1.5.6

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

No branches or pull requests

2 participants