Skip to content

Commit

Permalink
Merge pull request #1040 from julep-ai/dev
Browse files Browse the repository at this point in the history
dev -> main
  • Loading branch information
whiterabbit1983 authored Jan 11, 2025
2 parents 2ae5fe1 + 0509485 commit 1be5357
Show file tree
Hide file tree
Showing 522 changed files with 23,673 additions and 23,399 deletions.
3 changes: 1 addition & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ GOOGLE_APPLICATION_CREDENTIALS=.keys/julep-vertexai-svc.json
### > Set to either "voyage/voyage-3" or "Alibaba-NLP/gte-large-en-v1.5"
### > Use Alibaba-NLP/gte-large-en-v1.5 with local embedding server

EMBEDDING_MODEL_ID=voyage/voyage-3
EMBEDDING_MODEL_ID=Alibaba-NLP/gte-large-en-v1.5
EMBEDDING_MODEL_ID=openai/text-embedding-3-large

AGENTS_API_HOSTNAME=localhost
AGENTS_API_PROTOCOL=http
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/lint-agents-api-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ jobs:
uses: astral-sh/setup-uv@v4
with:
enable-cache: true

- name: Install Go migrate
uses: jaxxstorm/[email protected]
with: # Grab the latest version
repo: golang-migrate/migrate

- name: Set up python and install dependencies
run: |
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/test-agents-api-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ jobs:
uses: astral-sh/setup-uv@v4
with:
enable-cache: true

- name: Install Go migrate
uses: jaxxstorm/[email protected]
with: # Grab the latest version
repo: golang-migrate/migrate

- name: Set up python and install dependencies
run: |
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/typecheck-agents-api-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ jobs:
uses: astral-sh/setup-uv@v4
with:
enable-cache: true

- name: Install Go migrate
uses: jaxxstorm/[email protected]
with: # Grab the latest version
repo: golang-migrate/migrate

- name: Set up python and install dependencies
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ ngrok*
*/node_modules/
.aider*
.vscode/
schema.sql
3 changes: 2 additions & 1 deletion agents-api/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
notebooks/

# Local database files
cozo.db
temporal.db
*.bak
*.dat
Expand Down
2 changes: 1 addition & 1 deletion agents-api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ COPY . ./
ENV PYTHONUNBUFFERED=1
ENV GUNICORN_CMD_ARGS="--capture-output --enable-stdio-inheritance"

ENTRYPOINT ["uv", "run", "gunicorn", "agents_api.web:app", "-c", "gunicorn_conf.py"]
ENTRYPOINT ["uv", "run", "--offline", "--no-sync", "gunicorn", "agents_api.web:app", "-c", "gunicorn_conf.py"]
22 changes: 0 additions & 22 deletions agents-api/Dockerfile.migration

This file was deleted.

2 changes: 1 addition & 1 deletion agents-api/Dockerfile.worker
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ COPY . ./
ENV PYTHONUNBUFFERED=1
ENV GUNICORN_CMD_ARGS="--capture-output --enable-stdio-inheritance"

ENTRYPOINT ["uv", "run", "python", "-m", "agents_api.worker"]
ENTRYPOINT ["uv", "run", "--offline", "--no-sync", "python", "-m", "agents_api.worker"]
7 changes: 3 additions & 4 deletions agents-api/agents_api/activities/demo.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
from typing import Callable

from temporalio import activity

from ..env import testing


async def demo_activity(a: int, b: int) -> int:
# Should throw an error if testing is not enabled
raise Exception("This should not be called in production")
msg = "This should not be called in production"
raise Exception(msg)


async def mock_demo_activity(a: int, b: int) -> int:
return a + b


