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

x/fix codec #463

Merged
merged 4 commits into from
Aug 20, 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
4 changes: 1 addition & 3 deletions agents-api/agents_api/activities/task_steps/evaluate_step.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import logging

from beartype import beartype
from temporalio import activity

Expand All @@ -23,7 +21,7 @@ async def evaluate_step(context: StepContext) -> StepOutcome:
return result

except BaseException as e:
logging.error(f"Error in evaluate_step: {e}")
activity.logger.error(f"Error in evaluate_step: {e}")
return StepOutcome(error=str(e))


Expand Down
4 changes: 1 addition & 3 deletions agents-api/agents_api/activities/task_steps/if_else_step.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import logging

from beartype import beartype
from simpleeval import simple_eval
from temporalio import activity
Expand Down Expand Up @@ -27,7 +25,7 @@ async def if_else_step(context: StepContext) -> StepOutcome:
return result

except BaseException as e:
logging.error(f"Error in if_else_step: {e}")
activity.logger.error(f"Error in if_else_step: {e}")
return StepOutcome(error=str(e))


Expand Down
4 changes: 1 addition & 3 deletions agents-api/agents_api/activities/task_steps/log_step.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import logging

from beartype import beartype
from simpleeval import simple_eval
from temporalio import activity
Expand All @@ -26,7 +24,7 @@ async def log_step(context: StepContext) -> StepOutcome:
return result

except BaseException as e:
logging.error(f"Error in log_step: {e}")
activity.logger.error(f"Error in log_step: {e}")
return StepOutcome(error=str(e))


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@

@activity.defn
async def raise_complete_async() -> None:
activity.heartbeat("Starting to wait")
activity.raise_complete_async()
4 changes: 1 addition & 3 deletions agents-api/agents_api/activities/task_steps/return_step.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import logging

from temporalio import activity

from ...activities.task_steps.utils import simple_eval_dict
Expand All @@ -24,7 +22,7 @@ async def return_step(context: StepContext) -> StepOutcome:
return result

except BaseException as e:
logging.error(f"Error in log_step: {e}")
activity.logger.error(f"Error in log_step: {e}")
return StepOutcome(error=str(e))


Expand Down
4 changes: 1 addition & 3 deletions agents-api/agents_api/activities/task_steps/switch_step.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import logging

from beartype import beartype
from simpleeval import simple_eval
from temporalio import activity
Expand Down Expand Up @@ -35,7 +33,7 @@ async def switch_step(context: StepContext) -> StepOutcome:
return result

