Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Misc improvements to types and stdlib in jinja #788

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions agents-api/agents_api/activities/task_steps/prompt_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,23 @@
COMPUTER_USE_BETA_FLAG = "computer-use-2024-10-22"


# FIXME: This shouldn't be here.
def format_agent_tool(tool: Tool) -> dict:
if tool.type == "function":
return {
"type": "function",
"function": {
"name": tool.name,
"description": tool.description,
"parameters": tool.parameters,
"parameters": tool.function.parameters,
},
}
elif tool.type == "computer_20241022":
return {
"type": tool.type,
"name": tool.name,
"display_width_px": tool.spec["display_width_px"],
"display_height_px": tool.spec["display_height_px"],
"display_number": tool.spec["display_number"],
"display_width_px": tool.computer_20241022.display_width_px,
"display_height_px": tool.computer_20241022.display_height_px,
"display_number": tool.computer_20241022.display_number,
}
elif tool.type == "bash_20241022":
return {
Expand Down
5 changes: 5 additions & 0 deletions agents-api/agents_api/activities/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
"search_regex": lambda pattern, string: re2.search(pattern, string),
"load_json": json.loads,
"load_yaml": yaml.load,
"dump_json": json.dumps,
"dump_yaml": yaml.dump,
"match_regex": lambda pattern, string: bool(re2.fullmatch(pattern, string)),
}

Expand Down Expand Up @@ -203,6 +205,9 @@ class stdlib_statistics:

constants = {
"NEWLINE": "\n",
"true": True,
"false": False,
"null": None,
}


Expand Down
106 changes: 97 additions & 9 deletions agents-api/agents_api/autogen/Tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ class CreateTaskRequest(BaseModel):
"""
Tools defined specifically for this task not included in the Agent itself.
"""
inherit_tools: StrictBool = True
inherit_tools: StrictBool = False
"""
Whether to inherit tools from the parent agent or not. Defaults to true.
Whether to inherit tools from the parent agent or not. Defaults to false.
"""
metadata: dict[str, Any] | None = None