demo_activity: Callable[[int, int], int] = activity.defn(name="demo_activity")(
demo_activity = activity.defn(name="demo_activity")(
demo_activity if not testing else mock_demo_activity
)
75 changes: 0 additions & 75 deletions agents-api/agents_api/activities/embed_docs.py

This file was deleted.

18 changes: 8 additions & 10 deletions agents-api/agents_api/activities/excecute_api_call.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
import base64
from typing import Any, Optional, TypedDict, Union
from typing import Any, TypedDict

import httpx
from beartype import beartype
from temporalio import activity

from ..autogen.openapi_model import ApiCallDef
from ..common.storage_handler import auto_blob_store
from ..env import testing


class RequestArgs(TypedDict):
content: Optional[str]
data: Optional[dict[str, Any]]
json_: Optional[dict[str, Any]]
cookies: Optional[dict[str, str]]
params: Optional[Union[str, dict[str, Any]]]
url: Optional[str]
headers: Optional[dict[str, str]]
content: str | None
data: dict[str, Any] | None
json_: dict[str, Any] | None
cookies: dict[str, str] | None
params: str | dict[str, Any] | None
url: str | None
headers: dict[str, str] | None


@auto_blob_store(deep=True)
@beartype
async def execute_api_call(
api_call: ApiCallDef,
Expand Down
42 changes: 24 additions & 18 deletions agents-api/agents_api/activities/execute_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
from beartype import beartype
from temporalio import activity

from ..app import app
from ..autogen.openapi_model import BaseIntegrationDef
from ..clients import integrations
from ..common.exceptions.tools import IntegrationExecutionException
from ..common.protocol.tasks import ExecutionInput, StepContext
from ..common.storage_handler import auto_blob_store
from ..env import testing
from ..models.tools import get_tool_args_from_metadata
from ..queries import tools


@auto_blob_store(deep=True)
@beartype
async def execute_integration(
context: StepContext,
Expand All @@ -22,23 +21,35 @@ async def execute_integration(
setup: dict[str, Any] = {},
) -> Any:
if not isinstance(context.execution_input, ExecutionInput):
raise TypeError("Expected ExecutionInput type for context.execution_input")
msg = "Expected ExecutionInput type for context.execution_input"
raise TypeError(msg)

developer_id = context.execution_input.developer_id
agent_id = context.execution_input.agent.id

if context.execution_input.task is None:
msg = "Task cannot be None in execution_input"
raise ValueError(msg)

task_id = context.execution_input.task.id

merged_tool_args = get_tool_args_from_metadata(
developer_id=developer_id, agent_id=agent_id, task_id=task_id, arg_type="args"
merged_tool_args = await tools.get_tool_args_from_metadata(
developer_id=developer_id,
agent_id=agent_id,
task_id=task_id,
arg_type="args",
connection_pool=app.state.postgres_pool,
)

merged_tool_setup = get_tool_args_from_metadata(
developer_id=developer_id, agent_id=agent_id, task_id=task_id, arg_type="setup"
merged_tool_setup = await tools.get_tool_args_from_metadata(
developer_id=developer_id,
agent_id=agent_id,
task_id=task_id,
arg_type="setup",
connection_pool=app.state.postgres_pool,
)

arguments = (
merged_tool_args.get(tool_name, {}) | (integration.arguments or {}) | arguments
)
arguments = merged_tool_args.get(tool_name, {}) | (integration.arguments or {}) | arguments

setup = merged_tool_setup.get(tool_name, {}) | (integration.setup or {}) | setup

Expand All @@ -53,10 +64,7 @@ async def execute_integration(
arguments=arguments,
)

if (
"error" in integration_service_response
and integration_service_response["error"]
):
if integration_service_response.get("error"):
raise IntegrationExecutionException(
integration=integration,
error=integration_service_response["error"],
Expand All @@ -69,9 +77,7 @@ async def execute_integration(
integration_str = integration.provider + (
"." + integration.method if integration.method else ""
)
activity.logger.error(
f"Error in execute_integration {integration_str}: {e}"
)
activity.logger.error(f"Error in execute_integration {integration_str}: {e}")

raise

Expand Down
Loading

0 comments on commit 1be5357

Please sign in to comment.