Skip to content
Open
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "emp-agents"
version = "0.3.0"
version = "0.3.1"
description = "A Python library for building low-code, capable and extensible autonomous agent systems."
readme = "README.md"
requires-python = ">=3.10"
Expand Down
11 changes: 9 additions & 2 deletions src/emp_agents/agents/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
ConfigDict,
Field,
PrivateAttr,
ValidationError,
computed_field,
field_validator,
)

from emp_agents.agents.history import AbstractConversationProvider, ConversationProvider
from emp_agents.exceptions import ResponseValidationError
from emp_agents.logger import logger
from emp_agents.models import (
AssistantMessage,
Expand Down Expand Up @@ -46,7 +48,7 @@ class AgentBase(BaseModel):
default_factory=ConversationProvider
)
sync_tools: bool = Field(
True, description="If true, tools will be executed synchronously"
default=True, description="If true, tools will be executed synchronously"
)

# This can be used to modify the conversation before completion, such as RAG
Expand Down Expand Up @@ -195,7 +197,12 @@ async def respond(
max_tokens=max_tokens,
response_format=response_format,
)
return response_format.model_validate_json(response)
try:
return response_format.model_validate_json(response)
except ValidationError as e:
raise ResponseValidationError(
f"Error validating agent response to {response_format.__name__}: {response}"
) from e

@overload
async def complete(
Expand Down
4 changes: 4 additions & 0 deletions src/emp_agents/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ class TooManyTriesException(BaseException):

class InvalidModelException(BaseException):
pass


class ResponseValidationError(BaseException):
pass