Comments (6)
Please let me test to make sure the code works before closing the issue though. I've got this code but it's still not working.
def chatbot2_response(query):
max_retries = 20
for attempt in range(1, max_retries + 1):
try:
for chunk in poe_client.send_message("capybara", query, with_chat_break=True):
yield chunk["text_new"]
break
except Exception as e:
logging.warning(f"SendMessageMutation returned an error: {e} | Retrying ({attempt}/{max_retries})")
time.sleep(1) # Add a sleep time to avoid overloading the server
else:
logging.error("SendMessageMutation failed after maximum retries")
@app.route("/chatbot2", methods=['GET', 'POST'])
def chatbot2():
chatbot_2_question = flask.request.form.get('question')
return Response(stream_with_context(chatbot2_response(chatbot_2_question)), mimetype='text/plain')
Output is just:
WARNING:root:SendMessageMutation returned an error: Server Error | Retrying (1/20)
WARNING:root:SendMessageMutation returned an error: Server Error | Retrying (2/20)
WARNING:root:SendMessageMutation returned an error: Server Error | Retrying (3/20)
and the page wont load
from poe-api.
If I put it inside like this it does not work either.
@app.route("/chatbot2", methods=['GET', 'POST'])
def chatbot2():
chatbot_2_question = flask.request.form.get('question')
def chatbot2_response(query):
max_retries = 20
for attempt in range(1, max_retries + 1):
try:
for chunk in poe_client.send_message("capybara", query, with_chat_break=True):
yield chunk["text_new"]
break
except Exception as e:
logging.warning(f"SendMessageMutation returned an error: {e} | Retrying ({attempt}/{max_retries})")
time.sleep(1)
else:
logging.error("SendMessageMutation failed after maximum retries")
return Response(stream_with_context(chatbot2_response(chatbot_2_question)), mimetype='text/plain')
from poe-api.
I apologize if my question seemed invalid I am just looking to get some help.
from poe-api.
I've gotten this library to work with Flask just fine. client.send_message
is just a normal python generator, so you'd just create a wrapper around it and return that.
Something like this should work (untested though):
@app.route("/send")
def send_message():
prompt = request.query.get("prompt")
def generator():
for chunk in client.send_message("capybara", prompt):
yield json.dumps(chunk)+"\n"
return Response(generator(), content_type="text/event-stream")
from poe-api.
Nope :(
WARNING:root:SendMessageMutation returned an error: Server Error | Retrying (1/20)
WARNING:root:SendMessageMutation returned an error: Server Error | Retrying (2/20)
WARNING:root:SendMessageMutation returned an error: Server Error | Retrying (3/20)
def chatbot2():
chatbot_2_question = flask.request.form.get('question')
def generator():
for chunk in poe_client.send_message("capybara", chatbot_2_question):
yield json.dumps(chunk)+"\n"
return Response(generator(), content_type="text/event-stream")`````
from poe-api.
Nope :(
Your issue is not poe-api related, but python/flask.
from poe-api.
Related Issues (20)
- SendMessageMutation returned an error: Server Error | Retrying (1/20) | Response: {'data': None, 'errors': [{'message': 'Server Error'}], 'extensions': {'is_final': True, 'enable_i18n': True}} HOT 1
- chunk['text'] gets incomplete anwser HOT 3
- 使用接口调用GPT4,回复的是GPT3.5的结果,而且没有扣除GPT4的次数 HOT 3
- Server returned a status code of 403 while downloading https://poe. com HOT 59
- ReferenceError: 'document' is not defined HOT 1
- it raises runtime error again (RuntimeError(f"Failed to download {url} too many times.")) HOT 1
- Add a feature to upload documents HOT 1
- No module named 'poe' HOT 2
- Failed building wheel for quickjs HOT 9
- RuntimeError: Failed to download https://poe.com too many times. HOT 3
- hard to get chatId HOT 4
- Client cannot be created due to 'data' KeyError HOT 4
- Can not create poe client instance HOT 1
- Seems Poe is blocking to access poe token HOT 1
- Server returned a status code of 400 while downloading https://poe.com/api/gql_POST HOT 8
- Maintainers Needed HOT 12
- Server returned a status code of 403 while downloading bot list HOT 2
- 最新AI集成软件-AI超元域,支持多款AI同时回答
- AI超元域,免费开源多AI协作应用
- Can't find p-b cookie value HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from poe-api.