Repository navigation
Python: Defining the response_format of a ChatCompletionAgent in a YAML file #13348
Unanswered
Dhrubanka Dutta (bankaboy)
asked this question in
Q&A
Replies: 4 comments
|
This is where I am structuring my YAML from Semantic Kernel YAML Schema |
0 replies
|
I struggled with scema also until i found this diving-into-function-calling-and-its-json-schema-in-semantic-kernel-net schema should be like this output_variable:
json_schema: |
{
"type": "object",
"required": [ "files_list" ],
"additionalProperties": false,
"properties": {
"files_list": { "type": "array", "items": { "type": "string" }}
}
} |
0 replies
|
For this specific case I would separate two things:
For the Python from semantic_kernel.functions import KernelArguments
from semantic_kernel.connectors.ai.open_ai import AzureChatPromptExecutionSettings
from semantic_kernel.kernel_pydantic import KernelBaseModel
class FilesList(KernelBaseModel):
files_list: list[str]
settings = AzureChatPromptExecutionSettings(
temperature=0.0,
top_p=0.0,
)
settings.response_format = FilesList
agent = await AgentRegistry.create_from_file(
"file_discovery_agent.yaml",
kernel=kernel,
service=AzureChatCompletion(...),
arguments=KernelArguments(settings=settings),
)If you prefer a schema dictionary instead of a Pydantic model, use the provider structured-output shape rather than an example object: settings.response_format = {
"type": "json_schema",
"json_schema": {
"name": "files_list_response",
"strict": True,
"schema": {
"type": "object",
"required": ["files_list"],
"additionalProperties": False,
"properties": {
"files_list": {
"type": "array",
"items": {"type": "string"},
}
},
},
},
}Two small gotchas:
|
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I have the following class for structuring the response of a ChatCompletionAgent
I want to create the ChatCompletionAgent using the AgentRegistry.create_from_file() method and the agent should pull the AzurePromptExecutionSettings from the YAML file.
My current YAML file
Plugin
If I use get_response, I get the result back in free text and not structured to the FilesList class
The result is the same whether I do
or
or
This is what I'm trying to achieve (agent initialised in code itself):
I want a way the AgentRegistry.create_from_file method either:
All reactions