You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. I'm trying to understand how attachments are processed in a server bot. From your tutorial and examples, I got the impression that I can manipulate all inputs going to Poe models and responses shown. However, it seems that I have no control of attachments and how they are parsed and sent to LLMs for processing. See example code below.
Code below runs fine and bot identifies as "Alice". However, I assumed that by setting all "parsed_content" of attachments to "dummy text!" the bot will be unable to see and process my attached PDFs. However, this exercise has no effect at all. The bot can still read attached PDFs without any problems, which means I cannot control how Poe parses attachement and what is sent to LLMs. I hope it is not so.
from __future__ import annotations
from typing import AsyncIterable
import fastapi_poe as fp
import uvicorn
MODEL = "GPT-4o-mini"
SYSTEM_PROMPT = "You are document summarizer bot called Alice. You analyze given documents by users and help them any way you can."
class PromptBot(fp.PoeBot):
async def get_response(
self, request: fp.QueryRequest
) -> AsyncIterable[fp.PartialResponse]:
system_message = fp.ProtocolMessage(role="system", content=SYSTEM_PROMPT)
user_message = request.query
# nullify any attached text content
for i in range(len(user_message)):
for j in range(len(user_message[i].attachments)):
try:
user_message[i].attachments[j].parsed_content = "dummy text!"
except:
break
# send system message and tampered user_message
request.query = [system_message] + user_message
async for msg in fp.stream_request(request,MODEL,request.access_key):
yield msg
async def get_settings(self, setting: fp.SettingsRequest) -> fp.SettingsResponse:
return fp.SettingsResponse(allow_attachments=True, allow_user_context_clear=True,server_bot_dependencies={MODEL: 1},expand_text_attachments=False) # "Claude-3.5-Sonnet": 1 enable_multi_bot_chat_prompting=True
app = fp.make_app(PromptBot(),allow_without_key=True)
if __name__ == '__main__':
uvicorn.run(app, host='0.0.0.0', port=8000)
Can you elaborate this aspect and maybe explain how to correctly override default document parsing made internally by Poe? Thanks.
The text was updated successfully, but these errors were encountered:
Hi. I'm trying to understand how attachments are processed in a server bot. From your tutorial and examples, I got the impression that I can manipulate all inputs going to Poe models and responses shown. However, it seems that I have no control of attachments and how they are parsed and sent to LLMs for processing. See example code below.
Code below runs fine and bot identifies as "Alice". However, I assumed that by setting all "parsed_content" of attachments to "dummy text!" the bot will be unable to see and process my attached PDFs. However, this exercise has no effect at all. The bot can still read attached PDFs without any problems, which means I cannot control how Poe parses attachement and what is sent to LLMs. I hope it is not so.
Can you elaborate this aspect and maybe explain how to correctly override default document parsing made internally by Poe? Thanks.
The text was updated successfully, but these errors were encountered: