mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 03:20:46 +02:00
# Description of Changes Have the Java send a list of enabled endpoints to the AI engine so it can intelligently respond to the user that the tool does exist but is disabled on the server so it can't acutally run the operation, instead of the current behaviour where it sends the API call back and then 503 errors because the execution fails when the URL is disabled. <img width="380" height="208" alt="image" src="https://github.com/user-attachments/assets/5842fb2e-2e55-45a5-8205-25515636daae" /> --------- Co-authored-by: EthanHealy01 <[email protected]>
63 lines
1.8 KiB
Python
63 lines
1.8 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Annotated, Literal
|
|
|
|
from pydantic import BeforeValidator, Field
|
|
|
|
from stirling.models import ApiModel, ToolEndpoint
|
|
|
|
from .agent_drafts import AgentDraftResponse
|
|
from .common import (
|
|
AiFile,
|
|
ArtifactKind,
|
|
ConversationMessage,
|
|
ExtractedFileText,
|
|
NeedContentResponse,
|
|
NeedIngestResponse,
|
|
SupportedCapability,
|
|
ToolReportArtifact,
|
|
WorkflowOutcome,
|
|
drop_unknown_tool_endpoints,
|
|
)
|
|
from .execution import NextExecutionAction
|
|
from .pdf_edit import PdfEditTerminalResponse
|
|
from .pdf_questions import PdfQuestionTerminalResponse
|
|
|
|
|
|
class ExtractedTextArtifact(ApiModel):
|
|
kind: Literal[ArtifactKind.EXTRACTED_TEXT] = ArtifactKind.EXTRACTED_TEXT
|
|
files: list[ExtractedFileText] = Field(default_factory=list)
|
|
|
|
|
|
WorkflowArtifact = Annotated[ExtractedTextArtifact | ToolReportArtifact, Field(discriminator="kind")]
|
|
|
|
|
|
class OrchestratorRequest(ApiModel):
|
|
user_message: str
|
|
files: list[AiFile] = Field(default_factory=list)
|
|
conversation_history: list[ConversationMessage] = Field(default_factory=list)
|
|
artifacts: list[WorkflowArtifact] = Field(default_factory=list)
|
|
resume_with: SupportedCapability | None = None
|
|
# See `PdfEditRequest.enabled_endpoints`.
|
|
enabled_endpoints: Annotated[list[ToolEndpoint], BeforeValidator(drop_unknown_tool_endpoints)] = Field(
|
|
default_factory=list
|
|
)
|
|
|
|
|
|
class UnsupportedCapabilityResponse(ApiModel):
|
|
outcome: Literal[WorkflowOutcome.UNSUPPORTED_CAPABILITY] = WorkflowOutcome.UNSUPPORTED_CAPABILITY
|
|
capability: str
|
|
message: str
|
|
|
|
|
|
type OrchestratorResponse = Annotated[
|
|
PdfEditTerminalResponse
|
|
| PdfQuestionTerminalResponse
|
|
| NeedContentResponse
|
|
| NeedIngestResponse
|
|
| AgentDraftResponse
|
|
| NextExecutionAction
|
|
| UnsupportedCapabilityResponse,
|
|
Field(discriminator="outcome"),
|
|
]
|