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

Codegen for all new typespec types #435

Merged
merged 40 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
fc34ce3
feat(typespec): Add initial typespec definitions
Jul 11, 2024
8806f76
Merge branch 'dev-tasks' into f/typespec
Jul 12, 2024
2d6f6b8
feat(typespec): Add Tasks typespec
Jul 12, 2024
0381586
feat(typespec): Add Executions typespec
Jul 12, 2024
787d654
feat: Add session token budget and context overflow
whiterabbit1983 Jul 13, 2024
a56bbbe
fix(typespec): Minor spec fixes
Jul 14, 2024
a88ab44
feat(typespec): Add name field to Tool
Jul 14, 2024
5157c44
Merge branch 'dev-tasks' into f/typespec
Jul 14, 2024
c5414e0
refactor(typespec): Minor refactors to common/ utils
Jul 14, 2024
955f8b9
feat(typespec): Add search endpoints
Jul 14, 2024
6373794
feat(typespec): Add multi-agent multi-user sessions, add template for…
Jul 15, 2024
63ba26f
refactor: Remove mock_openapi.yaml and link openapi.yaml to the types…
Jul 15, 2024
aa4da04
feat: Codegen for all new typespec stuff
Jul 15, 2024
cc54e26
feat(fern): Upgrade fern and fern-python
Jul 15, 2024
d54bca3
feat(typespec): Various changes to the spec
Jul 18, 2024
f9ce313
Merge branch 'f/typespec' into f/typespec-codegen
Jul 18, 2024
b2f5808
fix(typespec): Fix docstrings
Jul 20, 2024
2676f6d
wip
Jul 20, 2024
14bee99
wip
Jul 20, 2024
b652995
fix(agents-api): Fix datamodel-codegen options
Jul 20, 2024
2406fe8
fix(typespec): Misc fixes
Jul 22, 2024
c3bc32c
feat(agents-api): Add migrations for updated typespec models
Jul 22, 2024
059f94b
wip
Jul 22, 2024
b9c6a82
wip
Jul 22, 2024
67a0fff
feat(agents-api): Add migrations for developers relations and renamin…
Jul 22, 2024
59462d2
wip
Jul 22, 2024
ac3fcec
wip
Jul 22, 2024
99d5e9e
wip
Jul 22, 2024
752fbaf
fix(agents-api): Update agent/tool models
Jul 23, 2024
9bb58c3
wip
Jul 25, 2024
c31f563
wip
Jul 26, 2024
027faca
wip
Jul 26, 2024
fdfb94b
wip
Jul 26, 2024
c4bac6c
wip
Jul 26, 2024
b8f8992
wip
Jul 28, 2024
4428ed9
wip
Jul 28, 2024
e5aac60
reformat evthing
Jul 28, 2024
1bd6bf2
wip
Jul 29, 2024
d18f7da
wip
Jul 29, 2024
f184863
Merge branch 'dev-tasks' into f/typespec-codegen
Jul 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions agents-api/agents_api/activities/embed_docs.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from pydantic import UUID4
from temporalio import activity

from agents_api.embed_models_registry import EmbeddingModel
from agents_api.env import embedding_model_id
from agents_api.models.docs.embed_docs import (
embed_docs_snippets_query,
)
from agents_api.embed_models_registry import EmbeddingModel


snippet_embed_instruction = "Encode this passage for retrieval: "

Expand Down
1 change: 0 additions & 1 deletion agents-api/agents_api/activities/logger.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging


logger = logging.getLogger(__name__)
h = logging.StreamHandler()
fmt = logging.Formatter("[%(asctime)s/%(levelname)s] - %(message)s")
Expand Down
1 change: 0 additions & 1 deletion agents-api/agents_api/activities/mem_mgmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from ..clients.model import julep_client
from .types import ChatML, MemoryManagementTaskArgs


example_previous_memory = """
Speaker 1: Composes and listens to music. Likes to buy basketball shoes but doesn't wear them often.
""".strip()
Expand Down
16 changes: 9 additions & 7 deletions agents-api/agents_api/activities/summarization.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
#!/usr/bin/env python3

import asyncio
from uuid import UUID
from typing import Callable
from textwrap import dedent
from temporalio import activity
from typing import Callable
from uuid import UUID

from litellm import acompletion
from temporalio import activity

from agents_api.common.protocol.entries import Entry
from agents_api.models.entry.entries_summarization import (
get_toplevel_entries_query,
entries_summarization_query,
get_toplevel_entries_query,
)
from agents_api.common.protocol.entries import Entry
from ..model_registry import LOCAL_MODELS
from ..env import model_inference_url, model_api_key, summarization_model_name
from agents_api.rec_sum.entities import get_entities
from agents_api.rec_sum.summarize import summarize_messages
from agents_api.rec_sum.trim import trim_messages

from ..env import model_api_key, model_inference_url, summarization_model_name
from ..model_registry import LOCAL_MODELS

