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
3 changes: 2 additions & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
- [Alex Thewsey](https://github.com/athewsey)
- [Kaustav Dey](https://github.com/kaustavbecs)
- [Tony Santiago](https://github.com/tsanti)
- [Lucas Banerji](https://github.com/LucaiB)
- [Lucas Banerji](https://github.com/LucaiB)
- [Banjo Obayomi](https://github.com/aws-banjo)
25 changes: 12 additions & 13 deletions src/InlineAgent/src/InlineAgent/agent/process_roc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import inspect
import json
from typing import Any, Callable, Dict, Union

from termcolor import colored

from InlineAgent.constants import TraceColor
Expand Down Expand Up @@ -44,20 +45,18 @@ async def process_roc(
parameters = dict()
for param in functionInvocationInput["parameters"]:
if param["type"] == "array":
result = None
try:
result = json.loads(param["value"])
except Exception:
json_str = (
param["value"]
.replace("=", ":")
.replace("[{", '[{"')
.replace("}]", '"}]')
)
json_str = json_str.replace(", ", '", "').replace(":", '":"')
result = json.loads(json_str)
finally:
parameters[param["name"]] = result
# First try direct JSON parsing
parameters[param["name"]] = json.loads(param["value"])
except json.JSONDecodeError:
# If that fails, try to clean up the string to make it valid JSON
value = param["value"]
# Remove square brackets if they exist at start/end
if value.startswith("[") and value.endswith("]"):
value = value[1:-1]
# Split by comma and clean up each item
items = [item.strip() for item in value.split(",")]
parameters[param["name"]] = items
elif param["type"] == "string":
parameters[param["name"]] = param["value"]
elif param["type"] == "number":
Expand Down