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

How to Include a URL and PDF as Attachments in a Protocol Message with fastapi_poe? #113

Closed
Skrut86 opened this issue Jul 11, 2024 · 1 comment

Comments

@Skrut86
Copy link

Skrut86 commented Jul 11, 2024

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!

@JohntheLi
Copy link
Collaborator

Refer to #89, the API currently doesn't support arbitrary attachments, and the attachments should be uploaded through the user interface. See https://creator.poe.com/docs/server-bots-functional-guides#enabling-file-upload-for-your-bot for details on enabling file uploads for your bot.

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

No branches or pull requests

2 participants