from typing import Annotated
from a2a.types import Message
from agentstack_sdk import server
from agentstack_sdk.a2a.extensions import (
PlatformApiExtensionServer,
PlatformApiExtensionSpec,
EmbeddingServiceExtensionServer,
EmbeddingServiceExtensionSpec,
)
from agentstack_sdk.server.context import RunContext
# Fileformats supported by the text-extraction service (docling)
default_input_modes = [
"text/plain",
"application/pdf",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document", # DOCX
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", # XLSX
"application/vnd.openxmlformats-officedocument.presentationml.presentation", # PPTX
"text/markdown", # Markdown
"text/asciidoc", # AsciiDoc
"text/html", # HTML
"application/xhtml+xml", # XHTML
"text/csv", # CSV
"image/png", # PNG
"image/jpeg", # JPEG
"image/tiff", # TIFF
"image/bmp", # BMP
"image/webp", # WEBP
]
@server.agent(
default_input_modes=default_input_modes, default_output_modes=["text/plain"]
)
async def rag_agent(
input: Message,
context: RunContext,
embedding: Annotated[
EmbeddingServiceExtensionServer, EmbeddingServiceExtensionSpec.single_demand()
],
_: Annotated[PlatformApiExtensionServer, PlatformApiExtensionSpec()],
): ... # Agent code