Skip to content

Commit

Permalink
feat: Add TODOs and fix typescript generated code
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 3, 2024
1 parent aabb24f commit 984c813
Show file tree
Hide file tree
Showing 28 changed files with 140 additions and 105 deletions.
1 change: 1 addition & 0 deletions .github/workflows/changelog-ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Changelog CI

# TODO: This is currently not working. Need to fix it
on:
pull_request:
types: [ opened, synchronize ]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/generate-docs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Generate docs on merge to dev
run-name: ${{ github.actor }} is generating documentation

# TODO: This is currently not working. Need to fix it
on:
push:
branches:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lint-and-format.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Lint and typecheck APIs and SDKs
run-name: ${{ github.actor }} is linting and typechecking the code

# TODO: This is currently not working. Need to fix it
on: [pull_request]

jobs:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/push-to-hub.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Build and push images to docker hub on merge to dev
run-name: ${{ github.actor }} is building and pushing images to docker hub

# TODO: This is currently not working. Need to fix it
on:
push:
branches:
Expand Down
1 change: 1 addition & 0 deletions agents-api/agents_api/activities/task_steps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .cozo_query_step import cozo_query_step
from .evaluate_step import evaluate_step
from .for_each_step import for_each_step
from .get_value_step import get_value_step
from .if_else_step import if_else_step
from .log_step import log_step
from .map_reduce_step import map_reduce_step
Expand Down
26 changes: 26 additions & 0 deletions agents-api/agents_api/activities/task_steps/get_value_step.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from typing import Any

from beartype import beartype
from temporalio import activity

from ...activities.utils import simple_eval_dict
from ...common.protocol.tasks import StepContext, StepOutcome
from ...env import testing


# TODO: We should use this step to query the parent workflow and get the value from the workflow context
@beartype
async def get_value_step(
context: StepContext,
key: str,
) -> StepOutcome:
raise NotImplementedError("Not implemented yet")


# Note: This is here just for clarity. We could have just imported get_value_step directly
# They do the same thing, so we dont need to mock the get_value_step function
mock_get_value_step = get_value_step

