Skip to content

Commit

Permalink
feat: Rewrite expression types
Browse files Browse the repository at this point in the history
  • Loading branch information
whiterabbit1983 committed Nov 27, 2024
1 parent 32bd599 commit f9f2308
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 205 deletions.
36 changes: 6 additions & 30 deletions agents-api/agents_api/autogen/Tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class EvaluateStep(BaseModel):
"""
The label of this step for referencing it from other steps
"""
evaluate: dict[str, list[str] | dict[str, str] | list[dict[str, str]] | str]
evaluate: dict[str, Any]
"""
The expression to evaluate
"""
Expand Down Expand Up @@ -837,10 +837,7 @@ class ReturnStep(BaseModel):
"""
The label of this step for referencing it from other steps
"""
return_: Annotated[
dict[str, list[str] | dict[str, str] | list[dict[str, str]] | str],
Field(alias="return"),
]
return_: Annotated[dict[str, Any], Field(alias="return")]
"""
The value to return
"""
Expand All @@ -860,7 +857,7 @@ class SetStep(BaseModel):
"""
The label of this step for referencing it from other steps
"""
set: dict[str, str]
set: dict[str, Any]
"""
The value to set
"""
Expand Down Expand Up @@ -1046,25 +1043,7 @@ class ToolCallStep(BaseModel):
"""
The tool to run
"""
arguments: (
dict[
str,
dict[str, list[str] | dict[str, str] | list[dict[str, str]] | str]
| list[dict[str, list[str] | dict[str, str] | list[dict[str, str]] | str]]
| str,
]
| list[
dict[
str,
dict[str, list[str] | dict[str, str] | list[dict[str, str]] | str]
| list[
dict[str, list[str] | dict[str, str] | list[dict[str, str]] | str]
]
| str,
]
]
| Literal["_"]
) = "_"
arguments: dict[str, Any] | Literal["_"] = "_"
"""
The input parameters for the tool (defaults to last step output)
"""
Expand Down Expand Up @@ -1168,7 +1147,7 @@ class WaitForInputInfo(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
info: dict[str, list[str] | dict[str, str] | list[dict[str, str]] | str]
info: dict[str, Any]
"""
Any additional info or data
"""
Expand Down Expand Up @@ -1213,10 +1192,7 @@ class YieldStep(BaseModel):
The subworkflow to run.
VALIDATION: Should resolve to a defined subworkflow.
"""
arguments: (
dict[str, list[str] | dict[str, str] | list[dict[str, str]] | str]
| Literal["_"]
) = "_"
arguments: dict[str, Any] | Literal["_"] = "_"
"""
The input parameters for the subworkflow (defaults to last step output)
"""
36 changes: 6 additions & 30 deletions integrations-service/integrations/autogen/Tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class EvaluateStep(BaseModel):
"""
The label of this step for referencing it from other steps
"""
evaluate: dict[str, list[str] | dict[str, str] | list[dict[str, str]] | str]
evaluate: dict[str, Any]
"""
The expression to evaluate
"""
Expand Down Expand Up @@ -838,10 +838,7 @@ class ReturnStep(BaseModel):
"""
The label of this step for referencing it from other steps
"""
return_: Annotated[
dict[str, list[str] | dict[str, str] | list[dict[str, str]] | str],
Field(alias="return"),
]
return_: Annotated[dict[str, Any], Field(alias="return")]
"""
The value to return
"""
Expand All @@ -861,7 +858,7 @@ class SetStep(BaseModel):
"""
The label of this step for referencing it from other steps
"""
set: dict[str, str]
set: dict[str, Any]
"""
The value to set
"""
Expand Down Expand Up @@ -1047,25 +1044,7 @@ class ToolCallStep(BaseModel):
"""
The tool to run
"""
arguments: (
dict[
str,
dict[str, list[str] | dict[str, str] | list[dict[str, str]] | str]
| list[dict[str, list[str] | dict[str, str] | list[dict[str, str]] | str]]
| str,
]
| list[
dict[
str,
dict[str, list[str] | dict[str, str] | list[dict[str, str]] | str]
| list[
dict[str, list[str] | dict[str, str] | list[dict[str, str]] | str]
]
| str,
]
]
| Literal["_"]
) = "_"
arguments: dict[str, Any] | Literal["_"] = "_"
"""
The input parameters for the tool (defaults to last step output)
"""
Expand Down Expand Up @@ -1169,7 +1148,7 @@ class WaitForInputInfo(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
info: dict[str, list[str] | dict[str, str] | list[dict[str, str]] | str]
info: dict[str, Any]
"""
Any additional info or data
"""
Expand Down Expand Up @@ -1214,10 +1193,7 @@ class YieldStep(BaseModel):
The subworkflow to run.
VALIDATION: Should resolve to a defined subworkflow.
"""
arguments: (
dict[str, list[str] | dict[str, str] | list[dict[str, str]] | str]
| Literal["_"]
) = "_"
arguments: dict[str, Any] | Literal["_"] = "_"
"""
The input parameters for the subworkflow (defaults to last step output)
"""
20 changes: 6 additions & 14 deletions typespec/tasks/steps.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ alias TypedExpression<T> = PyExpression;
/** A python expression that takes an accumulator `results` and an input item `_` and reduces them. */
alias ReduceExpression<Value = unknown, Accumulator = Array<Value>> = TypedExpression<Accumulator>;

/** A string->string object where the values are python expressions that get evaluated to give a final object. */
alias ExpressionObject<T> = Record<TypedExpression<T> | TypedExpression<T>[] | Record<TypedExpression<T>> | Record<TypedExpression<T>>[]>;

alias NestedExpression<T> = Record<TypedExpression<T> | ExpressionObject<T> | ExpressionObject<T>[]>;

/** Nested expression object. */
alias NestedExpressionObject<T> = NestedExpression<T> | NestedExpression<T>[];

@discriminator("kind_")
model BaseWorkflowStep<T extends valueof WorkflowStepKind> {
/** The kind of step */
Expand Down Expand Up @@ -88,7 +80,7 @@ model ToolCallStepDef {
tool: validPythonIdentifier;

/** The input parameters for the tool (defaults to last step output) */
arguments: NestedExpressionObject<unknown> | "_" = "_";
arguments: Record<unknown> | "_" = "_";
}

model PromptStep extends BaseWorkflowStep<"prompt"> {
Expand Down Expand Up @@ -134,7 +126,7 @@ model EvaluateStep extends BaseWorkflowStep<"evaluate"> {

model EvaluateStepDef {
/** The expression to evaluate */
evaluate: ExpressionObject<unknown>;
evaluate: Record<unknown>;
}

model WaitForInputStep extends BaseWorkflowStep<"wait_for_input"> {
Expand All @@ -146,7 +138,7 @@ model WaitForInputStep extends BaseWorkflowStep<"wait_for_input"> {

model WaitForInputInfo {
/** Any additional info or data */
info: ExpressionObject<unknown>;
info: Record<unknown>;
}

model WaitForInputStepDef {
Expand Down Expand Up @@ -191,7 +183,7 @@ model SetStep extends BaseWorkflowStep<"set"> {

model SetStepDef {
/** The value to set */
set: Record<TypedExpression<unknown>>;
set: Record<unknown>;
}

///////////////////////
Expand Down Expand Up @@ -317,7 +309,7 @@ model YieldStepDef {
workflow: string;

/** The input parameters for the subworkflow (defaults to last step output) */
arguments: ExpressionObject<unknown> | "_" = "_";
arguments: Record<unknown> | "_" = "_";
}

model ErrorWorkflowStep extends BaseWorkflowStep<"error"> {
Expand Down Expand Up @@ -375,5 +367,5 @@ model ReturnStep extends BaseWorkflowStep<"return"> {

model ReturnStepDef {
/** The value to return */
`return`: ExpressionObject<unknown>;
`return`: Record<unknown>;
}
Loading

0 comments on commit f9f2308

Please sign in to comment.