Skip to content

Add pdf object #64

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

Merged
merged 2 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions tests/integration/run_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
from collections.abc import AsyncIterator

import pytest
from pydantic import BaseModel

import workflowai
Expand Down Expand Up @@ -150,6 +151,8 @@ async def city_to_capital(task_input: CityToCapitalTaskInput) -> CityToCapitalTa


async def test_run_with_tool(test_client: IntTestClient):
"""Test a round trip with a tool call request and a reply."""

class _SayHelloToolInput(BaseModel):
name: str

Expand All @@ -159,6 +162,10 @@ class _SayHelloToolOutput(BaseModel):
def say_hello(tool_input: _SayHelloToolInput) -> _SayHelloToolOutput:
return _SayHelloToolOutput(message=f"Hello {tool_input.name}")

# Sanity check to make sure that CityToCapitalTaskOutput.capital is a field required by pydantic
with pytest.raises(AttributeError):
_ = CityToCapitalTaskOutput.model_construct(None).capital

@workflowai.agent(id="city-to-capital", tools=[say_hello])
async def city_to_capital(task_input: CityToCapitalTaskInput) -> CityToCapitalTaskOutput:
"""Say hello to the user"""
Expand Down
11 changes: 11 additions & 0 deletions workflowai/core/fields/pdf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from workflowai.core.fields.file import File


class PDF(File):
"""A field representing a PDF file.

This field is used to handle PDF inputs.
The PDF can be provided either as base64-encoded data or as a URL.
"""

pass
1 change: 1 addition & 0 deletions workflowai/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from workflowai.core.fields.http_url import HttpUrl as HttpUrl
from workflowai.core.fields.image import Image as Image
from workflowai.core.fields.local_date_time import DatetimeLocal as DatetimeLocal
from workflowai.core.fields.pdf import PDF as PDF
from workflowai.core.fields.price import Price as Price
from workflowai.core.fields.surface_area import SurfaceArea as SurfaceArea
from workflowai.core.fields.zone_info import TimezoneInfo as TimezoneInfo