except BaseException as e:
logging.error(f"Error in switch_step: {e}")
activity.logger.error(f"Error in switch_step: {e}")
return StepOutcome(error=str(e))


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ async def transition_step(
transition_info.task_token = task_token

# Create transition
activity.heartbeat("Creating transition in db")
create_execution_transition_query(
developer_id=context.developer_id,
execution_id=context.execution.id,
Expand Down
3 changes: 1 addition & 2 deletions agents-api/agents_api/activities/task_steps/yield_step.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import logging
from typing import Callable

from beartype import beartype
Expand Down Expand Up @@ -38,7 +37,7 @@ async def yield_step(context: StepContext) -> StepOutcome:
return StepOutcome(output=arguments, transition_to=("step", transition_target))

except BaseException as e:
logging.error(f"Error in log_step: {e}")
activity.logger.error(f"Error in yield_step: {e}")
return StepOutcome(error=str(e))


Expand Down
5 changes: 5 additions & 0 deletions agents-api/agents_api/autogen/Agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

class Agent(BaseModel):
model_config = ConfigDict(
extra="allow",
populate_by_name=True,
)
id: Annotated[UUID, Field(json_schema_extra={"readOnly": True})]
Expand Down Expand Up @@ -59,6 +60,7 @@ class CreateAgentRequest(BaseModel):
"""

model_config = ConfigDict(
extra="allow",
populate_by_name=True,
)
metadata: dict[str, Any] | None = None
Expand Down Expand Up @@ -92,6 +94,7 @@ class CreateAgentRequest(BaseModel):

class CreateOrUpdateAgentRequest(CreateAgentRequest):
model_config = ConfigDict(
extra="allow",
populate_by_name=True,
)
id: UUID
Expand Down Expand Up @@ -130,6 +133,7 @@ class PatchAgentRequest(BaseModel):
"""

model_config = ConfigDict(
extra="allow",
populate_by_name=True,
)
metadata: dict[str, Any] | None = None
Expand Down Expand Up @@ -167,6 +171,7 @@ class UpdateAgentRequest(BaseModel):
"""

model_config = ConfigDict(
extra="allow",
populate_by_name=True,
)
metadata: dict[str, Any] | None = None
Expand Down
29 changes: 23 additions & 6 deletions agents-api/agents_api/autogen/Chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Annotated, Literal
from uuid import UUID

from pydantic import AwareDatetime, BaseModel, ConfigDict, Field
from pydantic import AwareDatetime, BaseModel, ConfigDict, Field, StrictBool

from .Common import LogitBias
from .Docs import DocReference
Expand All @@ -16,6 +16,7 @@

class BaseChatOutput(BaseModel):
model_config = ConfigDict(
extra="allow",
populate_by_name=True,
)
index: int
Expand All @@ -31,6 +32,7 @@ class BaseChatOutput(BaseModel):

class BaseChatResponse(BaseModel):
model_config = ConfigDict(
extra="allow",
populate_by_name=True,
)
usage: CompetionUsage | None = None
Expand All @@ -54,6 +56,7 @@ class BaseChatResponse(BaseModel):

class BaseTokenLogProb(BaseModel):
model_config = ConfigDict(
extra="allow",
populate_by_name=True,
)
token: str
Expand All @@ -66,6 +69,7 @@ class BaseTokenLogProb(BaseModel):

class ChatInputData(BaseModel):
model_config = ConfigDict(
extra="allow",
populate_by_name=True,
)
messages: Annotated[list[InputChatMLMessage], Field(min_length=1)]
Expand All @@ -88,6 +92,7 @@ class ChatOutputChunk(BaseChatOutput):
"""

model_config = ConfigDict(
extra="allow",
populate_by_name=True,
)
delta: InputChatMLMessage
Expand All @@ -98,6 +103,7 @@ class ChatOutputChunk(BaseChatOutput):

class ChunkChatResponse(BaseChatResponse):
model_config = ConfigDict(
extra="allow",
populate_by_name=True,
)
choices: list[ChatOutputChunk]
Expand All @@ -112,6 +118,7 @@ class CompetionUsage(BaseModel):
"""

model_config = ConfigDict(
extra="allow",
populate_by_name=True,
)
completion_tokens: Annotated[
Expand All @@ -136,6 +143,7 @@ class CompetionUsage(BaseModel):

class CompletionResponseFormat(BaseModel):
model_config = ConfigDict(
extra="allow",
populate_by_name=True,
)
type: Literal["text", "json_object"] = "text"
Expand All @@ -146,6 +154,7 @@ class CompletionResponseFormat(BaseModel):

class LogProbResponse(BaseModel):
model_config = ConfigDict(
extra="allow",
populate_by_name=True,
)
content: Annotated[list[TokenLogProb] | None, Field(...)]
Expand All @@ -156,6 +165,7 @@ class LogProbResponse(BaseModel):

class MessageChatResponse(BaseChatResponse):
model_config = ConfigDict(
extra="allow",
populate_by_name=True,
)
choices: list[SingleChatOutput | MultipleChatOutput]
Expand All @@ -170,13 +180,15 @@ class MultipleChatOutput(BaseChatOutput):
"""

model_config = ConfigDict(
extra="allow",
populate_by_name=True,
)
messages: list[InputChatMLMessage]


class OpenAISettings(BaseModel):
model_config = ConfigDict(
extra="allow",
populate_by_name=True,
)
frequency_penalty: Annotated[float | None, Field(None, ge=-2.0, le=2.0)]
Expand All @@ -203,31 +215,34 @@ class SingleChatOutput(BaseChatOutput):
"""

model_config = ConfigDict(
extra="allow",
populate_by_name=True,
)
message: InputChatMLMessage


class TokenLogProb(BaseTokenLogProb):
model_config = ConfigDict(
extra="allow",
populate_by_name=True,
)
top_logprobs: list[BaseTokenLogProb]


class ChatInput(ChatInputData):
model_config = ConfigDict(
extra="allow",
populate_by_name=True,
)
remember: Annotated[bool, Field(False, json_schema_extra={"readOnly": True})]
remember: Annotated[StrictBool, Field(False, json_schema_extra={"readOnly": True})]
"""
DISABLED: Whether this interaction should form new memories or not (will be enabled in a future release)
"""
recall: bool = True
recall: StrictBool = True
"""
Whether previous memories and docs should be recalled or not
"""
save: bool = True
save: StrictBool = True
"""
Whether this interaction should be stored in the session history or not
"""
Expand All @@ -241,7 +256,7 @@ class ChatInput(ChatInputData):
"""
Identifier of the model to be used
"""
stream: bool = False
stream: StrictBool = False
"""
Indicates if the server should stream the response as it's generated
"""
Expand Down Expand Up @@ -305,6 +320,7 @@ class DefaultChatSettings(OpenAISettings):
"""

model_config = ConfigDict(
extra="allow",
populate_by_name=True,
)
repetition_penalty: Annotated[float | None, Field(None, ge=0.0, le=2.0)]
Expand All @@ -323,6 +339,7 @@ class DefaultChatSettings(OpenAISettings):

class ChatSettings(DefaultChatSettings):
model_config = ConfigDict(
extra="allow",
populate_by_name=True,
)
model: Annotated[
Expand All @@ -335,7 +352,7 @@ class ChatSettings(DefaultChatSettings):
"""
Identifier of the model to be used
"""
stream: bool = False
stream: StrictBool = False
"""
Indicates if the server should stream the response as it's generated
"""
Expand Down
3 changes: 3 additions & 0 deletions agents-api/agents_api/autogen/Common.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Offset(RootModel[int]):

class ResourceCreatedResponse(BaseModel):
model_config = ConfigDict(
extra="allow",
populate_by_name=True,
)
id: UUID
Expand All @@ -56,6 +57,7 @@ class ResourceCreatedResponse(BaseModel):

class ResourceDeletedResponse(BaseModel):
model_config = ConfigDict(
extra="allow",
populate_by_name=True,
)
id: UUID
Expand All @@ -74,6 +76,7 @@ class ResourceDeletedResponse(BaseModel):

class ResourceUpdatedResponse(BaseModel):
model_config = ConfigDict(
extra="allow",
populate_by_name=True,
)
id: UUID
Expand Down
Loading
Loading