mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: Properly configure structured outputs based on new options dict (#3213)
* Properly configure structured outputs based on new options dict * Fix mypy
This commit is contained in:
committed by
GitHub
Unverified
parent
620da7a829
commit
15d0c34d9f
+2
-2
@@ -99,7 +99,7 @@ def spam_detection_orchestration(context: DurableOrchestrationContext):
|
||||
spam_result_raw = yield spam_agent.run(
|
||||
messages=spam_prompt,
|
||||
thread=spam_thread,
|
||||
response_format=SpamDetectionResult,
|
||||
options={"response_format": SpamDetectionResult},
|
||||
)
|
||||
|
||||
spam_result = cast(SpamDetectionResult, spam_result_raw.value)
|
||||
@@ -120,7 +120,7 @@ def spam_detection_orchestration(context: DurableOrchestrationContext):
|
||||
email_result_raw = yield email_agent.run(
|
||||
messages=email_prompt,
|
||||
thread=email_thread,
|
||||
response_format=EmailResponse,
|
||||
options={"response_format": EmailResponse},
|
||||
)
|
||||
|
||||
email_result = cast(EmailResponse, email_result_raw.value)
|
||||
|
||||
+4
-8
@@ -98,7 +98,7 @@ def content_generation_hitl_orchestration(context: DurableOrchestrationContext):
|
||||
initial_raw = yield writer.run(
|
||||
messages=f"Write a short article about '{payload.topic}'.",
|
||||
thread=writer_thread,
|
||||
response_format=GeneratedContent,
|
||||
options={"response_format": GeneratedContent},
|
||||
)
|
||||
|
||||
content = initial_raw.value
|
||||
@@ -135,9 +135,7 @@ def content_generation_hitl_orchestration(context: DurableOrchestrationContext):
|
||||
)
|
||||
return {"content": content.content}
|
||||
|
||||
context.set_custom_status(
|
||||
"Content rejected by human reviewer. Incorporating feedback and regenerating..."
|
||||
)
|
||||
context.set_custom_status("Content rejected by human reviewer. Incorporating feedback and regenerating...")
|
||||
rewrite_prompt = (
|
||||
"The content was rejected by a human reviewer. Please rewrite the article incorporating their feedback.\n\n"
|
||||
f"Human Feedback: {approval_payload.feedback or 'No feedback provided.'}"
|
||||
@@ -145,7 +143,7 @@ def content_generation_hitl_orchestration(context: DurableOrchestrationContext):
|
||||
rewritten_raw = yield writer.run(
|
||||
messages=rewrite_prompt,
|
||||
thread=writer_thread,
|
||||
response_format=GeneratedContent,
|
||||
options={"response_format": GeneratedContent},
|
||||
)
|
||||
|
||||
rewritten_value = rewritten_raw.value
|
||||
@@ -157,9 +155,7 @@ def content_generation_hitl_orchestration(context: DurableOrchestrationContext):
|
||||
context.set_custom_status(
|
||||
f"Human approval timed out after {payload.approval_timeout_hours} hour(s). Treating as rejection."
|
||||
)
|
||||
raise TimeoutError(
|
||||
f"Human approval timed out after {payload.approval_timeout_hours} hour(s)."
|
||||
)
|
||||
raise TimeoutError(f"Human approval timed out after {payload.approval_timeout_hours} hour(s).")
|
||||
|
||||
raise RuntimeError(f"Content could not be approved after {payload.max_review_attempts} iteration(s).")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user