get_value_step = activity.defn(name="get_value_step")(
get_value_step if not testing else mock_get_value_step
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from ...env import testing


# TODO: We should use this step to signal to the parent workflow and set the value on the workflow context
@beartype
async def set_value_step(
context: StepContext,
Expand Down
4 changes: 2 additions & 2 deletions agents-api/agents_api/autogen/Chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from .Common import LogitBias
from .Docs import DocReference
from .Tools import FunctionTool, NamedToolChoice
from .Tools import NamedToolChoice, Tool


class BaseChatOutput(BaseModel):
Expand Down Expand Up @@ -71,7 +71,7 @@ class ChatInputData(BaseModel):
"""
A list of new input messages comprising the conversation so far.
"""
tools: list[FunctionTool] = []
tools: list[Tool] = []
"""
(Advanced) List of tools that are provided in addition to agent's default set of tools.
"""
Expand Down
42 changes: 23 additions & 19 deletions agents-api/agents_api/autogen/Tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,19 @@ class CreateToolRequest(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
type: Literal["function", "integration", "system", "api_call"]
type: Literal["function", "integration", "system", "api_call"] = "function"
"""
Whether this tool is a `function`, `api_call`, `system` etc. (Only `function` tool supported right now)
"""
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 | None = None
background: Literal[False] = False
function: FunctionDef
"""
The function to call
"""
integration: Any | None = None
system: Any | None = None
api_call: Any | None = None
Expand Down Expand Up @@ -111,15 +115,19 @@ class PatchToolRequest(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
type: Literal["function", "integration", "system", "api_call"] | None = None
type: Literal["function", "integration", "system", "api_call"] = "function"
"""
Whether this tool is a `function`, `api_call`, `system` etc. (Only `function` tool supported right now)
"""
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 )
"""
background: Literal[False] = False
function: FunctionDef | None = None
"""
The function to call
"""
integration: Any | None = None
system: Any | None = None
api_call: Any | None = None
Expand All @@ -129,15 +137,19 @@ class Tool(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
type: Literal["function", "integration", "system", "api_call"]
type: Literal["function", "integration", "system", "api_call"] = "function"
"""
Whether this tool is a `function`, `api_call`, `system` etc. (Only `function` tool supported right now)
"""
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 | None = None
background: Literal[False] = False
function: FunctionDef
"""
The function to call
"""
integration: Any | None = None
system: Any | None = None
api_call: Any | None = None
Expand Down Expand Up @@ -171,15 +183,19 @@ class UpdateToolRequest(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
type: Literal["function", "integration", "system", "api_call"]
type: Literal["function", "integration", "system", "api_call"] = "function"
"""
Whether this tool is a `function`, `api_call`, `system` etc. (Only `function` tool supported right now)
"""
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 | None = None
background: Literal[False] = False
function: FunctionDef
"""
The function to call
"""
integration: Any | None = None
system: Any | None = None
api_call: Any | None = None
Expand All @@ -196,18 +212,6 @@ class ChosenFunctionCall(ChosenToolCall):
"""


class FunctionTool(Tool):
model_config = ConfigDict(
populate_by_name=True,
)
type: Literal["function"] = "function"
background: Literal[False] = False
function: FunctionDef
"""
The function to call
"""


class NamedFunctionChoice(NamedToolChoice):
model_config = ConfigDict(
populate_by_name=True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async def event_publisher(
async with inner_send_chan:
try:
async for event in history_events:
# TODO: We should get the workflow-completed event as well and use that to close the stream
if event.event_type == EventType.EVENT_TYPE_ACTIVITY_TASK_COMPLETED:
payloads = (
event.activity_task_completed_event_attributes.result.payloads
Expand All @@ -51,7 +52,6 @@ async def event_publisher(
continue

# FIXME: This does NOT return the last event (and maybe other events)
# Need to fix this. I think we need to grab events from child workflows too
transition_event_dict = dict(
type=data_item.type,
output=data_item.output,
Expand Down Expand Up @@ -92,6 +92,7 @@ async def stream_transitions_events(
execution_id=execution_id,
)

# TODO: Need to get all the events for child workflows too. Maybe try the `run_id` or something?
workflow_handle = await get_workflow_handle(
handle_id=temporal_data["id"],
)
Expand Down
6 changes: 3 additions & 3 deletions agents-api/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions embedding-service/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ x--shared-environment: &shared-environment
TRUNCATE_EMBED_TEXT: ${TRUNCATE_EMBED_TEXT:-True}
WORKER_URL: ${WORKER_URL:-temporal:7233}

# TODO: We should switch to Alibaba-NLP/gte-Qwen2-1.5B-instruct instead of gte-large-en-v1.5

services:
text-embeddings-inference-cpu:
Expand Down
6 changes: 3 additions & 3 deletions sdks/python/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions sdks/ts/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ export type { Tools_ChosenToolCall } from "./models/Tools_ChosenToolCall";
export type { Tools_CreateToolRequest } from "./models/Tools_CreateToolRequest";
export type { Tools_FunctionCallOption } from "./models/Tools_FunctionCallOption";
export type { Tools_FunctionDef } from "./models/Tools_FunctionDef";
export type { Tools_FunctionTool } from "./models/Tools_FunctionTool";
export type { Tools_NamedFunctionChoice } from "./models/Tools_NamedFunctionChoice";
export type { Tools_NamedToolChoice } from "./models/Tools_NamedToolChoice";
export type { Tools_PatchToolRequest } from "./models/Tools_PatchToolRequest";
Expand Down Expand Up @@ -257,7 +256,6 @@ export { $Tools_ChosenToolCall } from "./schemas/$Tools_ChosenToolCall";
export { $Tools_CreateToolRequest } from "./schemas/$Tools_CreateToolRequest";
export { $Tools_FunctionCallOption } from "./schemas/$Tools_FunctionCallOption";
export { $Tools_FunctionDef } from "./schemas/$Tools_FunctionDef";
export { $Tools_FunctionTool } from "./schemas/$Tools_FunctionTool";
export { $Tools_NamedFunctionChoice } from "./schemas/$Tools_NamedFunctionChoice";
export { $Tools_NamedToolChoice } from "./schemas/$Tools_NamedToolChoice";
export { $Tools_PatchToolRequest } from "./schemas/$Tools_PatchToolRequest";
Expand Down
4 changes: 2 additions & 2 deletions sdks/ts/src/api/models/Chat_ChatInputData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/* tslint:disable */
/* eslint-disable */
import type { Entries_ChatMLRole } from "./Entries_ChatMLRole";
import type { Tools_FunctionTool } from "./Tools_FunctionTool";
import type { Tools_NamedToolChoice } from "./Tools_NamedToolChoice";
import type { Tools_Tool } from "./Tools_Tool";
export type Chat_ChatInputData = {
/**
* A list of new input messages comprising the conversation so far.
Expand All @@ -30,7 +30,7 @@ export type Chat_ChatInputData = {
/**
* (Advanced) List of tools that are provided in addition to agent's default set of tools.
*/
tools: Array<Tools_FunctionTool>;
tools: Array<Tools_Tool>;
/**
* Can be one of existing tools given to the agent earlier or the ones provided in this request.
*/
Expand Down
6 changes: 5 additions & 1 deletion sdks/ts/src/api/models/Tools_CreateToolRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export type Tools_CreateToolRequest = {
* Name of the tool (must be unique for this agent and a valid python identifier string )
*/
name: Common_validPythonIdentifier;
function?: Tools_FunctionDef;
background: boolean;
/**
* The function to call
*/
function: Tools_FunctionDef;
integration?: any;
system?: any;
api_call?: any;
Expand Down
15 changes: 0 additions & 15 deletions sdks/ts/src/api/models/Tools_FunctionTool.ts

This file was deleted.

4 changes: 4 additions & 0 deletions sdks/ts/src/api/models/Tools_PatchToolRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export type Tools_PatchToolRequest = {
* Name of the tool (must be unique for this agent and a valid python identifier string )
*/
name?: Common_validPythonIdentifier;
background?: boolean;
/**
* The function to call
*/
function?: Tools_FunctionDef;
integration?: any;
system?: any;
Expand Down
6 changes: 5 additions & 1 deletion sdks/ts/src/api/models/Tools_Tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ export type Tools_Tool = {
* Name of the tool (must be unique for this agent and a valid python identifier string )
*/
name: Common_validPythonIdentifier;
function?: Tools_FunctionDef;
background: boolean;
/**
* The function to call
*/
function: Tools_FunctionDef;
integration?: any;
system?: any;
api_call?: any;
Expand Down
6 changes: 5 additions & 1 deletion sdks/ts/src/api/models/Tools_UpdateToolRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export type Tools_UpdateToolRequest = {
* Name of the tool (must be unique for this agent and a valid python identifier string )
*/
name: Common_validPythonIdentifier;
function?: Tools_FunctionDef;
background: boolean;
/**
* The function to call
*/
function: Tools_FunctionDef;
integration?: any;
system?: any;
api_call?: any;
Expand Down
2 changes: 1 addition & 1 deletion sdks/ts/src/api/schemas/$Chat_ChatInputData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const $Chat_ChatInputData = {
tools: {
type: "array",
contains: {
type: "Tools_FunctionTool",
type: "Tools_Tool",
},
isRequired: true,
},
Expand Down
13 changes: 12 additions & 1 deletion sdks/ts/src/api/schemas/$Tools_CreateToolRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,19 @@ export const $Tools_CreateToolRequest = {
],
isRequired: true,
},
background: {
type: "boolean",
isRequired: true,
},
function: {
type: "Tools_FunctionDef",
type: "all-of",
description: `The function to call`,
contains: [
{
type: "Tools_FunctionDef",
},
],
isRequired: true,
},
integration: {
properties: {},
Expand Down
Loading

0 comments on commit 984c813

Please sign in to comment.