Skip to content

Commit 3db6179

Browse files
authored
Merge pull request #1067 from writer/fix-AB-217-no-code-agent-empty-default-input
fix: convert empty values for AI Studio agent calls - AB-217
2 parents f3063d7 + 9e8ae26 commit 3db6179

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/writer/ai/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2366,7 +2366,7 @@ def retrieve(
23662366
def generate_content(
23672367
self,
23682368
application_id: str,
2369-
input_dict: Optional[Dict[str, str]] = None,
2369+
input_dict: Optional[Dict[str, Optional[Union[List[str], str]]]] = None,
23702370
async_job: Optional[bool] = False,
23712371
config: Optional[APIOptions] = None
23722372
) -> Union[str, JobCreateResponse]:
@@ -2429,9 +2429,16 @@ def generate_content(
24292429
inputs = []
24302430

24312431
for k, v in input_dict.items():
2432+
# Convert None/empty to []
2433+
# to avoid API 400 errors on optional inputs
2434+
if v is None or v == "":
2435+
value = []
2436+
else:
2437+
value = v if isinstance(v, list) else [v]
2438+
24322439
inputs.append(Input({
24332440
"id": k,
2434-
"value": v if isinstance(v, list) else [v]
2441+
"value": value
24352442
}))
24362443

24372444
if not async_job:

0 commit comments

Comments
 (0)