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
I'm working with the fastapi_poe library to build a bot that includes attachments in the prompt. I need to attach both a URL and a PDF file. However, I'm encountering validation errors. How can I properly structure the Attachment fields to ensure both types are recognized and processed?
Here is a snippet of my current implementation:
import asyncio
import fastapi_poe as fp
async def get_responses(api_key, messages):
async for partial in fp.get_bot_response(messages=messages, bot_name="gpt-3", api_key=api_key):
print(partial.text)
api_key = "YOUR_API_KEY"
message = fp.ProtocolMessage(
role="user",
content="Please create a paragraph based on the provided document.",
attachments=[
fp.Attachment(
url="https://example.com/document",
title="Document",
description="Detailed instructions",
content_type="text/html",
),
fp.Attachment(
url="https://example.com/sample.pdf",
title="Sample PDF",
description="A sample PDF file.",
content_type="application/pdf",
name="sample.pdf"
)
]
)
asyncio.run(get_responses(api_key, [message]))
asyncio.run(get_responses(api_key, [message]))
What modifications are needed to correctly include these attachments? Any help would be greatly appreciated!
The text was updated successfully, but these errors were encountered:
I'm working with the fastapi_poe library to build a bot that includes attachments in the prompt. I need to attach both a URL and a PDF file. However, I'm encountering validation errors. How can I properly structure the Attachment fields to ensure both types are recognized and processed?
Here is a snippet of my current implementation:
import asyncio
import fastapi_poe as fp
async def get_responses(api_key, messages):
async for partial in fp.get_bot_response(messages=messages, bot_name="gpt-3", api_key=api_key):
print(partial.text)
api_key = "YOUR_API_KEY"
message = fp.ProtocolMessage(
role="user",
content="Please create a paragraph based on the provided document.",
attachments=[
fp.Attachment(
url="https://example.com/document",
title="Document",
description="Detailed instructions",
content_type="text/html",
),
fp.Attachment(
url="https://example.com/sample.pdf",
title="Sample PDF",
description="A sample PDF file.",
content_type="application/pdf",
name="sample.pdf"
)
]
)
asyncio.run(get_responses(api_key, [message]))
asyncio.run(get_responses(api_key, [message]))
What modifications are needed to correctly include these attachments? Any help would be greatly appreciated!
The text was updated successfully, but these errors were encountered: