Skip to content

Commit

Permalink
fix(agents-api): failed decoding arguments fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Vedantsahai18 committed Oct 15, 2024
1 parent 746f9a1 commit eb251c6
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 107 deletions.
5 changes: 5 additions & 0 deletions agents-api/agents_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@
#################################
## Do NOT put any imports here ##
#################################
# Failed decoding arguments fixture
from temporalio import workflow

with workflow.unsafe.imports_passed_through():
import msgpack as msgpack
15 changes: 4 additions & 11 deletions agents-api/agents_api/common/utils/yaml.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
from io import StringIO
from typing import Any

from ruamel.yaml import YAML
import yaml

yaml = YAML(typ="safe", pure=True) # pure is needed for yaml 1.2 support
yaml.version = (1, 2)

def load(string: str) -> Any:
return yaml.load(string, Loader=yaml.CSafeLoader)

def dump(value: Any) -> str:
stream = StringIO()
yaml.dump(value, stream)

return stream.getvalue()


def load(string: str) -> Any:
return yaml.load(string)
return yaml.dump(value, Dumper=yaml.CSafeDumper)
88 changes: 4 additions & 84 deletions agents-api/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions agents-api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ google-re2 = "^1.1.20240702"
scalar-fastapi = "^1.0.3"
sse-starlette = "^2.1.3"
anyio = "^4.4.0"
python-box = {extras = ["toml"], version = "^7.2.0"}
python-box = {extras = [], version = "^7.2.0"}
prometheus-fastapi-instrumentator = "^7.0.0"
ruamel-yaml = "^0.18.6"
[tool.poetry.group.dev.dependencies]
ipython = "^8.26.0"
ruff = "^0.5.5"
Expand Down
2 changes: 1 addition & 1 deletion cookbooks/06-Designing_Multi-Step_Tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
)

# Defining a Task with various step types
task_def = yaml.safe_load("""
task_def = yaml.safe_load(f"""
name: Multi-Step Task Demonstration
input_schema:
Expand Down
2 changes: 1 addition & 1 deletion cookbooks/07-Integrating_External_Tools_and_APIs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)

# Defining a Task with various step types
task_def = yaml.safe_load("""
task_def = yaml.safe_load(f"""
name: Comprehensive Analysis Report
input_schema:
Expand Down
2 changes: 1 addition & 1 deletion cookbooks/08-Managing_Persistent_Sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
)

# Defining a task for managing user context
task_def = yaml.safe_load("""
task_def = yaml.safe_load(f"""
name: Manage User Context
input_schema:
Expand Down
4 changes: 2 additions & 2 deletions cookbooks/09-User_Management_and_Personalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
)

# Defining a task for user registration and profile creation
registration_task_def = yaml.safe_load("""
registration_task_def = yaml.safe_load(f"""
name: User Registration and Profile Creation
input_schema:
Expand Down Expand Up @@ -75,7 +75,7 @@
)

# Defining a task for personalized content recommendation
recommendation_task_def = yaml.safe_load("""
recommendation_task_def = yaml.safe_load(f"""
name: Personalized Content Recommendation
input_schema:
Expand Down
8 changes: 4 additions & 4 deletions cookbooks/10-Document_Management_and_Search.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
)

# Defining a task for document upload and indexing
upload_task_def = yaml.safe_load("""
upload_task_def = yaml.safe_load(f"""
name: Document Upload and Indexing
input_schema:
Expand Down Expand Up @@ -68,8 +68,8 @@
data:
title: _.title
content: _.content
metadata: _.metadataetadata
metadata: _.metadata
- prompt:
- role: system
content: >-
Expand All @@ -85,7 +85,7 @@
)

# Defining a task for document search
search_task_def = yaml.safe_load("""
search_task_def = yaml.safe_load(f"""
name: Document Search
input_schema:
Expand Down
2 changes: 1 addition & 1 deletion cookbooks/11-Advanced_Chat_Interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
)

# Defining a task for handling complex conversations
chat_task_def = yaml.safe_load("""
chat_task_def = yaml.safe_load(f"""
name: Advanced Chat Interaction
input_schema:
Expand Down

0 comments on commit eb251c6

Please sign in to comment.