Skip to content

Commit 6689a9c

Browse files
authored
feat: testing for pdf usage (#420)
## Description <!-- What does this PR do? --> Integration testing for pdf handling. Turns out that only a subset of providers support pdf recognition. We also need to modify the type definition of `annotations` to allow for more permissive content. I opted to not put this into the provider compatibility matrix doc page, since it seemed like a niche feature and would risk cluttering an already busy page. ## PR Type <!-- Delete the types that don't apply --!> 🆕 New Feature ## Relevant issues <!-- e.g. "Fixes #123" --> ## Checklist - [x] I have added unit tests that prove my fix/feature works - [x] New and existing tests pass locally - [x] Documentation was updated where necessary - [x] I have read and followed the [contribution guidelines](https://github.com/mozilla-ai/any-llm/blob/main/CONTRIBUTING.md)```
1 parent c672fe2 commit 6689a9c

File tree

28 files changed

+81
-0
lines changed

28 files changed

+81
-0
lines changed

src/any_llm/provider.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ class Provider(ABC):
114114
SUPPORTS_COMPLETION_IMAGE: bool
115115
"""Image Support for Completion API"""
116116

117+
SUPPORTS_COMPLETION_PDF: bool
118+
"""PDF Support for Completion API"""
119+
117120
SUPPORTS_EMBEDDING: bool
118121
"""OpenAI Embedding API"""
119122

@@ -205,6 +208,7 @@ def get_provider_metadata(cls) -> ProviderMetadata:
205208
reasoning=cls.SUPPORTS_COMPLETION_REASONING,
206209
completion=cls.SUPPORTS_COMPLETION,
207210
image=cls.SUPPORTS_COMPLETION_IMAGE,
211+
pdf=cls.SUPPORTS_COMPLETION_PDF,
208212
embedding=cls.SUPPORTS_EMBEDDING,
209213
responses=cls.SUPPORTS_RESPONSES,
210214
list_models=cls.SUPPORTS_LIST_MODELS,

src/any_llm/providers/anthropic/anthropic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class AnthropicProvider(Provider):
4040
SUPPORTS_RESPONSES = False
4141
SUPPORTS_COMPLETION_REASONING = True
4242
SUPPORTS_COMPLETION_IMAGE = False # Needs https://github.com/mozilla-ai/any-llm/issues/416
43+
SUPPORTS_COMPLETION_PDF = False
4344
SUPPORTS_EMBEDDING = False
4445
SUPPORTS_LIST_MODELS = True
4546

src/any_llm/providers/azure/azure.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class AzureProvider(Provider):
3737
PROVIDER_DOCUMENTATION_URL = "https://azure.microsoft.com/en-us/products/ai-services/openai-service"
3838
SUPPORTS_COMPLETION_STREAMING = True
3939
SUPPORTS_COMPLETION_IMAGE = False
40+
SUPPORTS_COMPLETION_PDF = False
4041
SUPPORTS_EMBEDDING = True
4142
SUPPORTS_COMPLETION_REASONING = False
4243
SUPPORTS_COMPLETION = True

src/any_llm/providers/bedrock/bedrock.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class BedrockProvider(Provider):
4141
SUPPORTS_RESPONSES = False
4242
SUPPORTS_COMPLETION_REASONING = False
4343
SUPPORTS_COMPLETION_IMAGE = False
44+
SUPPORTS_COMPLETION_PDF = False
4445
SUPPORTS_EMBEDDING = True
4546
SUPPORTS_LIST_MODELS = True
4647

src/any_llm/providers/cerebras/cerebras.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class CerebrasProvider(Provider):
3434
SUPPORTS_RESPONSES = False
3535
SUPPORTS_COMPLETION_REASONING = False
3636
SUPPORTS_COMPLETION_IMAGE = False
37+
SUPPORTS_COMPLETION_PDF = False
3738
SUPPORTS_EMBEDDING = False
3839
SUPPORTS_LIST_MODELS = True
3940

src/any_llm/providers/cohere/cohere.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class CohereProvider(Provider):
3434
SUPPORTS_RESPONSES = False
3535
SUPPORTS_COMPLETION_REASONING = False
3636
SUPPORTS_COMPLETION_IMAGE = False
37+
SUPPORTS_COMPLETION_PDF = False
3738
SUPPORTS_EMBEDDING = False
3839
SUPPORTS_LIST_MODELS = True
3940

src/any_llm/providers/deepseek/deepseek.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class DeepseekProvider(BaseOpenAIProvider):
1313
PROVIDER_DOCUMENTATION_URL = "https://platform.deepseek.com/"
1414

1515
SUPPORTS_COMPLETION_IMAGE = False
16+
SUPPORTS_COMPLETION_PDF = False
1617
SUPPORTS_EMBEDDING = False # DeepSeek doesn't host an embedding model
1718

1819
async def acompletion(

src/any_llm/providers/fireworks/fireworks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class FireworksProvider(BaseOpenAIProvider):
1818
SUPPORTS_COMPLETION = True
1919
SUPPORTS_RESPONSES = True
2020
SUPPORTS_COMPLETION_REASONING = False
21+
SUPPORTS_COMPLETION_PDF = False
2122
SUPPORTS_EMBEDDING = False
2223
SUPPORTS_LIST_MODELS = True
2324

src/any_llm/providers/gemini/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class GoogleProvider(Provider):
5252
SUPPORTS_RESPONSES = False
5353
SUPPORTS_COMPLETION_REASONING = True
5454
SUPPORTS_COMPLETION_IMAGE = False # TODO: Add image support https://github.com/mozilla-ai/any-llm/issues/415
55+
SUPPORTS_COMPLETION_PDF = False
5556
SUPPORTS_EMBEDDING = True
5657
SUPPORTS_LIST_MODELS = True
5758

src/any_llm/providers/groq/groq.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class GroqProvider(Provider):
4848
SUPPORTS_RESPONSES = True
4949
SUPPORTS_COMPLETION_REASONING = True
5050
SUPPORTS_COMPLETION_IMAGE = False
51+
SUPPORTS_COMPLETION_PDF = False
5152
SUPPORTS_EMBEDDING = False
5253
SUPPORTS_LIST_MODELS = True
5354

0 commit comments

Comments
 (0)