Expand All @@ -159,6 +159,10 @@ class ErrorWorkflowStep(BaseModel):
"""
The kind of step
"""
label: str | None = None
"""
The label of this step for referencing it from other steps
"""
error: str
"""
The error message
Expand All @@ -175,6 +179,10 @@ class EvaluateStep(BaseModel):
"""
The kind of step
"""
label: str | None = None
"""
The label of this step for referencing it from other steps
"""
evaluate: dict[str, str]
"""
The expression to evaluate
Expand Down Expand Up @@ -239,6 +247,10 @@ class ForeachStep(BaseModel):
"""
The kind of step
"""
label: str | None = None
"""
The label of this step for referencing it from other steps
"""
foreach: ForeachDo
"""
The steps to run for each iteration
Expand All @@ -249,6 +261,10 @@ class ForeachStepUpdateItem(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
label: str | None = None
"""
The label of this step for referencing it from other steps
"""
kind_: str | None = None
"""
Discriminator property for BaseWorkflowStep.
Expand All @@ -269,6 +285,10 @@ class GetStep(BaseModel):
"""
The kind of step
"""
label: str | None = None
"""
The label of this step for referencing it from other steps
"""
get: str
"""
The key to get
Expand All @@ -285,6 +305,10 @@ class IfElseWorkflowStep(BaseModel):
"""
The kind of step
"""
label: str | None = None
"""
The label of this step for referencing it from other steps
"""
if_: Annotated[str, Field(alias="if")]
"""
The condition to evaluate
Expand Down Expand Up @@ -329,6 +353,10 @@ class IfElseWorkflowStepUpdateItem(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
label: str | None = None
"""
The label of this step for referencing it from other steps
"""
kind_: str | None = None
"""
Discriminator property for BaseWorkflowStep.
Expand Down Expand Up @@ -401,6 +429,10 @@ class LogStep(BaseModel):
"""
The kind of step
"""
label: str | None = None
"""
The label of this step for referencing it from other steps
"""
log: str
"""
The value to log
Expand All @@ -417,6 +449,10 @@ class Main(BaseModel):
"""
The kind of step
"""
label: str | None = None
"""
The label of this step for referencing it from other steps
"""
over: str
"""
The variable to iterate over
Expand Down Expand Up @@ -453,6 +489,10 @@ class MainModel(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
label: str | None = None
"""
The label of this step for referencing it from other steps
"""
kind_: str | None = None
"""
Discriminator property for BaseWorkflowStep.
Expand Down Expand Up @@ -499,6 +539,10 @@ class ParallelStep(BaseModel):
"""
The kind of step
"""
label: str | None = None
"""
The label of this step for referencing it from other steps
"""
parallel: Annotated[
list[
EvaluateStep
Expand All @@ -520,6 +564,10 @@ class ParallelStepUpdateItem(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
label: str | None = None
"""
The label of this step for referencing it from other steps
"""
kind_: str | None = None
"""
Discriminator property for BaseWorkflowStep.
Expand Down Expand Up @@ -583,9 +631,9 @@ class PatchTaskRequest(BaseModel):
"""
Tools defined specifically for this task not included in the Agent itself.
"""
inherit_tools: StrictBool = True
inherit_tools: StrictBool = False
"""
Whether to inherit tools from the parent agent or not. Defaults to true.
Whether to inherit tools from the parent agent or not. Defaults to false.
"""
metadata: dict[str, Any] | None = None

Expand Down Expand Up @@ -630,6 +678,10 @@ class PromptStep(BaseModel):
"""
The kind of step
"""
label: str | None = None
"""
The label of this step for referencing it from other steps
"""
prompt: list[PromptItem] | str
"""
The prompt to run
Expand Down Expand Up @@ -666,6 +718,10 @@ class PromptStepUpdateItem(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
label: str | None = None
"""
The label of this step for referencing it from other steps
"""
kind_: str | None = None
"""
Discriminator property for BaseWorkflowStep.
Expand Down Expand Up @@ -712,6 +768,10 @@ class ReturnStep(BaseModel):
"""
The kind of step
"""
label: str | None = None
"""
The label of this step for referencing it from other steps
"""
return_: Annotated[dict[str, str], Field(alias="return")]
"""
The value to return
Expand All @@ -728,6 +788,10 @@ class SetStep(BaseModel):
"""
The kind of step
"""
label: str | None = None
"""
The label of this step for referencing it from other steps
"""
set: dict[str, str]
"""
The value to set
Expand Down Expand Up @@ -766,6 +830,10 @@ class SleepStep(BaseModel):
"""
The kind of step
"""
label: str | None = None
"""
The label of this step for referencing it from other steps
"""
sleep: SleepFor
"""
The duration to sleep for (max 31 days)
Expand All @@ -782,6 +850,10 @@ class SwitchStep(BaseModel):
"""
The kind of step
"""
label: str | None = None
"""
The label of this step for referencing it from other steps
"""
switch: Annotated[list[CaseThen], Field(min_length=1)]
"""
The cond tree
Expand All @@ -792,6 +864,10 @@ class SwitchStepUpdateItem(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
label: str | None = None
"""
The label of this step for referencing it from other steps
"""
kind_: str | None = None
"""
Discriminator property for BaseWorkflowStep.
Expand Down Expand Up @@ -844,9 +920,9 @@ class Task(BaseModel):
"""
Tools defined specifically for this task not included in the Agent itself.
"""
inherit_tools: StrictBool = True
inherit_tools: StrictBool = False
"""
Whether to inherit tools from the parent agent or not. Defaults to true.
Whether to inherit tools from the parent agent or not. Defaults to false.
"""
id: Annotated[UUID, Field(json_schema_extra={"readOnly": True})]
created_at: Annotated[AwareDatetime, Field(json_schema_extra={"readOnly": True})]
Expand Down Expand Up @@ -882,6 +958,10 @@ class ToolCallStep(BaseModel):
"""
The kind of step
"""
label: str | None = None
"""
The label of this step for referencing it from other steps
"""
tool: Annotated[str, Field(max_length=40, pattern="^[^\\W0-9]\\w*$")]
"""
The tool to run
Expand Down Expand Up @@ -911,7 +991,7 @@ class ToolRefById(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
id: UUID | None = None
id: str | None = None


class ToolRefByName(BaseModel):
Expand Down Expand Up @@ -979,9 +1059,9 @@ class UpdateTaskRequest(BaseModel):
"""
Tools defined specifically for this task not included in the Agent itself.
"""
inherit_tools: StrictBool = True
inherit_tools: StrictBool = False
"""
Whether to inherit tools from the parent agent or not. Defaults to true.
Whether to inherit tools from the parent agent or not. Defaults to false.
"""
metadata: dict[str, Any] | None = None

Expand All @@ -1006,6 +1086,10 @@ class WaitForInputStep(BaseModel):
"""
The kind of step
"""
label: str | None = None
"""
The label of this step for referencing it from other steps
"""
wait_for_input: WaitForInputInfo
"""
Any additional info or data
Expand All @@ -1022,6 +1106,10 @@ class YieldStep(BaseModel):
"""
The kind of step
"""
label: str | None = None
"""
The label of this step for referencing it from other steps
"""
workflow: str
"""
The subworkflow to run.
Expand Down
10 changes: 9 additions & 1 deletion agents-api/agents_api/autogen/Tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class ApiCallDef(BaseModel):
"""
The URL to call
"""
schema_: Annotated[dict[str, Any] | None, Field(alias="schema")] = None
"""
The schema of the response
"""
headers: dict[str, str] | None = None
"""
The headers to send with the request
Expand Down Expand Up @@ -98,6 +102,10 @@ class ApiCallDefUpdate(BaseModel):
"""
The URL to call
"""
schema_: Annotated[dict[str, Any] | None, Field(alias="schema")] = None
"""
The schema of the response
"""
headers: dict[str, str] | None = None
"""
The headers to send with the request
Expand Down Expand Up @@ -1477,7 +1485,7 @@ class ToolResponse(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
id: UUID
id: str
output: dict[str, Any]
"""
The output of the tool
Expand Down
Loading
Loading