import os
from datagrid_ai import Datagrid
client = Datagrid(api_key=os.environ.get("DATAGRID_API_KEY"))
# Step 1: Upload a file
with open("report.pdf", "rb") as file:
uploaded_file = client.files.create(file=file)
# Step 2: Include the file in a conversation
response = client.converse(
prompt=[
{
"role": "user",
"content": [
{"type": "input_text", "text": "Summarize this document"},
{"type": "input_file", "file_id": uploaded_file.id}
]
}
]
)
print(response.content[0].text)