diff --git a/agents-api/agents_api/autogen/Agents.py b/agents-api/agents_api/autogen/Agents.py index a20dd5392..157ceb064 100644 --- a/agents-api/agents_api/autogen/Agents.py +++ b/agents-api/agents_api/autogen/Agents.py @@ -13,7 +13,6 @@ class Agent(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) id: Annotated[UUID, Field(json_schema_extra={"readOnly": True})] @@ -30,6 +29,7 @@ class Agent(BaseModel): str, Field( "", + max_length=120, pattern="^[\\p{L}\\p{Nl}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]+[\\p{ID_Start}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]*$", ), ] @@ -60,7 +60,6 @@ class CreateAgentRequest(BaseModel): """ model_config = ConfigDict( - extra="allow", populate_by_name=True, ) metadata: dict[str, Any] | None = None @@ -68,6 +67,7 @@ class CreateAgentRequest(BaseModel): str, Field( "", + max_length=120, pattern="^[\\p{L}\\p{Nl}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]+[\\p{ID_Start}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]*$", ), ] @@ -94,7 +94,6 @@ class CreateAgentRequest(BaseModel): class CreateOrUpdateAgentRequest(CreateAgentRequest): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) id: UUID @@ -103,6 +102,7 @@ class CreateOrUpdateAgentRequest(CreateAgentRequest): str, Field( "", + max_length=120, pattern="^[\\p{L}\\p{Nl}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]+[\\p{ID_Start}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]*$", ), ] @@ -133,7 +133,6 @@ class PatchAgentRequest(BaseModel): """ model_config = ConfigDict( - extra="allow", populate_by_name=True, ) metadata: dict[str, Any] | None = None @@ -141,6 +140,7 @@ class PatchAgentRequest(BaseModel): str, Field( "", + max_length=120, pattern="^[\\p{L}\\p{Nl}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]+[\\p{ID_Start}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]*$", ), ] @@ -171,7 +171,6 @@ class UpdateAgentRequest(BaseModel): """ model_config = ConfigDict( - extra="allow", populate_by_name=True, ) metadata: dict[str, Any] | None = None @@ -179,6 +178,7 @@ class UpdateAgentRequest(BaseModel): str, Field( "", + max_length=120, pattern="^[\\p{L}\\p{Nl}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]+[\\p{ID_Start}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]*$", ), ] diff --git a/agents-api/agents_api/autogen/Chat.py b/agents-api/agents_api/autogen/Chat.py index 19c9fb05e..5aa4d6d29 100644 --- a/agents-api/agents_api/autogen/Chat.py +++ b/agents-api/agents_api/autogen/Chat.py @@ -10,13 +10,12 @@ from .Common import LogitBias from .Docs import DocReference -from .Entries import InputChatMLMessage +from .Entries import ChatMLImageContentPart from .Tools import FunctionTool, NamedToolChoice class BaseChatOutput(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) index: int @@ -32,7 +31,6 @@ class BaseChatOutput(BaseModel): class BaseChatResponse(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) usage: CompetionUsage | None = None @@ -56,7 +54,6 @@ class BaseChatResponse(BaseModel): class BaseTokenLogProb(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) token: str @@ -69,10 +66,9 @@ class BaseTokenLogProb(BaseModel): class ChatInputData(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) - messages: Annotated[list[InputChatMLMessage], Field(min_length=1)] + messages: Annotated[list[Message], Field(min_length=1)] """ A list of new input messages comprising the conversation so far. """ @@ -92,10 +88,9 @@ class ChatOutputChunk(BaseChatOutput): """ model_config = ConfigDict( - extra="allow", populate_by_name=True, ) - delta: InputChatMLMessage + delta: Delta """ The message generated by the model """ @@ -103,7 +98,6 @@ class ChatOutputChunk(BaseChatOutput): class ChunkChatResponse(BaseChatResponse): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) choices: list[ChatOutputChunk] @@ -118,7 +112,6 @@ class CompetionUsage(BaseModel): """ model_config = ConfigDict( - extra="allow", populate_by_name=True, ) completion_tokens: Annotated[ @@ -143,7 +136,6 @@ class CompetionUsage(BaseModel): class CompletionResponseFormat(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) type: Literal["text", "json_object"] = "text" @@ -152,9 +144,53 @@ class CompletionResponseFormat(BaseModel): """ +class Content(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + text: str + type: Literal["text"] = "text" + """ + The type (fixed to 'text') + """ + + +class Delta(BaseModel): + """ + The message generated by the model + """ + + model_config = ConfigDict( + populate_by_name=True, + ) + role: Literal[ + "user", + "assistant", + "system", + "function", + "function_response", + "function_call", + "auto", + ] + """ + The role of the message + """ + content: str | list[str] | list[Content | ChatMLImageContentPart] + """ + The content parts of the message + """ + name: str | None = None + """ + Name + """ + continue_: Annotated[StrictBool | None, Field(None, alias="continue")] + """ + Whether to continue this message or return a new one + """ + + class LogProbResponse(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) content: Annotated[list[TokenLogProb] | None, Field(...)] @@ -163,9 +199,38 @@ class LogProbResponse(BaseModel): """ +class Message(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + role: Literal[ + "user", + "assistant", + "system", + "function", + "function_response", + "function_call", + "auto", + ] + """ + The role of the message + """ + content: str | list[str] | list[Content | ChatMLImageContentPart] + """ + The content parts of the message + """ + name: str | None = None + """ + Name + """ + continue_: Annotated[StrictBool | None, Field(None, alias="continue")] + """ + Whether to continue this message or return a new one + """ + + class MessageChatResponse(BaseChatResponse): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) choices: list[SingleChatOutput | MultipleChatOutput] @@ -180,15 +245,13 @@ class MultipleChatOutput(BaseChatOutput): """ model_config = ConfigDict( - extra="allow", populate_by_name=True, ) - messages: list[InputChatMLMessage] + messages: list[Message] class OpenAISettings(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) frequency_penalty: Annotated[float | None, Field(None, ge=-2.0, le=2.0)] @@ -215,15 +278,13 @@ class SingleChatOutput(BaseChatOutput): """ model_config = ConfigDict( - extra="allow", populate_by_name=True, ) - message: InputChatMLMessage + message: Message class TokenLogProb(BaseTokenLogProb): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) top_logprobs: list[BaseTokenLogProb] @@ -231,7 +292,6 @@ class TokenLogProb(BaseTokenLogProb): class ChatInput(ChatInputData): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) remember: Annotated[StrictBool, Field(False, json_schema_extra={"readOnly": True})] @@ -250,6 +310,7 @@ class ChatInput(ChatInputData): str | None, Field( None, + max_length=120, pattern="^[\\p{L}\\p{Nl}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]+[\\p{ID_Start}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]*$", ), ] @@ -320,7 +381,6 @@ class DefaultChatSettings(OpenAISettings): """ model_config = ConfigDict( - extra="allow", populate_by_name=True, ) repetition_penalty: Annotated[float | None, Field(None, ge=0.0, le=2.0)] @@ -339,13 +399,13 @@ class DefaultChatSettings(OpenAISettings): class ChatSettings(DefaultChatSettings): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) model: Annotated[ str | None, Field( None, + max_length=120, pattern="^[\\p{L}\\p{Nl}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]+[\\p{ID_Start}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]*$", ), ] diff --git a/agents-api/agents_api/autogen/Common.py b/agents-api/agents_api/autogen/Common.py index 7dedd743e..aab88621d 100644 --- a/agents-api/agents_api/autogen/Common.py +++ b/agents-api/agents_api/autogen/Common.py @@ -38,7 +38,6 @@ class Offset(RootModel[int]): class ResourceCreatedResponse(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) id: UUID @@ -57,7 +56,6 @@ class ResourceCreatedResponse(BaseModel): class ResourceDeletedResponse(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) id: UUID @@ -76,7 +74,6 @@ class ResourceDeletedResponse(BaseModel): class ResourceUpdatedResponse(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) id: UUID diff --git a/agents-api/agents_api/autogen/Docs.py b/agents-api/agents_api/autogen/Docs.py index 3039fc3f4..a7023ddfc 100644 --- a/agents-api/agents_api/autogen/Docs.py +++ b/agents-api/agents_api/autogen/Docs.py @@ -11,7 +11,6 @@ class BaseDocSearchRequest(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) limit: Annotated[int, Field(10, ge=1, le=100)] @@ -27,16 +26,10 @@ class CreateDocRequest(BaseModel): """ model_config = ConfigDict( - extra="allow", populate_by_name=True, ) metadata: dict[str, Any] | None = None - title: Annotated[ - str, - Field( - pattern="^[\\p{L}\\p{Nl}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]+[\\p{ID_Start}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]*$" - ), - ] + title: Annotated[str, Field(max_length=800)] """ Title describing what this document contains """ @@ -48,7 +41,6 @@ class CreateDocRequest(BaseModel): class Doc(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) id: Annotated[UUID, Field(json_schema_extra={"readOnly": True})] @@ -57,12 +49,7 @@ class Doc(BaseModel): """ When this resource was created as UTC date-time """ - title: Annotated[ - str, - Field( - pattern="^[\\p{L}\\p{Nl}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]+[\\p{ID_Start}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]*$" - ), - ] + title: Annotated[str, Field(max_length=800)] """ Title describing what this document contains """ @@ -74,7 +61,6 @@ class Doc(BaseModel): class DocOwner(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) id: UUID @@ -83,7 +69,6 @@ class DocOwner(BaseModel): class DocReference(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) owner: DocOwner @@ -101,7 +86,6 @@ class DocReference(BaseModel): class DocSearchResponse(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) docs: list[DocReference] @@ -116,7 +100,6 @@ class DocSearchResponse(BaseModel): class EmbedQueryRequest(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) text: str | list[str] @@ -127,7 +110,6 @@ class EmbedQueryRequest(BaseModel): class EmbedQueryResponse(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) vectors: list[list[float]] @@ -138,7 +120,6 @@ class EmbedQueryResponse(BaseModel): class HybridDocSearchRequest(BaseDocSearchRequest): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) confidence: Annotated[float, Field(0.5, ge=0.0, le=1.0)] @@ -161,7 +142,6 @@ class HybridDocSearchRequest(BaseDocSearchRequest): class Snippet(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) index: int @@ -170,7 +150,6 @@ class Snippet(BaseModel): class TextOnlyDocSearchRequest(BaseDocSearchRequest): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) text: str @@ -181,7 +160,6 @@ class TextOnlyDocSearchRequest(BaseDocSearchRequest): class VectorDocSearchRequest(BaseDocSearchRequest): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) confidence: Annotated[float, Field(0.5, ge=0.0, le=1.0)] diff --git a/agents-api/agents_api/autogen/Entries.py b/agents-api/agents_api/autogen/Entries.py index dc64872a1..753436702 100644 --- a/agents-api/agents_api/autogen/Entries.py +++ b/agents-api/agents_api/autogen/Entries.py @@ -6,21 +6,13 @@ from typing import Annotated, Literal from uuid import UUID -from pydantic import ( - AnyUrl, - AwareDatetime, - BaseModel, - ConfigDict, - Field, - StrictBool, -) +from pydantic import AnyUrl, AwareDatetime, BaseModel, ConfigDict, Field, RootModel from .Tools import ChosenToolCall, Tool, ToolResponse class BaseEntry(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) role: Literal[ @@ -37,13 +29,13 @@ class BaseEntry(BaseModel): """ name: str | None = None content: ( - list[ChatMLTextContentPart | ChatMLImageContentPart] + list[Content | ChatMLImageContentPart] | Tool | ChosenToolCall | str | ToolResponse | list[ - list[ChatMLTextContentPart | ChatMLImageContentPart] + list[Content | ChatMLImageContentPart] | Tool | ChosenToolCall | str @@ -63,7 +55,6 @@ class BaseEntry(BaseModel): class ChatMLImageContentPart(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) image_url: ImageURL @@ -76,9 +67,38 @@ class ChatMLImageContentPart(BaseModel): """ -class ChatMLTextContentPart(BaseModel): +class ChatMLRole( + RootModel[ + Literal[ + "user", + "assistant", + "system", + "function", + "function_response", + "function_call", + "auto", + ] + ] +): + model_config = ConfigDict( + populate_by_name=True, + ) + root: Literal[ + "user", + "assistant", + "system", + "function", + "function_response", + "function_call", + "auto", + ] + """ + ChatML role (system|assistant|user|function_call|function|function_response|auto) + """ + + +class Content(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) text: str @@ -90,7 +110,6 @@ class ChatMLTextContentPart(BaseModel): class Entry(BaseEntry): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) created_at: Annotated[AwareDatetime, Field(json_schema_extra={"readOnly": True})] @@ -102,7 +121,6 @@ class Entry(BaseEntry): class History(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) entries: list[Entry] @@ -116,7 +134,6 @@ class History(BaseModel): class ImageURL(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) url: AnyUrl @@ -129,40 +146,8 @@ class ImageURL(BaseModel): """ -class InputChatMLMessage(BaseModel): - model_config = ConfigDict( - extra="allow", - populate_by_name=True, - ) - role: Literal[ - "user", - "assistant", - "system", - "function", - "function_response", - "function_call", - "auto", - ] - """ - The role of the message - """ - content: str | list[str] | list[ChatMLTextContentPart | ChatMLImageContentPart] - """ - The content parts of the message - """ - name: str | None = None - """ - Name - """ - continue_: Annotated[StrictBool | None, Field(None, alias="continue")] - """ - Whether to continue this message or return a new one - """ - - class Relation(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) head: UUID diff --git a/agents-api/agents_api/autogen/Executions.py b/agents-api/agents_api/autogen/Executions.py index 97046d7d9..904680e44 100644 --- a/agents-api/agents_api/autogen/Executions.py +++ b/agents-api/agents_api/autogen/Executions.py @@ -15,7 +15,6 @@ class CreateExecutionRequest(BaseModel): """ model_config = ConfigDict( - extra="allow", populate_by_name=True, ) input: dict[str, Any] @@ -27,7 +26,6 @@ class CreateExecutionRequest(BaseModel): class Execution(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) task_id: Annotated[UUID, Field(json_schema_extra={"readOnly": True})] @@ -67,7 +65,6 @@ class Execution(BaseModel): class TaskTokenResumeExecutionRequest(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) status: Literal["running"] = "running" @@ -79,7 +76,6 @@ class TaskTokenResumeExecutionRequest(BaseModel): class Transition(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) type: Annotated[ @@ -106,13 +102,13 @@ class Transition(BaseModel): class TransitionTarget(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) workflow: Annotated[ str, Field( - pattern="^[\\p{L}\\p{Nl}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]+[\\p{ID_Start}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]*$" + max_length=120, + pattern="^[\\p{L}\\p{Nl}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]+[\\p{ID_Start}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]*$", ), ] """ @@ -125,7 +121,6 @@ class TransitionTarget(BaseModel): class UpdateExecutionRequest(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) status: Literal[ @@ -141,7 +136,6 @@ class UpdateExecutionRequest(BaseModel): class ResumeExecutionRequest(UpdateExecutionRequest): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) status: Literal["running"] = "running" @@ -153,7 +147,6 @@ class ResumeExecutionRequest(UpdateExecutionRequest): class StopExecutionRequest(UpdateExecutionRequest): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) status: Literal["cancelled"] = "cancelled" diff --git a/agents-api/agents_api/autogen/Jobs.py b/agents-api/agents_api/autogen/Jobs.py index a3402d04d..568b7a09c 100644 --- a/agents-api/agents_api/autogen/Jobs.py +++ b/agents-api/agents_api/autogen/Jobs.py @@ -11,7 +11,6 @@ class JobStatus(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) id: Annotated[UUID, Field(json_schema_extra={"readOnly": True})] @@ -27,6 +26,7 @@ class JobStatus(BaseModel): str, Field( "", + max_length=120, pattern="^[\\p{L}\\p{Nl}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]+[\\p{ID_Start}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]*$", ), ] diff --git a/agents-api/agents_api/autogen/Sessions.py b/agents-api/agents_api/autogen/Sessions.py index caf47c278..4380dac02 100644 --- a/agents-api/agents_api/autogen/Sessions.py +++ b/agents-api/agents_api/autogen/Sessions.py @@ -15,7 +15,6 @@ class CreateSessionRequest(BaseModel): """ model_config = ConfigDict( - extra="allow", populate_by_name=True, ) user: UUID | None = None @@ -53,7 +52,6 @@ class PatchSessionRequest(BaseModel): """ model_config = ConfigDict( - extra="allow", populate_by_name=True, ) situation: str = '{%- if agent.name -%}\nYou are {{agent.name}}.{{" "}}\n{%- endif -%}\n\n{%- if agent.about -%}\nAbout you: {{agent.name}}.{{" "}}\n{%- endif -%}\n\n{%- if user -%}\nYou are talking to a user\n {%- if user.name -%}{{" "}} and their name is {{user.name}}\n {%- if user.about -%}. About the user: {{user.about}}.{%- else -%}.{%- endif -%}\n {%- endif -%}\n{%- endif -%}\n\n{{"\n\n"}}\n\n{%- if agent.instructions -%}\nInstructions:{{"\n"}}\n {%- if agent.instructions is string -%}\n {{agent.instructions}}{{"\n"}}\n {%- else -%}\n {%- for instruction in agent.instructions -%}\n - {{instruction}}{{"\n"}}\n {%- endfor -%}\n {%- endif -%}\n {{"\n"}}\n{%- endif -%}\n\n{%- if tools -%}\nTools:{{"\n"}}\n {%- for tool in tools -%}\n {%- if tool.type == "function" -%}\n - {{tool.function.name}}\n {%- if tool.function.description -%}: {{tool.function.description}}{%- endif -%}{{"\n"}}\n {%- else -%}\n - {{ 0/0 }} {# Error: Other tool types aren\'t supported yet. #}\n {%- endif -%}\n {%- endfor -%}\n{{"\n\n"}}\n{%- endif -%}\n\n{%- if docs -%}\nRelevant documents:{{"\n"}}\n {%- for doc in docs -%}\n {{doc.title}}{{"\n"}}\n {%- if doc.content is string -%}\n {{doc.content}}{{"\n"}}\n {%- else -%}\n {%- for snippet in doc.content -%}\n {{snippet}}{{"\n"}}\n {%- endfor -%}\n {%- endif -%}\n {{"---"}}\n {%- endfor -%}\n{%- endif -%}' @@ -77,7 +75,6 @@ class PatchSessionRequest(BaseModel): class Session(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) situation: str = '{%- if agent.name -%}\nYou are {{agent.name}}.{{" "}}\n{%- endif -%}\n\n{%- if agent.about -%}\nAbout you: {{agent.name}}.{{" "}}\n{%- endif -%}\n\n{%- if user -%}\nYou are talking to a user\n {%- if user.name -%}{{" "}} and their name is {{user.name}}\n {%- if user.about -%}. About the user: {{user.about}}.{%- else -%}.{%- endif -%}\n {%- endif -%}\n{%- endif -%}\n\n{{"\n\n"}}\n\n{%- if agent.instructions -%}\nInstructions:{{"\n"}}\n {%- if agent.instructions is string -%}\n {{agent.instructions}}{{"\n"}}\n {%- else -%}\n {%- for instruction in agent.instructions -%}\n - {{instruction}}{{"\n"}}\n {%- endfor -%}\n {%- endif -%}\n {{"\n"}}\n{%- endif -%}\n\n{%- if tools -%}\nTools:{{"\n"}}\n {%- for tool in tools -%}\n {%- if tool.type == "function" -%}\n - {{tool.function.name}}\n {%- if tool.function.description -%}: {{tool.function.description}}{%- endif -%}{{"\n"}}\n {%- else -%}\n - {{ 0/0 }} {# Error: Other tool types aren\'t supported yet. #}\n {%- endif -%}\n {%- endfor -%}\n{{"\n\n"}}\n{%- endif -%}\n\n{%- if docs -%}\nRelevant documents:{{"\n"}}\n {%- for doc in docs -%}\n {{doc.title}}{{"\n"}}\n {%- if doc.content is string -%}\n {{doc.content}}{{"\n"}}\n {%- else -%}\n {%- for snippet in doc.content -%}\n {{snippet}}{{"\n"}}\n {%- endfor -%}\n {%- endif -%}\n {{"---"}}\n {%- endfor -%}\n{%- endif -%}' @@ -118,7 +115,6 @@ class Session(BaseModel): class SingleAgentMultiUserSession(Session): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) agent: UUID @@ -127,7 +123,6 @@ class SingleAgentMultiUserSession(Session): class SingleAgentNoUserSession(Session): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) agent: UUID @@ -135,7 +130,6 @@ class SingleAgentNoUserSession(Session): class SingleAgentSingleUserSession(Session): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) agent: UUID @@ -148,7 +142,6 @@ class UpdateSessionRequest(BaseModel): """ model_config = ConfigDict( - extra="allow", populate_by_name=True, ) situation: str = '{%- if agent.name -%}\nYou are {{agent.name}}.{{" "}}\n{%- endif -%}\n\n{%- if agent.about -%}\nAbout you: {{agent.name}}.{{" "}}\n{%- endif -%}\n\n{%- if user -%}\nYou are talking to a user\n {%- if user.name -%}{{" "}} and their name is {{user.name}}\n {%- if user.about -%}. About the user: {{user.about}}.{%- else -%}.{%- endif -%}\n {%- endif -%}\n{%- endif -%}\n\n{{"\n\n"}}\n\n{%- if agent.instructions -%}\nInstructions:{{"\n"}}\n {%- if agent.instructions is string -%}\n {{agent.instructions}}{{"\n"}}\n {%- else -%}\n {%- for instruction in agent.instructions -%}\n - {{instruction}}{{"\n"}}\n {%- endfor -%}\n {%- endif -%}\n {{"\n"}}\n{%- endif -%}\n\n{%- if tools -%}\nTools:{{"\n"}}\n {%- for tool in tools -%}\n {%- if tool.type == "function" -%}\n - {{tool.function.name}}\n {%- if tool.function.description -%}: {{tool.function.description}}{%- endif -%}{{"\n"}}\n {%- else -%}\n - {{ 0/0 }} {# Error: Other tool types aren\'t supported yet. #}\n {%- endif -%}\n {%- endfor -%}\n{{"\n\n"}}\n{%- endif -%}\n\n{%- if docs -%}\nRelevant documents:{{"\n"}}\n {%- for doc in docs -%}\n {{doc.title}}{{"\n"}}\n {%- if doc.content is string -%}\n {{doc.content}}{{"\n"}}\n {%- else -%}\n {%- for snippet in doc.content -%}\n {{snippet}}{{"\n"}}\n {%- endfor -%}\n {%- endif -%}\n {{"---"}}\n {%- endfor -%}\n{%- endif -%}' @@ -172,7 +165,6 @@ class UpdateSessionRequest(BaseModel): class CreateOrUpdateSessionRequest(CreateSessionRequest): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) id: UUID @@ -207,7 +199,6 @@ class CreateOrUpdateSessionRequest(CreateSessionRequest): class MultiAgentMultiUserSession(Session): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) agents: list[UUID] @@ -216,7 +207,6 @@ class MultiAgentMultiUserSession(Session): class MultiAgentNoUserSession(Session): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) agents: list[UUID] @@ -224,7 +214,6 @@ class MultiAgentNoUserSession(Session): class MultiAgentSingleUserSession(Session): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) agents: list[UUID] diff --git a/agents-api/agents_api/autogen/Tasks.py b/agents-api/agents_api/autogen/Tasks.py index b3059cc12..5c5050447 100644 --- a/agents-api/agents_api/autogen/Tasks.py +++ b/agents-api/agents_api/autogen/Tasks.py @@ -15,13 +15,12 @@ TextOnlyDocSearchRequest, VectorDocSearchRequest, ) -from .Entries import InputChatMLMessage +from .Entries import ChatMLImageContentPart from .Tools import CreateToolRequest class BaseWorkflowStep(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) kind_: Literal[ @@ -51,10 +50,9 @@ class BaseWorkflowStep(BaseModel): class CaseThen(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) - case: str + case: Literal["_"] | str """ The condition to evaluate """ @@ -78,13 +76,26 @@ class CaseThen(BaseModel): """ +class Content(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + text: str + """ + A valid jinja template. + """ + type: Literal["text"] = "text" + """ + The type (fixed to 'text') + """ + + class CreateTaskRequest(BaseModel): """ Payload for creating a task """ model_config = ConfigDict( - extra="allow", populate_by_name=True, ) name: str @@ -129,7 +140,6 @@ class CreateTaskRequest(BaseModel): class EmbedStep(BaseWorkflowStep): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) kind_: Literal["embed"] = "embed" @@ -141,7 +151,6 @@ class EmbedStep(BaseWorkflowStep): class ErrorWorkflowStep(BaseWorkflowStep): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) kind_: Literal["error"] = "error" @@ -153,7 +162,6 @@ class ErrorWorkflowStep(BaseWorkflowStep): class EvaluateStep(BaseWorkflowStep): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) kind_: Literal["evaluate"] = "evaluate" @@ -165,7 +173,6 @@ class EvaluateStep(BaseWorkflowStep): class ForeachDo(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) in_: Annotated[str, Field(alias="in")] @@ -194,7 +201,6 @@ class ForeachDo(BaseModel): class ForeachStep(BaseWorkflowStep): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) kind_: Literal["foreach"] = "foreach" @@ -206,7 +212,6 @@ class ForeachStep(BaseWorkflowStep): class GetStep(BaseWorkflowStep): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) kind_: Literal["get"] = "get" @@ -218,7 +223,6 @@ class GetStep(BaseWorkflowStep): class IfElseWorkflowStep(BaseWorkflowStep): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) kind_: Literal["if_else"] = "if_else" @@ -267,7 +271,6 @@ class IfElseWorkflowStep(BaseWorkflowStep): class LogStep(BaseWorkflowStep): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) kind_: Literal["log"] = "log" @@ -279,7 +282,6 @@ class LogStep(BaseWorkflowStep): class MapOver(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) over: str @@ -294,7 +296,6 @@ class MapOver(BaseModel): class MapReduceStep(BaseWorkflowStep): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) kind_: Literal["map_reduce"] = "map_reduce" @@ -302,7 +303,7 @@ class MapReduceStep(BaseWorkflowStep): """ The steps to run for each iteration """ - reduce: str | None = None + reduce: Literal["_"] | str = "_" """ The expression to reduce the results (`_` is a list of outputs). If not provided, the results are returned as a list. """ @@ -310,7 +311,6 @@ class MapReduceStep(BaseWorkflowStep): class ParallelStep(BaseWorkflowStep): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) kind_: Literal["parallel"] = "parallel" @@ -340,7 +340,6 @@ class PatchTaskRequest(BaseModel): """ model_config = ConfigDict( - extra="allow", populate_by_name=True, ) description: str = "" @@ -385,13 +384,42 @@ class PatchTaskRequest(BaseModel): metadata: dict[str, Any] | None = None +class PromptItem(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + role: Literal[ + "user", + "assistant", + "system", + "function", + "function_response", + "function_call", + "auto", + ] + """ + The role of the message + """ + content: list[str] | list[Content | ChatMLImageContentPart] | str + """ + The content parts of the message + """ + name: str | None = None + """ + Name + """ + continue_: Annotated[StrictBool | None, Field(None, alias="continue")] + """ + Whether to continue this message or return a new one + """ + + class PromptStep(BaseWorkflowStep): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) kind_: Literal["prompt"] = "prompt" - prompt: str | list[InputChatMLMessage] + prompt: list[PromptItem] | str """ The prompt to run """ @@ -403,7 +431,6 @@ class PromptStep(BaseWorkflowStep): class ReturnStep(BaseWorkflowStep): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) kind_: Literal["return"] = "return" @@ -415,7 +442,6 @@ class ReturnStep(BaseWorkflowStep): class SearchStep(BaseWorkflowStep): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) kind_: Literal["search"] = "search" @@ -427,7 +453,6 @@ class SearchStep(BaseWorkflowStep): class SetKey(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) key: str @@ -442,11 +467,10 @@ class SetKey(BaseModel): class SetStep(BaseWorkflowStep): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) kind_: Literal["set"] = "set" - set: SetKey | list[SetKey] + set: SetKey """ The value to set """ @@ -454,22 +478,21 @@ class SetStep(BaseWorkflowStep): class SleepFor(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) - seconds: Annotated[int, Field(0, ge=0)] + seconds: Annotated[int, Field(0, ge=0, le=60)] """ The number of seconds to sleep for """ - minutes: Annotated[int, Field(0, ge=0)] + minutes: Annotated[int, Field(0, ge=0, le=60)] """ The number of minutes to sleep for """ - hours: Annotated[int, Field(0, ge=0)] + hours: Annotated[int, Field(0, ge=0, le=24)] """ The number of hours to sleep for """ - days: Annotated[int, Field(0, ge=0)] + days: Annotated[int, Field(0, ge=0, le=30)] """ The number of days to sleep for """ @@ -477,23 +500,21 @@ class SleepFor(BaseModel): class SleepStep(BaseWorkflowStep): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) kind_: Literal["sleep"] = "sleep" sleep: SleepFor """ - The duration to sleep for + The duration to sleep for (max 31 days) """ class SwitchStep(BaseWorkflowStep): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) kind_: Literal["switch"] = "switch" - switch: list[CaseThen] + switch: Annotated[list[CaseThen], Field(min_length=1)] """ The cond tree """ @@ -505,7 +526,6 @@ class Task(BaseModel): """ model_config = ConfigDict( - extra="allow", populate_by_name=True, ) name: str @@ -559,7 +579,6 @@ class Task(BaseModel): class TaskTool(CreateToolRequest): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) inherited: Annotated[StrictBool, Field(False, json_schema_extra={"readOnly": True})] @@ -570,7 +589,6 @@ class TaskTool(CreateToolRequest): class ToolCallStep(BaseWorkflowStep): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) kind_: Literal["tool_call"] = "tool_call" @@ -580,9 +598,9 @@ class ToolCallStep(BaseWorkflowStep): """ The tool to run """ - arguments: dict[str, str] + arguments: dict[str, str] | Literal["_"] = "_" """ - The input parameters for the tool + The input parameters for the tool (defaults to last step output) """ @@ -592,7 +610,6 @@ class UpdateTaskRequest(BaseModel): """ model_config = ConfigDict( - extra="allow", populate_by_name=True, ) description: str = "" @@ -636,7 +653,6 @@ class UpdateTaskRequest(BaseModel): class WaitForInputStep(BaseWorkflowStep): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) kind_: Literal["wait_for_input"] = "wait_for_input" @@ -648,7 +664,6 @@ class WaitForInputStep(BaseWorkflowStep): class YieldStep(BaseWorkflowStep): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) kind_: Literal["yield"] = "yield" @@ -656,7 +671,7 @@ class YieldStep(BaseWorkflowStep): """ The subworkflow to run """ - arguments: dict[str, str] + arguments: dict[str, str] | Literal["_"] = "_" """ - The input parameters for the subworkflow + The input parameters for the subworkflow (defaults to last step output) """ diff --git a/agents-api/agents_api/autogen/Tools.py b/agents-api/agents_api/autogen/Tools.py index 74d207d06..b28334041 100644 --- a/agents-api/agents_api/autogen/Tools.py +++ b/agents-api/agents_api/autogen/Tools.py @@ -15,7 +15,6 @@ class ChosenToolCall(BaseModel): """ model_config = ConfigDict( - extra="allow", populate_by_name=True, ) type: Literal["function", "integration", "system", "api_call"] @@ -35,14 +34,13 @@ class CreateToolRequest(BaseModel): """ model_config = ConfigDict( - extra="allow", populate_by_name=True, ) type: Literal["function", "integration", "system", "api_call"] """ Whether this tool is a `function`, `api_call`, `system` etc. (Only `function` tool supported right now) """ - name: Annotated[str, Field(pattern="^[^\\W0-9]\\w*$")] + name: Annotated[str, Field(max_length=40, pattern="^[^\\W0-9]\\w*$")] """ Name of the tool (must be unique for this agent and a valid python identifier string ) """ @@ -54,7 +52,6 @@ class CreateToolRequest(BaseModel): class FunctionCallOption(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) name: str @@ -69,7 +66,6 @@ class FunctionDef(BaseModel): """ model_config = ConfigDict( - extra="allow", populate_by_name=True, ) name: Any | None = None @@ -80,6 +76,7 @@ class FunctionDef(BaseModel): str | None, Field( None, + max_length=120, pattern="^[\\p{L}\\p{Nl}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]+[\\p{ID_Start}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]*$", ), ] @@ -94,7 +91,6 @@ class FunctionDef(BaseModel): class NamedToolChoice(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) type: Literal["function", "integration", "system", "api_call"] @@ -113,14 +109,13 @@ class PatchToolRequest(BaseModel): """ model_config = ConfigDict( - extra="allow", populate_by_name=True, ) type: Literal["function", "integration", "system", "api_call"] | None = None """ Whether this tool is a `function`, `api_call`, `system` etc. (Only `function` tool supported right now) """ - name: Annotated[str | None, Field(None, pattern="^[^\\W0-9]\\w*$")] + name: Annotated[str | None, Field(None, max_length=40, pattern="^[^\\W0-9]\\w*$")] """ Name of the tool (must be unique for this agent and a valid python identifier string ) """ @@ -132,14 +127,13 @@ class PatchToolRequest(BaseModel): class Tool(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) type: Literal["function", "integration", "system", "api_call"] """ Whether this tool is a `function`, `api_call`, `system` etc. (Only `function` tool supported right now) """ - name: Annotated[str, Field(pattern="^[^\\W0-9]\\w*$")] + name: Annotated[str, Field(max_length=40, pattern="^[^\\W0-9]\\w*$")] """ Name of the tool (must be unique for this agent and a valid python identifier string ) """ @@ -160,7 +154,6 @@ class Tool(BaseModel): class ToolResponse(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) id: UUID @@ -176,14 +169,13 @@ class UpdateToolRequest(BaseModel): """ model_config = ConfigDict( - extra="allow", populate_by_name=True, ) type: Literal["function", "integration", "system", "api_call"] """ Whether this tool is a `function`, `api_call`, `system` etc. (Only `function` tool supported right now) """ - name: Annotated[str, Field(pattern="^[^\\W0-9]\\w*$")] + name: Annotated[str, Field(max_length=40, pattern="^[^\\W0-9]\\w*$")] """ Name of the tool (must be unique for this agent and a valid python identifier string ) """ @@ -195,7 +187,6 @@ class UpdateToolRequest(BaseModel): class ChosenFunctionCall(ChosenToolCall): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) type: Literal["function"] = "function" @@ -207,7 +198,6 @@ class ChosenFunctionCall(ChosenToolCall): class FunctionTool(Tool): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) type: Literal["function"] = "function" @@ -220,7 +210,6 @@ class FunctionTool(Tool): class NamedFunctionChoice(NamedToolChoice): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) type: Literal["function"] = "function" diff --git a/agents-api/agents_api/autogen/Users.py b/agents-api/agents_api/autogen/Users.py index 24ba132ac..6eeb1783d 100644 --- a/agents-api/agents_api/autogen/Users.py +++ b/agents-api/agents_api/autogen/Users.py @@ -15,7 +15,6 @@ class CreateUserRequest(BaseModel): """ model_config = ConfigDict( - extra="allow", populate_by_name=True, ) metadata: dict[str, Any] | None = None @@ -23,6 +22,7 @@ class CreateUserRequest(BaseModel): str, Field( "", + max_length=120, pattern="^[\\p{L}\\p{Nl}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]+[\\p{ID_Start}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]*$", ), ] @@ -41,7 +41,6 @@ class PatchUserRequest(BaseModel): """ model_config = ConfigDict( - extra="allow", populate_by_name=True, ) metadata: dict[str, Any] | None = None @@ -49,6 +48,7 @@ class PatchUserRequest(BaseModel): str, Field( "", + max_length=120, pattern="^[\\p{L}\\p{Nl}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]+[\\p{ID_Start}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]*$", ), ] @@ -67,7 +67,6 @@ class UpdateUserRequest(BaseModel): """ model_config = ConfigDict( - extra="allow", populate_by_name=True, ) metadata: dict[str, Any] | None = None @@ -75,6 +74,7 @@ class UpdateUserRequest(BaseModel): str, Field( "", + max_length=120, pattern="^[\\p{L}\\p{Nl}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]+[\\p{ID_Start}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]*$", ), ] @@ -89,7 +89,6 @@ class UpdateUserRequest(BaseModel): class User(BaseModel): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) id: Annotated[UUID, Field(json_schema_extra={"readOnly": True})] @@ -106,6 +105,7 @@ class User(BaseModel): str, Field( "", + max_length=120, pattern="^[\\p{L}\\p{Nl}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]+[\\p{ID_Start}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]*$", ), ] @@ -120,7 +120,6 @@ class User(BaseModel): class CreateOrUpdateUserRequest(CreateUserRequest): model_config = ConfigDict( - extra="allow", populate_by_name=True, ) id: UUID diff --git a/agents-api/agents_api/autogen/openapi_model.py b/agents-api/agents_api/autogen/openapi_model.py index 0b0b0e2b5..593264c70 100644 --- a/agents-api/agents_api/autogen/openapi_model.py +++ b/agents-api/agents_api/autogen/openapi_model.py @@ -38,6 +38,8 @@ class ListResponse(BaseModel, Generic[DataT]): CreateOrUpdateSessionRequest = CreateSessionRequest CreateOrUpdateTaskRequest = CreateTaskRequest ChatResponse = ChunkChatResponse | MessageChatResponse +ChatMLTextContentPart = Content +InputChatMLMessage = Message # Custom types (not generated correctly) diff --git a/agents-api/agents_api/middleware.py b/agents-api/agents_api/middleware.py index a76b29fa6..d8ebc38ef 100644 --- a/agents-api/agents_api/middleware.py +++ b/agents-api/agents_api/middleware.py @@ -20,6 +20,8 @@ async def __call__(self, request: Request, call_next): ]: return await call_next(request) + # TODO: This should be wrapped in a try/except block to catch any parsing errors + # # Parse the YAML body into a Python object body = yaml.load(await request.body(), yaml.CSafeLoader) request._json = body diff --git a/agents-api/agents_api/web.py b/agents-api/agents_api/web.py index e20803e92..e633fc3ce 100644 --- a/agents-api/agents_api/web.py +++ b/agents-api/agents_api/web.py @@ -80,8 +80,14 @@ def register_exceptions(app: FastAPI) -> None: ) +# TODO: Auth logic should be moved into global middleware _per router_ +# Because some routes don't require auth +# See: https://fastapi.tiangolo.com/tutorial/bigger-applications/ +# app: Any = FastAPI(dependencies=[Depends(get_api_key)]) +# TODO: CORS should be enabled only for JWT auth +# app.add_middleware( CORSMiddleware, allow_origins=["*"], diff --git a/agents-api/poetry.lock b/agents-api/poetry.lock index 8223195dd..0ece98e08 100644 --- a/agents-api/poetry.lock +++ b/agents-api/poetry.lock @@ -1244,13 +1244,13 @@ networkx = ">=2" [[package]] name = "importlib-metadata" -version = "8.3.0" +version = "8.4.0" description = "Read metadata from Python packages" optional = false python-versions = ">=3.8" files = [ - {file = "importlib_metadata-8.3.0-py3-none-any.whl", hash = "sha256:42817a4a0be5845d22c6e212db66a94ad261e2318d80b3e0d363894a79df2b67"}, - {file = "importlib_metadata-8.3.0.tar.gz", hash = "sha256:9c8fa6e8ea0f9516ad5c8db9246a731c948193c7754d3babb0114a05b27dd364"}, + {file = "importlib_metadata-8.4.0-py3-none-any.whl", hash = "sha256:66f342cc6ac9818fc6ff340576acd24d65ba0b3efabb2b4ac08b598965a4a2f1"}, + {file = "importlib_metadata-8.4.0.tar.gz", hash = "sha256:9a547d3bc3608b025f93d403fdd1aae741c24fbb8314df4b155675742ce303c5"}, ] [package.dependencies] @@ -1837,13 +1837,13 @@ dev = ["Sphinx (>=5.1.1)", "black (==23.12.1)", "build (>=0.10.0)", "coverage (> [[package]] name = "litellm" -version = "1.43.18" +version = "1.43.19" description = "Library to easily interface with LLM API providers" optional = false python-versions = "!=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*,>=3.8" files = [ - {file = "litellm-1.43.18-py3-none-any.whl", hash = "sha256:68d853b4a0198a16e2260e4406a20f8d2e59bd903e019b7f3ba5a9f35ecc3e62"}, - {file = "litellm-1.43.18.tar.gz", hash = "sha256:e22b20065b62663dd060be9da1e84ca05903931c41c49d35a98649ed09e79d29"}, + {file = "litellm-1.43.19-py3-none-any.whl", hash = "sha256:f66bfe9c8b91577af57a5d1203728abc9b59df38a545148b7e85dec903185c12"}, + {file = "litellm-1.43.19.tar.gz", hash = "sha256:b1f475f98073632f0cea6d814bb10b14b6498e5ff93b91b52dfc00445bf013ab"}, ] [package.dependencies] @@ -2008,13 +2008,13 @@ files = [ [[package]] name = "marshmallow" -version = "3.21.3" +version = "3.22.0" description = "A lightweight library for converting complex datatypes to and from native Python datatypes." optional = false python-versions = ">=3.8" files = [ - {file = "marshmallow-3.21.3-py3-none-any.whl", hash = "sha256:86ce7fb914aa865001a4b2092c4c2872d13bc347f3d42673272cabfdbad386f1"}, - {file = "marshmallow-3.21.3.tar.gz", hash = "sha256:4f57c5e050a54d66361e826f94fba213eb10b67b2fdb02c3e0343ce207ba1662"}, + {file = "marshmallow-3.22.0-py3-none-any.whl", hash = "sha256:71a2dce49ef901c3f97ed296ae5051135fd3febd2bf43afe0ae9a82143a494d9"}, + {file = "marshmallow-3.22.0.tar.gz", hash = "sha256:4972f529104a220bb8637d595aa4c9762afbe7f7a77d82dc58c1615d70c5823e"}, ] [package.dependencies] @@ -2022,7 +2022,7 @@ packaging = ">=17.0" [package.extras] dev = ["marshmallow[tests]", "pre-commit (>=3.5,<4.0)", "tox"] -docs = ["alabaster (==0.7.16)", "autodocsumm (==0.2.12)", "sphinx (==7.3.7)", "sphinx-issues (==4.1.0)", "sphinx-version-warning (==1.1.2)"] +docs = ["alabaster (==1.0.0)", "autodocsumm (==0.2.13)", "sphinx (==8.0.2)", "sphinx-issues (==4.1.0)", "sphinx-version-warning (==1.1.2)"] tests = ["pytest", "pytz", "simplejson"] [[package]] diff --git a/agents-api/pyproject.toml b/agents-api/pyproject.toml index 5e965a97b..01a7f0e18 100644 --- a/agents-api/pyproject.toml +++ b/agents-api/pyproject.toml @@ -71,12 +71,11 @@ datamodel-codegen \ --strict-types bool \ --strict-nullable \ --allow-population-by-field-name \ - --allow-extra-fields \ --field-include-all-keys \ + --reuse-model \ --snake-case-field \ --enum-field-as-literal all \ --field-constraints \ - --reuse-model \ --use-operation-id-as-name \ --use-schema-description \ --use-field-description \ @@ -90,12 +89,12 @@ datamodel-codegen \ --use-exact-imports \ --use-standard-collections \ --use-non-positive-negative-number-constrained-types \ - --collapse-root-models \ --target-python-version 3.11 \ + --collapse-root-models \ --openapi-scopes schemas \ --keep-model-order \ --disable-timestamp""" [tool.poe.tasks.test] env = { AGENTS_API_TESTING = "true" } -cmd = "ward test" \ No newline at end of file +cmd = "ward test" diff --git a/scripts/generate_openapi_code.sh b/scripts/generate_openapi_code.sh index 1c1d22476..9d046dbda 100755 --- a/scripts/generate_openapi_code.sh +++ b/scripts/generate_openapi_code.sh @@ -10,7 +10,7 @@ cd typespec/ && \ tsp compile . cd - -fern generate +# fern generate cd sdks/python && \ poetry update && \ diff --git a/sdks/python/poetry.lock b/sdks/python/poetry.lock index ec7e2547a..4ad4307a6 100644 --- a/sdks/python/poetry.lock +++ b/sdks/python/poetry.lock @@ -829,13 +829,13 @@ networkx = ">=2" [[package]] name = "importlib-metadata" -version = "8.3.0" +version = "8.4.0" description = "Read metadata from Python packages" optional = false python-versions = ">=3.8" files = [ - {file = "importlib_metadata-8.3.0-py3-none-any.whl", hash = "sha256:42817a4a0be5845d22c6e212db66a94ad261e2318d80b3e0d363894a79df2b67"}, - {file = "importlib_metadata-8.3.0.tar.gz", hash = "sha256:9c8fa6e8ea0f9516ad5c8db9246a731c948193c7754d3babb0114a05b27dd364"}, + {file = "importlib_metadata-8.4.0-py3-none-any.whl", hash = "sha256:66f342cc6ac9818fc6ff340576acd24d65ba0b3efabb2b4ac08b598965a4a2f1"}, + {file = "importlib_metadata-8.4.0.tar.gz", hash = "sha256:9a547d3bc3608b025f93d403fdd1aae741c24fbb8314df4b155675742ce303c5"}, ] [package.dependencies] @@ -1466,13 +1466,13 @@ files = [ [[package]] name = "marshmallow" -version = "3.21.3" +version = "3.22.0" description = "A lightweight library for converting complex datatypes to and from native Python datatypes." optional = false python-versions = ">=3.8" files = [ - {file = "marshmallow-3.21.3-py3-none-any.whl", hash = "sha256:86ce7fb914aa865001a4b2092c4c2872d13bc347f3d42673272cabfdbad386f1"}, - {file = "marshmallow-3.21.3.tar.gz", hash = "sha256:4f57c5e050a54d66361e826f94fba213eb10b67b2fdb02c3e0343ce207ba1662"}, + {file = "marshmallow-3.22.0-py3-none-any.whl", hash = "sha256:71a2dce49ef901c3f97ed296ae5051135fd3febd2bf43afe0ae9a82143a494d9"}, + {file = "marshmallow-3.22.0.tar.gz", hash = "sha256:4972f529104a220bb8637d595aa4c9762afbe7f7a77d82dc58c1615d70c5823e"}, ] [package.dependencies] @@ -1480,7 +1480,7 @@ packaging = ">=17.0" [package.extras] dev = ["marshmallow[tests]", "pre-commit (>=3.5,<4.0)", "tox"] -docs = ["alabaster (==0.7.16)", "autodocsumm (==0.2.12)", "sphinx (==7.3.7)", "sphinx-issues (==4.1.0)", "sphinx-version-warning (==1.1.2)"] +docs = ["alabaster (==1.0.0)", "autodocsumm (==0.2.13)", "sphinx (==8.0.2)", "sphinx-issues (==4.1.0)", "sphinx-version-warning (==1.1.2)"] tests = ["pytest", "pytz", "simplejson"] [[package]] diff --git a/sdks/ts/src/api/index.ts b/sdks/ts/src/api/index.ts index 64ca78e83..293ad250a 100644 --- a/sdks/ts/src/api/index.ts +++ b/sdks/ts/src/api/index.ts @@ -35,6 +35,7 @@ export type { Chat_OpenAISettings } from "./models/Chat_OpenAISettings"; export type { Chat_SingleChatOutput } from "./models/Chat_SingleChatOutput"; export type { Chat_TokenLogProb } from "./models/Chat_TokenLogProb"; export type { Common_identifierSafeUnicode } from "./models/Common_identifierSafeUnicode"; +export type { Common_JinjaTemplate } from "./models/Common_JinjaTemplate"; export type { Common_limit } from "./models/Common_limit"; export type { Common_logit_bias } from "./models/Common_logit_bias"; export type { Common_offset } from "./models/Common_offset"; @@ -65,12 +66,10 @@ export type { Docs_VectorDocSearchRequest } from "./models/Docs_VectorDocSearchR export type { Entries_BaseEntry } from "./models/Entries_BaseEntry"; export type { Entries_ChatMLImageContentPart } from "./models/Entries_ChatMLImageContentPart"; export type { Entries_ChatMLRole } from "./models/Entries_ChatMLRole"; -export type { Entries_ChatMLTextContentPart } from "./models/Entries_ChatMLTextContentPart"; export type { Entries_Entry } from "./models/Entries_Entry"; export type { Entries_History } from "./models/Entries_History"; export type { Entries_ImageDetail } from "./models/Entries_ImageDetail"; export type { Entries_ImageURL } from "./models/Entries_ImageURL"; -export type { Entries_InputChatMLMessage } from "./models/Entries_InputChatMLMessage"; export type { Entries_Relation } from "./models/Entries_Relation"; export type { Executions_CreateExecutionRequest } from "./models/Executions_CreateExecutionRequest"; export type { Executions_Execution } from "./models/Executions_Execution"; @@ -170,6 +169,7 @@ export { $Chat_OpenAISettings } from "./schemas/$Chat_OpenAISettings"; export { $Chat_SingleChatOutput } from "./schemas/$Chat_SingleChatOutput"; export { $Chat_TokenLogProb } from "./schemas/$Chat_TokenLogProb"; export { $Common_identifierSafeUnicode } from "./schemas/$Common_identifierSafeUnicode"; +export { $Common_JinjaTemplate } from "./schemas/$Common_JinjaTemplate"; export { $Common_limit } from "./schemas/$Common_limit"; export { $Common_logit_bias } from "./schemas/$Common_logit_bias"; export { $Common_offset } from "./schemas/$Common_offset"; @@ -200,12 +200,10 @@ export { $Docs_VectorDocSearchRequest } from "./schemas/$Docs_VectorDocSearchReq export { $Entries_BaseEntry } from "./schemas/$Entries_BaseEntry"; export { $Entries_ChatMLImageContentPart } from "./schemas/$Entries_ChatMLImageContentPart"; export { $Entries_ChatMLRole } from "./schemas/$Entries_ChatMLRole"; -export { $Entries_ChatMLTextContentPart } from "./schemas/$Entries_ChatMLTextContentPart"; export { $Entries_Entry } from "./schemas/$Entries_Entry"; export { $Entries_History } from "./schemas/$Entries_History"; export { $Entries_ImageDetail } from "./schemas/$Entries_ImageDetail"; export { $Entries_ImageURL } from "./schemas/$Entries_ImageURL"; -export { $Entries_InputChatMLMessage } from "./schemas/$Entries_InputChatMLMessage"; export { $Entries_Relation } from "./schemas/$Entries_Relation"; export { $Executions_CreateExecutionRequest } from "./schemas/$Executions_CreateExecutionRequest"; export { $Executions_Execution } from "./schemas/$Executions_Execution"; diff --git a/sdks/ts/src/api/models/Chat_ChatInputData.ts b/sdks/ts/src/api/models/Chat_ChatInputData.ts index fb11ddec2..ca502e70b 100644 --- a/sdks/ts/src/api/models/Chat_ChatInputData.ts +++ b/sdks/ts/src/api/models/Chat_ChatInputData.ts @@ -2,14 +2,31 @@ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { Entries_InputChatMLMessage } from "./Entries_InputChatMLMessage"; +import type { Entries_ChatMLRole } from "./Entries_ChatMLRole"; import type { Tools_FunctionTool } from "./Tools_FunctionTool"; import type { Tools_NamedToolChoice } from "./Tools_NamedToolChoice"; export type Chat_ChatInputData = { /** * A list of new input messages comprising the conversation so far. */ - messages: Array; + messages: Array<{ + /** + * The role of the message + */ + role: Entries_ChatMLRole; + /** + * The content parts of the message + */ + content: string | Array; + /** + * Name + */ + name?: string; + /** + * Whether to continue this message or return a new one + */ + continue?: boolean; + }>; /** * (Advanced) List of tools that are provided in addition to agent's default set of tools. */ diff --git a/sdks/ts/src/api/models/Chat_ChatOutputChunk.ts b/sdks/ts/src/api/models/Chat_ChatOutputChunk.ts index a3bbfacc7..af379458a 100644 --- a/sdks/ts/src/api/models/Chat_ChatOutputChunk.ts +++ b/sdks/ts/src/api/models/Chat_ChatOutputChunk.ts @@ -3,7 +3,7 @@ /* tslint:disable */ /* eslint-disable */ import type { Chat_BaseChatOutput } from "./Chat_BaseChatOutput"; -import type { Entries_InputChatMLMessage } from "./Entries_InputChatMLMessage"; +import type { Entries_ChatMLRole } from "./Entries_ChatMLRole"; /** * Streaming chat completion output */ @@ -11,5 +11,22 @@ export type Chat_ChatOutputChunk = Chat_BaseChatOutput & { /** * The message generated by the model */ - delta: Entries_InputChatMLMessage; + delta: { + /** + * The role of the message + */ + role: Entries_ChatMLRole; + /** + * The content parts of the message + */ + content: string | Array; + /** + * Name + */ + name?: string; + /** + * Whether to continue this message or return a new one + */ + continue?: boolean; + }; }; diff --git a/sdks/ts/src/api/models/Chat_MultipleChatOutput.ts b/sdks/ts/src/api/models/Chat_MultipleChatOutput.ts index b0eb182f6..89c725dfa 100644 --- a/sdks/ts/src/api/models/Chat_MultipleChatOutput.ts +++ b/sdks/ts/src/api/models/Chat_MultipleChatOutput.ts @@ -3,10 +3,27 @@ /* tslint:disable */ /* eslint-disable */ import type { Chat_BaseChatOutput } from "./Chat_BaseChatOutput"; -import type { Entries_InputChatMLMessage } from "./Entries_InputChatMLMessage"; +import type { Entries_ChatMLRole } from "./Entries_ChatMLRole"; /** * The output returned by the model. Note that, depending on the model provider, they might return more than one message. */ export type Chat_MultipleChatOutput = Chat_BaseChatOutput & { - messages: Array; + messages: Array<{ + /** + * The role of the message + */ + role: Entries_ChatMLRole; + /** + * The content parts of the message + */ + content: string | Array; + /** + * Name + */ + name?: string; + /** + * Whether to continue this message or return a new one + */ + continue?: boolean; + }>; }; diff --git a/sdks/ts/src/api/models/Chat_SingleChatOutput.ts b/sdks/ts/src/api/models/Chat_SingleChatOutput.ts index 57b76490c..b90b8c953 100644 --- a/sdks/ts/src/api/models/Chat_SingleChatOutput.ts +++ b/sdks/ts/src/api/models/Chat_SingleChatOutput.ts @@ -3,10 +3,27 @@ /* tslint:disable */ /* eslint-disable */ import type { Chat_BaseChatOutput } from "./Chat_BaseChatOutput"; -import type { Entries_InputChatMLMessage } from "./Entries_InputChatMLMessage"; +import type { Entries_ChatMLRole } from "./Entries_ChatMLRole"; /** * The output returned by the model. Note that, depending on the model provider, they might return more than one message. */ export type Chat_SingleChatOutput = Chat_BaseChatOutput & { - message: Entries_InputChatMLMessage; + message: { + /** + * The role of the message + */ + role: Entries_ChatMLRole; + /** + * The content parts of the message + */ + content: string | Array; + /** + * Name + */ + name?: string; + /** + * Whether to continue this message or return a new one + */ + continue?: boolean; + }; }; diff --git a/sdks/ts/src/api/models/Entries_ChatMLTextContentPart.ts b/sdks/ts/src/api/models/Common_JinjaTemplate.ts similarity index 51% rename from sdks/ts/src/api/models/Entries_ChatMLTextContentPart.ts rename to sdks/ts/src/api/models/Common_JinjaTemplate.ts index 26e266d4e..7eb9f4a48 100644 --- a/sdks/ts/src/api/models/Entries_ChatMLTextContentPart.ts +++ b/sdks/ts/src/api/models/Common_JinjaTemplate.ts @@ -2,10 +2,7 @@ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -export type Entries_ChatMLTextContentPart = { - text: string; - /** - * The type (fixed to 'text') - */ - type: "text"; -}; +/** + * A valid jinja template. + */ +export type Common_JinjaTemplate = string; diff --git a/sdks/ts/src/api/models/Docs_CreateDocRequest.ts b/sdks/ts/src/api/models/Docs_CreateDocRequest.ts index 1294bf701..a972e0f83 100644 --- a/sdks/ts/src/api/models/Docs_CreateDocRequest.ts +++ b/sdks/ts/src/api/models/Docs_CreateDocRequest.ts @@ -2,7 +2,6 @@ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { Common_identifierSafeUnicode } from "./Common_identifierSafeUnicode"; /** * Payload for creating a doc */ @@ -11,7 +10,7 @@ export type Docs_CreateDocRequest = { /** * Title describing what this document contains */ - title: Common_identifierSafeUnicode; + title: string; /** * Contents of the document */ diff --git a/sdks/ts/src/api/models/Docs_Doc.ts b/sdks/ts/src/api/models/Docs_Doc.ts index 3a4c7681d..9735170c6 100644 --- a/sdks/ts/src/api/models/Docs_Doc.ts +++ b/sdks/ts/src/api/models/Docs_Doc.ts @@ -2,7 +2,6 @@ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import type { Common_identifierSafeUnicode } from "./Common_identifierSafeUnicode"; import type { Common_uuid } from "./Common_uuid"; export type Docs_Doc = { readonly id: Common_uuid; @@ -14,7 +13,7 @@ export type Docs_Doc = { /** * Title describing what this document contains */ - title: Common_identifierSafeUnicode; + title: string; /** * Contents of the document */ diff --git a/sdks/ts/src/api/models/Entries_InputChatMLMessage.ts b/sdks/ts/src/api/models/Entries_InputChatMLMessage.ts deleted file mode 100644 index e735b8bd1..000000000 --- a/sdks/ts/src/api/models/Entries_InputChatMLMessage.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import type { Entries_ChatMLRole } from "./Entries_ChatMLRole"; -export type Entries_InputChatMLMessage = { - /** - * The role of the message - */ - role: Entries_ChatMLRole; - /** - * The content parts of the message - */ - content: string | Array; - /** - * Name - */ - name?: string; - /** - * Whether to continue this message or return a new one - */ - continue?: boolean; -}; diff --git a/sdks/ts/src/api/models/Tasks_CaseThen.ts b/sdks/ts/src/api/models/Tasks_CaseThen.ts index c55e939ad..ab51af385 100644 --- a/sdks/ts/src/api/models/Tasks_CaseThen.ts +++ b/sdks/ts/src/api/models/Tasks_CaseThen.ts @@ -20,7 +20,7 @@ export type Tasks_CaseThen = { /** * The condition to evaluate */ - case: Common_PyExpression; + case: Common_PyExpression | "_"; /** * The steps to run if the condition is true */ diff --git a/sdks/ts/src/api/models/Tasks_MapReduceStep.ts b/sdks/ts/src/api/models/Tasks_MapReduceStep.ts index e450d9162..ef049ed42 100644 --- a/sdks/ts/src/api/models/Tasks_MapReduceStep.ts +++ b/sdks/ts/src/api/models/Tasks_MapReduceStep.ts @@ -14,5 +14,5 @@ export type Tasks_MapReduceStep = Tasks_BaseWorkflowStep & { /** * The expression to reduce the results (`_` is a list of outputs). If not provided, the results are returned as a list. */ - reduce?: Common_PyExpression; + reduce: Common_PyExpression | "_"; }; diff --git a/sdks/ts/src/api/models/Tasks_PromptStep.ts b/sdks/ts/src/api/models/Tasks_PromptStep.ts index 39a7127ac..db019b522 100644 --- a/sdks/ts/src/api/models/Tasks_PromptStep.ts +++ b/sdks/ts/src/api/models/Tasks_PromptStep.ts @@ -3,14 +3,14 @@ /* tslint:disable */ /* eslint-disable */ import type { Chat_ChatSettings } from "./Chat_ChatSettings"; -import type { Entries_InputChatMLMessage } from "./Entries_InputChatMLMessage"; +import type { Common_JinjaTemplate } from "./Common_JinjaTemplate"; import type { Tasks_BaseWorkflowStep } from "./Tasks_BaseWorkflowStep"; export type Tasks_PromptStep = Tasks_BaseWorkflowStep & { kind_: "prompt"; /** * The prompt to run */ - prompt: string | Array; + prompt: Common_JinjaTemplate; /** * Settings for the prompt */ diff --git a/sdks/ts/src/api/models/Tasks_SetStep.ts b/sdks/ts/src/api/models/Tasks_SetStep.ts index a4425ecc3..61838776e 100644 --- a/sdks/ts/src/api/models/Tasks_SetStep.ts +++ b/sdks/ts/src/api/models/Tasks_SetStep.ts @@ -9,5 +9,5 @@ export type Tasks_SetStep = Tasks_BaseWorkflowStep & { /** * The value to set */ - set: Tasks_SetKey | Array; + set: Tasks_SetKey; }; diff --git a/sdks/ts/src/api/models/Tasks_SleepStep.ts b/sdks/ts/src/api/models/Tasks_SleepStep.ts index c2a14b9b5..cd2994546 100644 --- a/sdks/ts/src/api/models/Tasks_SleepStep.ts +++ b/sdks/ts/src/api/models/Tasks_SleepStep.ts @@ -7,7 +7,7 @@ import type { Tasks_SleepFor } from "./Tasks_SleepFor"; export type Tasks_SleepStep = Tasks_BaseWorkflowStep & { kind_: "sleep"; /** - * The duration to sleep for + * The duration to sleep for (max 31 days) */ sleep: Tasks_SleepFor; }; diff --git a/sdks/ts/src/api/models/Tasks_ToolCallStep.ts b/sdks/ts/src/api/models/Tasks_ToolCallStep.ts index f0a758372..dfb0b505c 100644 --- a/sdks/ts/src/api/models/Tasks_ToolCallStep.ts +++ b/sdks/ts/src/api/models/Tasks_ToolCallStep.ts @@ -12,7 +12,7 @@ export type Tasks_ToolCallStep = Tasks_BaseWorkflowStep & { */ tool: Common_toolRef; /** - * The input parameters for the tool + * The input parameters for the tool (defaults to last step output) */ - arguments: Record; + arguments: Record | "_"; }; diff --git a/sdks/ts/src/api/models/Tasks_YieldStep.ts b/sdks/ts/src/api/models/Tasks_YieldStep.ts index a1e298a41..6b677947e 100644 --- a/sdks/ts/src/api/models/Tasks_YieldStep.ts +++ b/sdks/ts/src/api/models/Tasks_YieldStep.ts @@ -11,7 +11,7 @@ export type Tasks_YieldStep = Tasks_BaseWorkflowStep & { */ workflow: string; /** - * The input parameters for the subworkflow + * The input parameters for the subworkflow (defaults to last step output) */ - arguments: Record; + arguments: Record | "_"; }; diff --git a/sdks/ts/src/api/schemas/$Chat_ChatInputData.ts b/sdks/ts/src/api/schemas/$Chat_ChatInputData.ts index b5ed3b199..3206351d5 100644 --- a/sdks/ts/src/api/schemas/$Chat_ChatInputData.ts +++ b/sdks/ts/src/api/schemas/$Chat_ChatInputData.ts @@ -7,7 +7,42 @@ export const $Chat_ChatInputData = { messages: { type: "array", contains: { - type: "Entries_InputChatMLMessage", + properties: { + role: { + type: "all-of", + description: `The role of the message`, + contains: [ + { + type: "Entries_ChatMLRole", + }, + ], + isRequired: true, + }, + content: { + type: "any-of", + description: `The content parts of the message`, + contains: [ + { + type: "string", + }, + { + type: "array", + contains: { + type: "string", + }, + }, + ], + isRequired: true, + }, + name: { + type: "string", + description: `Name`, + }, + continue: { + type: "boolean", + description: `Whether to continue this message or return a new one`, + }, + }, }, isRequired: true, }, diff --git a/sdks/ts/src/api/schemas/$Chat_ChatOutputChunk.ts b/sdks/ts/src/api/schemas/$Chat_ChatOutputChunk.ts index 71efa1925..869be9d62 100644 --- a/sdks/ts/src/api/schemas/$Chat_ChatOutputChunk.ts +++ b/sdks/ts/src/api/schemas/$Chat_ChatOutputChunk.ts @@ -12,13 +12,43 @@ export const $Chat_ChatOutputChunk = { { properties: { delta: { - type: "all-of", description: `The message generated by the model`, - contains: [ - { - type: "Entries_InputChatMLMessage", + properties: { + role: { + type: "all-of", + description: `The role of the message`, + contains: [ + { + type: "Entries_ChatMLRole", + }, + ], + isRequired: true, }, - ], + content: { + type: "any-of", + description: `The content parts of the message`, + contains: [ + { + type: "string", + }, + { + type: "array", + contains: { + type: "string", + }, + }, + ], + isRequired: true, + }, + name: { + type: "string", + description: `Name`, + }, + continue: { + type: "boolean", + description: `Whether to continue this message or return a new one`, + }, + }, isRequired: true, }, }, diff --git a/sdks/ts/src/api/schemas/$Chat_MultipleChatOutput.ts b/sdks/ts/src/api/schemas/$Chat_MultipleChatOutput.ts index 331290c5c..2b54621f5 100644 --- a/sdks/ts/src/api/schemas/$Chat_MultipleChatOutput.ts +++ b/sdks/ts/src/api/schemas/$Chat_MultipleChatOutput.ts @@ -14,7 +14,42 @@ export const $Chat_MultipleChatOutput = { messages: { type: "array", contains: { - type: "Entries_InputChatMLMessage", + properties: { + role: { + type: "all-of", + description: `The role of the message`, + contains: [ + { + type: "Entries_ChatMLRole", + }, + ], + isRequired: true, + }, + content: { + type: "any-of", + description: `The content parts of the message`, + contains: [ + { + type: "string", + }, + { + type: "array", + contains: { + type: "string", + }, + }, + ], + isRequired: true, + }, + name: { + type: "string", + description: `Name`, + }, + continue: { + type: "boolean", + description: `Whether to continue this message or return a new one`, + }, + }, }, isRequired: true, }, diff --git a/sdks/ts/src/api/schemas/$Chat_SingleChatOutput.ts b/sdks/ts/src/api/schemas/$Chat_SingleChatOutput.ts index 75c9ddf74..e5f68cf9b 100644 --- a/sdks/ts/src/api/schemas/$Chat_SingleChatOutput.ts +++ b/sdks/ts/src/api/schemas/$Chat_SingleChatOutput.ts @@ -12,7 +12,42 @@ export const $Chat_SingleChatOutput = { { properties: { message: { - type: "Entries_InputChatMLMessage", + properties: { + role: { + type: "all-of", + description: `The role of the message`, + contains: [ + { + type: "Entries_ChatMLRole", + }, + ], + isRequired: true, + }, + content: { + type: "any-of", + description: `The content parts of the message`, + contains: [ + { + type: "string", + }, + { + type: "array", + contains: { + type: "string", + }, + }, + ], + isRequired: true, + }, + name: { + type: "string", + description: `Name`, + }, + continue: { + type: "boolean", + description: `Whether to continue this message or return a new one`, + }, + }, isRequired: true, }, }, diff --git a/sdks/ts/src/api/schemas/$Common_JinjaTemplate.ts b/sdks/ts/src/api/schemas/$Common_JinjaTemplate.ts new file mode 100644 index 000000000..903a1579b --- /dev/null +++ b/sdks/ts/src/api/schemas/$Common_JinjaTemplate.ts @@ -0,0 +1,8 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $Common_JinjaTemplate = { + type: "string", + description: `A valid jinja template.`, +} as const; diff --git a/sdks/ts/src/api/schemas/$Common_identifierSafeUnicode.ts b/sdks/ts/src/api/schemas/$Common_identifierSafeUnicode.ts index e3e2e9f0a..75cd72df6 100644 --- a/sdks/ts/src/api/schemas/$Common_identifierSafeUnicode.ts +++ b/sdks/ts/src/api/schemas/$Common_identifierSafeUnicode.ts @@ -7,6 +7,7 @@ export const $Common_identifierSafeUnicode = { description: `For Unicode character safety See: https://unicode.org/reports/tr31/ See: https://www.unicode.org/reports/tr39/#Identifier_Characters`, + maxLength: 120, pattern: "^[\\p{L}\\p{Nl}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]+[\\p{ID_Start}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]*$", } as const; diff --git a/sdks/ts/src/api/schemas/$Common_validPythonIdentifier.ts b/sdks/ts/src/api/schemas/$Common_validPythonIdentifier.ts index 7be2759cc..89c378739 100644 --- a/sdks/ts/src/api/schemas/$Common_validPythonIdentifier.ts +++ b/sdks/ts/src/api/schemas/$Common_validPythonIdentifier.ts @@ -5,5 +5,6 @@ export const $Common_validPythonIdentifier = { type: "string", description: `Valid python identifier names`, + maxLength: 40, pattern: "^[^\\W0-9]\\w*$", } as const; diff --git a/sdks/ts/src/api/schemas/$Docs_CreateDocRequest.ts b/sdks/ts/src/api/schemas/$Docs_CreateDocRequest.ts index a3e2a7075..4af7128e1 100644 --- a/sdks/ts/src/api/schemas/$Docs_CreateDocRequest.ts +++ b/sdks/ts/src/api/schemas/$Docs_CreateDocRequest.ts @@ -12,14 +12,10 @@ export const $Docs_CreateDocRequest = { }, }, title: { - type: "all-of", + type: "string", description: `Title describing what this document contains`, - contains: [ - { - type: "Common_identifierSafeUnicode", - }, - ], isRequired: true, + maxLength: 800, }, content: { type: "any-of", diff --git a/sdks/ts/src/api/schemas/$Docs_Doc.ts b/sdks/ts/src/api/schemas/$Docs_Doc.ts index d6c622cb0..f77ec6d23 100644 --- a/sdks/ts/src/api/schemas/$Docs_Doc.ts +++ b/sdks/ts/src/api/schemas/$Docs_Doc.ts @@ -28,14 +28,10 @@ export const $Docs_Doc = { format: "date-time", }, title: { - type: "all-of", + type: "string", description: `Title describing what this document contains`, - contains: [ - { - type: "Common_identifierSafeUnicode", - }, - ], isRequired: true, + maxLength: 800, }, content: { type: "any-of", diff --git a/sdks/ts/src/api/schemas/$Entries_ChatMLTextContentPart.ts b/sdks/ts/src/api/schemas/$Entries_ChatMLTextContentPart.ts deleted file mode 100644 index 1701225c5..000000000 --- a/sdks/ts/src/api/schemas/$Entries_ChatMLTextContentPart.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export const $Entries_ChatMLTextContentPart = { - properties: { - text: { - type: "string", - isRequired: true, - }, - type: { - type: "Enum", - isRequired: true, - }, - }, -} as const; diff --git a/sdks/ts/src/api/schemas/$Entries_InputChatMLMessage.ts b/sdks/ts/src/api/schemas/$Entries_InputChatMLMessage.ts deleted file mode 100644 index 2f888d08b..000000000 --- a/sdks/ts/src/api/schemas/$Entries_InputChatMLMessage.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export const $Entries_InputChatMLMessage = { - properties: { - role: { - type: "all-of", - description: `The role of the message`, - contains: [ - { - type: "Entries_ChatMLRole", - }, - ], - isRequired: true, - }, - content: { - type: "any-of", - description: `The content parts of the message`, - contains: [ - { - type: "string", - }, - { - type: "array", - contains: { - type: "string", - }, - }, - ], - isRequired: true, - }, - name: { - type: "string", - description: `Name`, - }, - continue: { - type: "boolean", - description: `Whether to continue this message or return a new one`, - }, - }, -} as const; diff --git a/sdks/ts/src/api/schemas/$Tasks_CaseThen.ts b/sdks/ts/src/api/schemas/$Tasks_CaseThen.ts index c58942ef5..f30f3bf91 100644 --- a/sdks/ts/src/api/schemas/$Tasks_CaseThen.ts +++ b/sdks/ts/src/api/schemas/$Tasks_CaseThen.ts @@ -5,12 +5,15 @@ export const $Tasks_CaseThen = { properties: { case: { - type: "all-of", + type: "any-of", description: `The condition to evaluate`, contains: [ { type: "Common_PyExpression", }, + { + type: "Enum", + }, ], isRequired: true, }, diff --git a/sdks/ts/src/api/schemas/$Tasks_MapReduceStep.ts b/sdks/ts/src/api/schemas/$Tasks_MapReduceStep.ts index 3d52b1727..e24fc2479 100644 --- a/sdks/ts/src/api/schemas/$Tasks_MapReduceStep.ts +++ b/sdks/ts/src/api/schemas/$Tasks_MapReduceStep.ts @@ -25,13 +25,17 @@ export const $Tasks_MapReduceStep = { isRequired: true, }, reduce: { - type: "all-of", + type: "any-of", description: `The expression to reduce the results (\`_\` is a list of outputs). If not provided, the results are returned as a list.`, contains: [ { type: "Common_PyExpression", }, + { + type: "Enum", + }, ], + isRequired: true, }, }, }, diff --git a/sdks/ts/src/api/schemas/$Tasks_PromptStep.ts b/sdks/ts/src/api/schemas/$Tasks_PromptStep.ts index 3eb78c319..882307bdd 100644 --- a/sdks/ts/src/api/schemas/$Tasks_PromptStep.ts +++ b/sdks/ts/src/api/schemas/$Tasks_PromptStep.ts @@ -19,13 +19,7 @@ export const $Tasks_PromptStep = { description: `The prompt to run`, contains: [ { - type: "string", - }, - { - type: "array", - contains: { - type: "Entries_InputChatMLMessage", - }, + type: "Common_JinjaTemplate", }, ], isRequired: true, diff --git a/sdks/ts/src/api/schemas/$Tasks_SetStep.ts b/sdks/ts/src/api/schemas/$Tasks_SetStep.ts index 7c768fc10..0590f1141 100644 --- a/sdks/ts/src/api/schemas/$Tasks_SetStep.ts +++ b/sdks/ts/src/api/schemas/$Tasks_SetStep.ts @@ -15,18 +15,12 @@ export const $Tasks_SetStep = { isRequired: true, }, set: { - type: "any-of", + type: "all-of", description: `The value to set`, contains: [ { type: "Tasks_SetKey", }, - { - type: "array", - contains: { - type: "Tasks_SetKey", - }, - }, ], isRequired: true, }, diff --git a/sdks/ts/src/api/schemas/$Tasks_SleepFor.ts b/sdks/ts/src/api/schemas/$Tasks_SleepFor.ts index a03d5591c..025d83c26 100644 --- a/sdks/ts/src/api/schemas/$Tasks_SleepFor.ts +++ b/sdks/ts/src/api/schemas/$Tasks_SleepFor.ts @@ -9,24 +9,28 @@ export const $Tasks_SleepFor = { description: `The number of seconds to sleep for`, isRequired: true, format: "uint16", + maximum: 60, }, minutes: { type: "number", description: `The number of minutes to sleep for`, isRequired: true, format: "uint16", + maximum: 60, }, hours: { type: "number", description: `The number of hours to sleep for`, isRequired: true, format: "uint16", + maximum: 24, }, days: { type: "number", description: `The number of days to sleep for`, isRequired: true, format: "uint16", + maximum: 30, }, }, } as const; diff --git a/sdks/ts/src/api/schemas/$Tasks_SleepStep.ts b/sdks/ts/src/api/schemas/$Tasks_SleepStep.ts index 79d23cbcf..41fcf166d 100644 --- a/sdks/ts/src/api/schemas/$Tasks_SleepStep.ts +++ b/sdks/ts/src/api/schemas/$Tasks_SleepStep.ts @@ -16,7 +16,7 @@ export const $Tasks_SleepStep = { }, sleep: { type: "all-of", - description: `The duration to sleep for`, + description: `The duration to sleep for (max 31 days)`, contains: [ { type: "Tasks_SleepFor", diff --git a/sdks/ts/src/api/schemas/$Tasks_ToolCallStep.ts b/sdks/ts/src/api/schemas/$Tasks_ToolCallStep.ts index 1f6a07c09..54c54af17 100644 --- a/sdks/ts/src/api/schemas/$Tasks_ToolCallStep.ts +++ b/sdks/ts/src/api/schemas/$Tasks_ToolCallStep.ts @@ -25,10 +25,19 @@ export const $Tasks_ToolCallStep = { isRequired: true, }, arguments: { - type: "dictionary", - contains: { - type: "Common_PyExpression", - }, + type: "any-of", + description: `The input parameters for the tool (defaults to last step output)`, + contains: [ + { + type: "dictionary", + contains: { + type: "Common_PyExpression", + }, + }, + { + type: "Enum", + }, + ], isRequired: true, }, }, diff --git a/sdks/ts/src/api/schemas/$Tasks_YieldStep.ts b/sdks/ts/src/api/schemas/$Tasks_YieldStep.ts index 778bdeb90..376b32a56 100644 --- a/sdks/ts/src/api/schemas/$Tasks_YieldStep.ts +++ b/sdks/ts/src/api/schemas/$Tasks_YieldStep.ts @@ -20,10 +20,19 @@ export const $Tasks_YieldStep = { isRequired: true, }, arguments: { - type: "dictionary", - contains: { - type: "Common_PyExpression", - }, + type: "any-of", + description: `The input parameters for the subworkflow (defaults to last step output)`, + contains: [ + { + type: "dictionary", + contains: { + type: "Common_PyExpression", + }, + }, + { + type: "Enum", + }, + ], isRequired: true, }, }, diff --git a/typespec/agents/models.tsp b/typespec/agents/models.tsp index 0e5e17b62..17f43691b 100644 --- a/typespec/agents/models.tsp +++ b/typespec/agents/models.tsp @@ -20,8 +20,7 @@ model Agent { ...HasTimestamps; /** Name of the agent */ - @maxLength(120) - name: identifierSafeUnicode = ""; + name: identifierSafeUnicode = identifierSafeUnicode(""); /** About the agent */ about: string = ""; diff --git a/typespec/common/scalars.tsp b/typespec/common/scalars.tsp index 177f2ccd6..79eda2d99 100644 --- a/typespec/common/scalars.tsp +++ b/typespec/common/scalars.tsp @@ -12,11 +12,13 @@ scalar uuid extends string; * See: https://unicode.org/reports/tr31/ * See: https://www.unicode.org/reports/tr39/#Identifier_Characters */ +@maxLength(120) @pattern("^[\\p{L}\\p{Nl}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]+[\\p{ID_Start}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]*$") scalar identifierSafeUnicode extends string; /** Valid python identifier names */ @pattern("^[^\\W0-9]\\w*$") +@maxLength(40) scalar validPythonIdentifier extends string; /** Limit the number of results */ @@ -51,4 +53,7 @@ alias entrySource = "api_request" | "api_response" | "tool_response" | "internal scalar toolRef extends string; /** A simple python expression compatible with SimpleEval. */ -scalar PyExpression extends string; \ No newline at end of file +scalar PyExpression extends string; + +/** A valid jinja template. */ +scalar JinjaTemplate extends string; \ No newline at end of file diff --git a/typespec/docs/models.tsp b/typespec/docs/models.tsp index 0b57c02a8..ee283fe02 100644 --- a/typespec/docs/models.tsp +++ b/typespec/docs/models.tsp @@ -19,7 +19,7 @@ model Doc { /** Title describing what this document contains */ @maxLength(800) - title: identifierSafeUnicode; + title: string; /** Contents of the document */ content: string | string[]; diff --git a/typespec/entries/models.tsp b/typespec/entries/models.tsp index fba6803df..70a84233f 100644 --- a/typespec/entries/models.tsp +++ b/typespec/entries/models.tsp @@ -39,8 +39,8 @@ model ImageURL { detail: ImageDetail = ImageDetail.auto; } -model ChatMLTextContentPart { - text: string; +model ChatMLTextContentPart { + text: T; /** The type (fixed to 'text') */ type: "text" = "text"; @@ -54,14 +54,14 @@ model ChatMLImageContentPart { type: "image_url" = "image_url"; } -alias ChatMLContentPart = ChatMLTextContentPart | ChatMLImageContentPart; +alias ChatMLContentPart = ChatMLTextContentPart | ChatMLImageContentPart; -model ChatMLMessage { +model ChatMLMessage { /** The role of the message */ role: ChatMLRole; /** The content parts of the message */ - content: string | string[] | ChatMLContentPart[]; + content: T | T[] | ChatMLContentPart[]; /** Name */ name?: string; @@ -79,11 +79,11 @@ model ChatMLMessage { } @withVisibility("create") -model InputChatMLMessage { - ...ChatMLMessage; +model InputChatMLMessage { + ...ChatMLMessage; } -alias EntryContent = ChatMLContentPart[] | Tool | ChosenToolCall | string | ToolResponse; +alias EntryContent = ChatMLContentPart[] | Tool | ChosenToolCall | string | ToolResponse; model BaseEntry { role: ChatMLRole; diff --git a/typespec/jobs/models.tsp b/typespec/jobs/models.tsp index 07663d005..e8050b083 100644 --- a/typespec/jobs/models.tsp +++ b/typespec/jobs/models.tsp @@ -24,8 +24,7 @@ model JobStatus { ...HasTimestamps; /** Name of the job */ - @maxLength(120) - name: identifierSafeUnicode = ""; + name: identifierSafeUnicode = identifierSafeUnicode(""); /** Reason for the current state of the job */ reason: string = ""; diff --git a/typespec/tasks/steps.tsp b/typespec/tasks/steps.tsp index 2da1d2cdf..1cdbf213e 100644 --- a/typespec/tasks/steps.tsp +++ b/typespec/tasks/steps.tsp @@ -21,8 +21,9 @@ namespace Tasks; // /** An object where values are strings in the Common Expression Language that get evaluated before being passed downstream */ -alias ExpressionObject = Record; -alias NestedExpressionObject = Record; +alias TypedExpression = PyExpression; +alias ExpressionObject = Record>; +alias NestedExpressionObject = Record | ExpressionObject>; @discriminator("kind_") model BaseWorkflowStep { @@ -61,15 +62,15 @@ model ToolCallStep extends BaseWorkflowStep { /** The tool to run */ tool: toolRef; - /** The input parameters for the tool */ - arguments: ExpressionObject; + /** The input parameters for the tool (defaults to last step output) */ + arguments: ExpressionObject | "_" = "_"; } model PromptStep extends BaseWorkflowStep { kind_: "prompt" = "prompt"; /** The prompt to run */ - prompt: string | InputChatMLMessage[]; + prompt: JinjaTemplate | InputChatMLMessage[]; /** Settings for the prompt */ settings: ChatSettings; @@ -79,21 +80,21 @@ model EvaluateStep extends BaseWorkflowStep { kind_: "evaluate" = "evaluate"; /** The expression to evaluate */ - evaluate: ExpressionObject; + evaluate: ExpressionObject; } model WaitForInputStep extends BaseWorkflowStep { kind_: "wait_for_input" = "wait_for_input"; /** Any additional info or data */ - wait_for_input: ExpressionObject; + wait_for_input: ExpressionObject; } model LogStep extends BaseWorkflowStep { kind_: "log" = "log"; /** The value to log */ - log: PyExpression; + log: TypedExpression; } //////////////////////// @@ -130,14 +131,14 @@ model SetKey { key: string; /** The value to set */ - value: PyExpression; + value: TypedExpression; } model SetStep extends BaseWorkflowStep { kind_: "set" = "set"; /** The value to set */ - set: SetKey | SetKey[]; + set: SetKey; } /////////////////////// @@ -154,7 +155,7 @@ model ParallelStep extends BaseWorkflowStep { model ForeachDo { /** The variable to iterate over */ - in: PyExpression; + in: TypedExpression>; /** The steps to run for each iteration */ do: NonConditionalWorkflowStep; @@ -169,7 +170,7 @@ model ForeachStep extends BaseWorkflowStep { model MapOver { /** The variable to iterate over */ - over: PyExpression; + over: TypedExpression>; /** The subworkflow to run for each iteration */ workflow: string; @@ -182,7 +183,7 @@ model MapReduceStep extends BaseWorkflowStep { map: MapOver; /** The expression to reduce the results (`_` is a list of outputs). If not provided, the results are returned as a list. */ - reduce?: PyExpression; + reduce: TypedExpression | "_" = "_"; } ///////////////////////// @@ -193,7 +194,7 @@ model IfElseWorkflowStep extends BaseWorkflowStep { kind_: "if_else" = "if_else"; /** The condition to evaluate */ - `if`: PyExpression; + `if`: TypedExpression; /** The steps to run if the condition is true */ then: NonConditionalWorkflowStep; @@ -204,7 +205,7 @@ model IfElseWorkflowStep extends BaseWorkflowStep { model CaseThen { /** The condition to evaluate */ - case: PyExpression; + case: TypedExpression | "_"; // To support '_' as a value /** The steps to run if the condition is true */ then: NonConditionalWorkflowStep; @@ -214,6 +215,7 @@ model SwitchStep extends BaseWorkflowStep { kind_: "switch" = "switch"; /** The cond tree */ + @minItems(1) switch: CaseThen[]; } @@ -227,8 +229,8 @@ model YieldStep extends BaseWorkflowStep { /** The subworkflow to run */ workflow: string; - /** The input parameters for the subworkflow */ - arguments: ExpressionObject; + /** The input parameters for the subworkflow (defaults to last step output) */ + arguments: ExpressionObject | "_" = "_"; } model ErrorWorkflowStep extends BaseWorkflowStep { @@ -241,25 +243,29 @@ model ErrorWorkflowStep extends BaseWorkflowStep { model SleepFor { /** The number of seconds to sleep for */ @minValue(0) + @maxValue(60) seconds: uint16 = 0; /** The number of minutes to sleep for */ @minValue(0) + @maxValue(60) minutes: uint16 = 0; /** The number of hours to sleep for */ @minValue(0) + @maxValue(24) hours: uint16 = 0; /** The number of days to sleep for */ @minValue(0) + @maxValue(30) days: uint16 = 0; } model SleepStep extends BaseWorkflowStep { kind_: "sleep" = "sleep"; - /** The duration to sleep for */ + /** The duration to sleep for (max 31 days) */ sleep: SleepFor; } @@ -267,5 +273,5 @@ model ReturnStep extends BaseWorkflowStep { kind_: "return" = "return"; /** The value to return */ - `return`: ExpressionObject; + `return`: ExpressionObject; } diff --git a/typespec/users/models.tsp b/typespec/users/models.tsp index de7baadef..c21b1b03c 100644 --- a/typespec/users/models.tsp +++ b/typespec/users/models.tsp @@ -18,8 +18,7 @@ model User { ...HasTimestamps; /** Name of the user */ - @maxLength(120) - name: identifierSafeUnicode = ""; + name: identifierSafeUnicode = identifierSafeUnicode(""); /** About the user */ about: string = "";