Skip to content

Commit

Permalink
feat: New python client
Browse files Browse the repository at this point in the history
Signed-off-by: Diwank Singh Tomer <[email protected]>
  • Loading branch information
creatorrr committed Sep 8, 2024
1 parent 1172764 commit aedba24
Show file tree
Hide file tree
Showing 137 changed files with 5,457 additions and 1,793 deletions.
468 changes: 260 additions & 208 deletions agents-api/agents_api/autogen/Chat.py

Large diffs are not rendered by default.

32 changes: 18 additions & 14 deletions agents-api/agents_api/autogen/Docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,6 @@
from pydantic import AwareDatetime, BaseModel, ConfigDict, Field


class BaseDocSearchRequest(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
limit: Annotated[int, Field(10, ge=1, le=100)]
lang: Literal["en-US"] = "en-US"
"""
The language to be used for text-only search. Support for other languages coming soon.
"""


class CreateDocRequest(BaseModel):
"""
Payload for creating a doc
Expand Down Expand Up @@ -118,10 +107,15 @@ class EmbedQueryResponse(BaseModel):
"""


class HybridDocSearchRequest(BaseDocSearchRequest):
class HybridDocSearchRequest(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
limit: Annotated[int, Field(10, ge=1, le=100)]
lang: Literal["en-US"] = "en-US"
"""
The language to be used for text-only search. Support for other languages coming soon.
"""
confidence: Annotated[float, Field(0.5, ge=0.0, le=1.0)]
"""
The confidence cutoff level
Expand All @@ -148,20 +142,30 @@ class Snippet(BaseModel):
content: str


class TextOnlyDocSearchRequest(BaseDocSearchRequest):
class TextOnlyDocSearchRequest(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
limit: Annotated[int, Field(10, ge=1, le=100)]
lang: Literal["en-US"] = "en-US"
"""
The language to be used for text-only search. Support for other languages coming soon.
"""
text: str
"""
Text to use in the search.
"""


class VectorDocSearchRequest(BaseDocSearchRequest):
class VectorDocSearchRequest(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
limit: Annotated[int, Field(10, ge=1, le=100)]
lang: Literal["en-US"] = "en-US"
"""
The language to be used for text-only search. Support for other languages coming soon.
"""
confidence: Annotated[float, Field(0.5, ge=0.0, le=1.0)]
"""
The confidence cutoff level
Expand Down
23 changes: 20 additions & 3 deletions agents-api/agents_api/autogen/Entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@

from pydantic import AwareDatetime, BaseModel, ConfigDict, Field, RootModel

from .Tools import ChosenToolCall, Tool, ToolResponse
from .Tools import (
ChosenApiCall,
ChosenFunctionCall,
ChosenIntegrationCall,
ChosenSystemCall,
Tool,
ToolResponse,
)


class BaseEntry(BaseModel):
Expand All @@ -31,11 +38,21 @@ class BaseEntry(BaseModel):
content: (
list[Content | ContentModel]
| Tool
| ChosenToolCall
| ChosenFunctionCall
| ChosenIntegrationCall
| ChosenSystemCall
| ChosenApiCall
| str
| ToolResponse
| list[
list[Content | ContentModel] | Tool | ChosenToolCall | str | ToolResponse
list[Content | ContentModel]
| Tool
| ChosenFunctionCall
| ChosenIntegrationCall
| ChosenSystemCall
| ChosenApiCall
| str
| ToolResponse
]
)
source: Literal[
Expand Down
49 changes: 36 additions & 13 deletions agents-api/agents_api/autogen/Executions.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,42 @@ class TaskTokenResumeExecutionRequest(BaseModel):
"""


class Transition(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
type: Annotated[
Literal[
"init",
"init_branch",
"finish",
"finish_branch",
"wait",
"resume",
"error",
"step",
"cancelled",
],
Field(json_schema_extra={"readOnly": True}),
]
output: Annotated[Any, Field(json_schema_extra={"readOnly": True})]
created_at: Annotated[AwareDatetime, Field(json_schema_extra={"readOnly": True})]
"""
When this resource was created as UTC date-time
"""
updated_at: Annotated[AwareDatetime, Field(json_schema_extra={"readOnly": True})]
"""
When this resource was updated as UTC date-time
"""
execution_id: Annotated[UUID, Field(json_schema_extra={"readOnly": True})]
current: Annotated[TransitionTarget, Field(json_schema_extra={"readOnly": True})]
next: Annotated[
TransitionTarget | None, Field(json_schema_extra={"readOnly": True})
]
id: Annotated[UUID, Field(json_schema_extra={"readOnly": True})]
metadata: dict[str, Any] | None = None


class TransitionEvent(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
Expand Down Expand Up @@ -173,16 +209,3 @@ class StopExecutionRequest(UpdateExecutionRequest):
"""
The reason for stopping the execution
"""


class Transition(TransitionEvent):
model_config = ConfigDict(
populate_by_name=True,
)
execution_id: Annotated[UUID, Field(json_schema_extra={"readOnly": True})]
current: Annotated[TransitionTarget, Field(json_schema_extra={"readOnly": True})]
next: Annotated[
TransitionTarget | None, Field(json_schema_extra={"readOnly": True})
]
id: Annotated[UUID, Field(json_schema_extra={"readOnly": True})]
metadata: dict[str, Any] | None = None
19 changes: 17 additions & 2 deletions agents-api/agents_api/autogen/Tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
TextOnlyDocSearchRequest,
VectorDocSearchRequest,
)
from .Tools import CreateToolRequest
from .Tools import FunctionDef


class CaseThen(BaseModel):
Expand Down Expand Up @@ -686,14 +686,29 @@ class Task(BaseModel):
metadata: dict[str, Any] | None = None


class TaskTool(CreateToolRequest):
class TaskTool(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
inherited: Annotated[StrictBool, Field(False, json_schema_extra={"readOnly": True})]
"""
Read-only: Whether the tool was inherited or not. Only applies within tasks.
"""
type: Literal["function", "integration", "system", "api_call"] = "function"
"""
Whether this tool is a `function`, `api_call`, `system` etc. (Only `function` tool supported right now)The type of the tool
"""
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 )
"""
function: FunctionDef
"""
The function to call
"""
integration: Any | None = None
system: Any | None = None
api_call: Any | None = None


class ToolCallStep(BaseModel):
Expand Down
64 changes: 24 additions & 40 deletions agents-api/agents_api/autogen/Tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,43 @@
from pydantic import AwareDatetime, BaseModel, ConfigDict, Field


class ChosenToolCall(BaseModel):
"""
The response tool value generated by the model
"""
class ChosenApiCall(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
type: Literal["api_call"] = "api_call"
api_call: Any
id: Annotated[UUID, Field(json_schema_extra={"readOnly": True})]


class ChosenFunctionCall(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
type: Literal["function", "integration", "system", "api_call"]
type: Literal["function"] = "function"
function: FunctionCallOption
"""
Whether this tool is a `function`, `api_call`, `system` etc. (Only `function` tool supported right now)
The function to call
"""
function: FunctionCallOption | None = None
integration: Any | None = None
system: Any | None = None
api_call: Any | None = None
id: Annotated[UUID, Field(json_schema_extra={"readOnly": True})]


class CreateToolRequest(BaseModel):
"""
Payload for creating a tool
"""
class ChosenIntegrationCall(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
type: Literal["integration"] = "integration"
integration: Any
id: Annotated[UUID, Field(json_schema_extra={"readOnly": True})]


class ChosenSystemCall(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
type: Literal["function", "integration", "system", "api_call"] = "function"
"""
Whether this tool is a `function`, `api_call`, `system` etc. (Only `function` tool supported right now)The type of the tool
"""
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 )
"""
function: FunctionDef
"""
The function to call
"""
integration: Any | None = None
system: Any | None = None
api_call: Any | None = None
type: Literal["system"] = "system"
system: Any
id: Annotated[UUID, Field(json_schema_extra={"readOnly": True})]


class FunctionCallOption(BaseModel):
Expand Down Expand Up @@ -212,14 +207,3 @@ class UpdateToolRequest(BaseModel):
integration: Any | None = None
system: Any | None = None
api_call: Any | None = None


class ChosenFunctionCall(ChosenToolCall):
model_config = ConfigDict(
populate_by_name=True,
)
type: Literal["function"] = "function"
function: FunctionCallOption
"""
The function to call
"""
4 changes: 4 additions & 0 deletions agents-api/agents_api/autogen/openapi_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class InputChatMLMessage(Message):
pass


ChosenToolCall = (
ChosenIntegrationCall | ChosenApiCall | ChosenFunctionCall | ChosenSystemCall
)

# Custom types (not generated correctly)
# --------------------------------------

Expand Down
Loading

0 comments on commit aedba24

Please sign in to comment.