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

fix(python-sdk): temporarily remove async types #196

Merged
merged 2 commits into from
Apr 16, 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
1 change: 1 addition & 0 deletions agents-api/agents_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
The `agents_api` module serves as the foundation of the agent management system within the `agents-api` project. This module is responsible for defining the structure and capabilities of the API that manages agents. It includes operations such as creating, updating, listing, and deleting agents, as well as managing documents and tools associated with these agents. This file, in particular, acts as a configuration and initialization point for the `agents_api` package, and as per the directive, should not contain any imports.
"""

#################################
## Do NOT put any imports here ##
#################################
6 changes: 2 additions & 4 deletions agents-api/agents_api/activities/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ class ChatML(BaseModel):
token_count: Optional[int] = None


class BaseTask(BaseModel):
...
class BaseTask(BaseModel): ...


class BaseTaskArgs(BaseModel):
...
class BaseTaskArgs(BaseModel): ...


class AddPrinciplesTaskArgs(BaseTaskArgs):
Expand Down
6 changes: 2 additions & 4 deletions agents-api/agents_api/clients/worker/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ class ChatML(BaseModel):
token_count: Optional[int] = None


class BaseTask(BaseModel):
...
class BaseTask(BaseModel): ...


class BaseTaskArgs(BaseModel):
...
class BaseTaskArgs(BaseModel): ...


class MemoryManagementTaskArgs(BaseTaskArgs):
Expand Down
1 change: 1 addition & 0 deletions agents-api/agents_api/common/exceptions/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

These exceptions are used throughout the agents API to handle errors related to session operations, such as when a requested session cannot be found.
"""

from uuid import UUID
from . import BaseCommonException

Expand Down
2 changes: 1 addition & 1 deletion agents-api/agents_api/common/protocol/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ class AgentDefaultSettings(BaseModel):
"""Penalty that decreases the likelihood of frequently used words in the agent's responses."""
frequency_penalty: float = 0.0
"""Minimum probability threshold for including a word in the agent's response."""
min_p: float = 0.01
min_p: float = 0.01
1 change: 1 addition & 0 deletions agents-api/agents_api/common/protocol/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This module defines session-related data structures and settings used across the agents API.
It includes definitions for session settings and session data models.
"""

from uuid import UUID

from pydantic import BaseModel, validator
Expand Down
1 change: 1 addition & 0 deletions agents-api/agents_api/common/utils/json.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module provides JSON utilities, including a custom JSON encoder for handling specific object types and a utility function for JSON serialization."""

import json
from uuid import UUID
from typing import Any
Expand Down
1 change: 1 addition & 0 deletions agents-api/agents_api/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This module is responsible for loading and providing access to environment variables used throughout the agents-api application.
It utilizes the environs library for environment variable parsing.
"""

from pprint import pprint
from environs import Env

Expand Down
1 change: 1 addition & 0 deletions agents-api/agents_api/model_registry.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Model Registry maintains a list of supported models and their configs.
"""

from typing import Dict
from agents_api.clients.model import julep_client, openai_client
from openai import AsyncOpenAI
Expand Down
2 changes: 1 addition & 1 deletion agents-api/agents_api/models/agent/create_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ def create_agent_query(
"metadata": metadata,
"instructions": instructions,
},
)
)
1 change: 1 addition & 0 deletions agents-api/agents_api/models/docs/list_docs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains functions for querying document-related data from the 'cozodb' database using datalog queries."""

from typing import Literal
from uuid import UUID

Expand Down
1 change: 1 addition & 0 deletions agents-api/agents_api/models/entry/test_entry_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This module contains tests for entry queries against the CozoDB database.
It verifies the functionality of adding, retrieving, and processing entries as defined in the schema.
"""

# Tests for entry queries
from uuid import uuid4

Expand Down
1 change: 1 addition & 0 deletions agents-api/agents_api/models/session/create_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This module contains the functionality for creating a new session in the 'cozodb' database.
It constructs and executes a datalog query to insert session data.
"""

from uuid import UUID

import pandas as pd
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This module contains tests for session-related queries against the 'cozodb' database. It verifies the creation, retrieval, and deletion of session records as defined in the schema provided in agents-api/README.md.
"""

# Tests for session queries
from uuid import uuid4

Expand Down
1 change: 1 addition & 0 deletions agents-api/agents_api/models/user/create_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This module contains the functionality for creating a new user in the CozoDB database.
It defines a query for inserting user data into the 'users' relation.
"""

from uuid import UUID

import pandas as pd
Expand Down
1 change: 1 addition & 0 deletions agents-api/agents_api/models/user/test_user_queries.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains tests for user-related queries against the 'cozodb' database. It includes tests for creating, updating, and retrieving user information."""

# Tests for user queries
from uuid import uuid4

Expand Down
1 change: 1 addition & 0 deletions agents-api/agents_api/web.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This module initializes the FastAPI application, registers routes, sets up middleware, and configures exception handlers.
"""

import fire
import uvicorn
import logging
Expand Down
1 change: 1 addition & 0 deletions agents-api/agents_api/worker/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This script initializes and runs a Temporal worker that listens for tasks on a specified queue.
It supports various workflows and activities related to agents' operations.
"""

#!/usr/bin/env python3

import asyncio
Expand Down
14 changes: 8 additions & 6 deletions sdks/python/julep/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def __init__(
self._client_wrapper = SyncClientWrapper(
base_url=_get_base_url(base_url=base_url, environment=environment),
api_key=api_key,
httpx_client=httpx.Client(timeout=timeout)
if httpx_client is None
else httpx_client,
httpx_client=(
httpx.Client(timeout=timeout) if httpx_client is None else httpx_client
),
)

def list_sessions(
Expand Down Expand Up @@ -1838,9 +1838,11 @@ def __init__(
self._client_wrapper = AsyncClientWrapper(
base_url=_get_base_url(base_url=base_url, environment=environment),
api_key=api_key,
httpx_client=httpx.AsyncClient(timeout=timeout)
if httpx_client is None
else httpx_client,
httpx_client=(
httpx.AsyncClient(timeout=timeout)
if httpx_client is None
else httpx_client
),
)

async def list_sessions(
Expand Down
14 changes: 7 additions & 7 deletions sdks/python/julep/api/types/chat_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class ChatSettings(pydantic.BaseModel):
length_penalty: typing.Optional[float] = pydantic.Field(
description="(Huggingface-like) Number between 0 and 2.0. 1.0 is neutral and values larger than that penalize number of tokens generated."
)
logit_bias: typing.Optional[
typing.Dict[str, typing.Optional[int]]
] = pydantic.Field(
description=(
"Modify the likelihood of specified tokens appearing in the completion.\n"
"\n"
"Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.\n"
logit_bias: typing.Optional[typing.Dict[str, typing.Optional[int]]] = (
pydantic.Field(
description=(
"Modify the likelihood of specified tokens appearing in the completion.\n"
"\n"
"Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.\n"
)
)
)
max_tokens: typing.Optional[int] = pydantic.Field(
Expand Down
Loading