example_previous_memory = """
Speaker 1: Composes and listens to music. Likes to buy basketball shoes but doesn't wear them often.
Expand Down
18 changes: 8 additions & 10 deletions agents-api/agents_api/activities/task_steps/__init__.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
import asyncio
from uuid import uuid4

from openai.types.chat.chat_completion import ChatCompletion

# import celpy
from simpleeval import simple_eval
from openai.types.chat.chat_completion import ChatCompletion
from temporalio import activity
from uuid import uuid4

from ...autogen.openapi_model import (
PromptWorkflowStep,
# EvaluateWorkflowStep,
YieldWorkflowStep,
# ToolCallWorkflowStep,
# ErrorWorkflowStep,
IfElseWorkflowStep,
InputChatMLMessage,
PromptWorkflowStep,
# EvaluateWorkflowStep,
YieldWorkflowStep,
)

from ...clients.worker.types import ChatML
from ...common.protocol.tasks import (
StepContext,
TransitionInfo,
)

from ...common.utils.template import render_template

from ...models.execution.create_execution_transition import (
create_execution_transition_query,
)
from ...routers.sessions.session import llm_generate
from ...routers.sessions.protocol import Settings
from ...clients.worker.types import ChatML
from ...routers.sessions.session import llm_generate


@activity.defn
Expand Down
6 changes: 4 additions & 2 deletions agents-api/agents_api/activities/truncation.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from uuid import UUID

from temporalio import activity
from agents_api.models.entry.entries_summarization import get_toplevel_entries_query
from agents_api.models.entry.delete_entries import delete_entries

from agents_api.autogen.openapi_model import Role
from agents_api.common.protocol.entries import Entry
from agents_api.models.entry.delete_entries import delete_entries
from agents_api.models.entry.entries_summarization import get_toplevel_entries_query


def get_extra_entries(messages: list[Entry], token_count_threshold: int) -> list[UUID]:
Expand Down
172 changes: 172 additions & 0 deletions agents-api/agents_api/autogen/Agents.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
# generated by datamodel-codegen:
# filename: openapi-0.4.0.yaml

from __future__ import annotations

from typing import Annotated, Any
from uuid import UUID

from pydantic import AwareDatetime, BaseModel, ConfigDict, Field

from .Chat import GenerationPresetSettings, OpenAISettings, VLLMSettings


class Agent(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
id: Annotated[UUID, Field(json_schema_extra={"readOnly": True})]
metadata: dict[str, Any] | None = None
created_at: Annotated[AwareDatetime, Field(json_schema_extra={"readOnly": True})]
"""
When this resource was created as UTC date-time
"""
updated_at: Annotated[AwareDatetime, Field(json_schema_extra={"readOnly": True})]
"""
When this resource was updated as UTC date-time
"""
name: Annotated[
str,
Field(
"",
pattern="^[\\p{L}\\p{Nl}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]+[\\p{ID_Start}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]*$",
),
]
"""
Name of the agent
"""
about: str = ""
"""
About the agent
"""
model: str = ""
"""
Model name to use (gpt-4-turbo, gemini-nano etc)
"""
instructions: str | list[str] = ""
"""
Instructions for the agent
"""
default_settings: (
GenerationPresetSettings | OpenAISettings | VLLMSettings | None
) = None
"""
Default settings for all sessions created by this agent
"""


class CreateAgentRequest(BaseModel):
"""
Payload for creating a agent (and associated documents)
"""

model_config = ConfigDict(
populate_by_name=True,
)
metadata: dict[str, Any] | None = None
name: Annotated[
str,
Field(
"",
pattern="^[\\p{L}\\p{Nl}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]+[\\p{ID_Start}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]*$",
),
]
"""
Name of the agent
"""
about: str = ""
"""
About the agent
"""
model: str = ""
"""
Model name to use (gpt-4-turbo, gemini-nano etc)
"""
instructions: str | list[str] = ""
"""
Instructions for the agent
"""
default_settings: (
GenerationPresetSettings | OpenAISettings | VLLMSettings | None
) = None
"""
Default settings for all sessions created by this agent
"""


class PatchAgentRequest(BaseModel):
"""
Payload for patching a agent
"""

model_config = ConfigDict(
populate_by_name=True,
)
metadata: dict[str, Any] | None = None
name: Annotated[
str,
Field(
"",
pattern="^[\\p{L}\\p{Nl}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]+[\\p{ID_Start}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]*$",
),
]
"""
Name of the agent
"""
about: str = ""
"""
About the agent
"""
model: str = ""
"""
Model name to use (gpt-4-turbo, gemini-nano etc)
"""
instructions: str | list[str] = ""
"""
Instructions for the agent
"""
default_settings: (
GenerationPresetSettings | OpenAISettings | VLLMSettings | None
) = None
"""
Default settings for all sessions created by this agent
"""


class UpdateAgentRequest(BaseModel):
"""
Payload for updating a agent
"""

model_config = ConfigDict(
populate_by_name=True,
)
metadata: dict[str, Any] | None = None
name: Annotated[
str,
Field(
"",
pattern="^[\\p{L}\\p{Nl}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]+[\\p{ID_Start}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\p{Pattern_Syntax}\\p{Pattern_White_Space}]*$",
),
]
"""
Name of the agent
"""
about: str = ""
"""
About the agent
"""
model: str = ""
"""
Model name to use (gpt-4-turbo, gemini-nano etc)
"""
instructions: str | list[str] = ""
"""
Instructions for the agent
"""
default_settings: (
GenerationPresetSettings | OpenAISettings | VLLMSettings | None
) = None
"""
Default settings for all sessions created by this agent
"""
Loading
Loading