-
Notifications
You must be signed in to change notification settings - Fork 683
Python: Introducing support for declarative yaml spec #2002
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
eavanvalkenburg
wants to merge
6
commits into
microsoft:main
Choose a base branch
from
eavanvalkenburg:declarative
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,751
−166
Draft
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ba16450
first work on declarative
eavanvalkenburg f7ad21d
initial version of the declarative support
eavanvalkenburg cfcb309
fix tests and mypy
eavanvalkenburg 6eac844
fix parameters of functiontool
eavanvalkenburg 867d9a7
slight logic improvement
eavanvalkenburg c4db5d4
remove path until merge
eavanvalkenburg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Declarative Agents | ||
|
|
||
| This folder contains sample agent definitions than be ran using the [Declarative Agents](../dotnet/samples/GettingStarted/DeclarativeAgents) demo. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| kind: Prompt | ||
| name: Assistant | ||
| description: Helpful assistant | ||
| instructions: You are a helpful assistant. You answer questions is the language specified by the user. You return your answers in a JSON format. You must include Chat as the type in your response. | ||
| model: | ||
| id: =Env.AZURE_OPENAI_DEPLOYMENT_NAME | ||
| provider: AzureOpenAI | ||
| apiType: Chat | ||
| options: | ||
| temperature: 0.9 | ||
| topP: 0.95 | ||
| outputSchema: | ||
| properties: | ||
| language: | ||
| kind: string | ||
| required: true | ||
| description: The language of the answer. | ||
| answer: | ||
| kind: string | ||
| required: true | ||
| description: The answer text. | ||
| type: | ||
| kind: string | ||
| required: true | ||
| description: The type of the response. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| kind: Prompt | ||
| name: Assistant | ||
| description: Helpful assistant | ||
| instructions: You are a helpful assistant. You answer questions is the language specified by the user. You return your answers in a JSON format. You must include Assistants as the type in your response. | ||
| model: | ||
| id: =Env.AZURE_OPENAI_DEPLOYMENT_NAME | ||
| provider: AzureOpenAI | ||
| apiType: Assistants | ||
| options: | ||
| temperature: 0.9 | ||
| topP: 0.95 | ||
| outputSchema: | ||
| properties: | ||
| language: | ||
| kind: string | ||
| required: true | ||
| description: The language of the answer. | ||
| answer: | ||
| kind: string | ||
| required: true | ||
| description: The answer text. | ||
| type: | ||
| kind: string | ||
| required: true | ||
| description: The type of the response. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| kind: Prompt | ||
| name: Assistant | ||
| description: Helpful assistant | ||
| instructions: You are a helpful assistant. You answer questions is the language specified by the user. You return your answers in a JSON format. You must include Responses as the type in your response. | ||
| model: | ||
| id: =Env.AZURE_OPENAI_DEPLOYMENT_NAME | ||
| provider: AzureOpenAI | ||
| apiType: Responses | ||
| options: | ||
| text: | ||
| verbosity: medium | ||
| connection: | ||
| kind: remote | ||
| endpoint: =Env.AZURE_OPENAI_ENDPOINT | ||
| outputSchema: | ||
| properties: | ||
| language: | ||
| kind: string | ||
| required: true | ||
| description: The language of the answer. | ||
| answer: | ||
| kind: string | ||
| required: true | ||
| description: The answer text. | ||
| type: | ||
| kind: string | ||
| required: true | ||
| description: The type of the response. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| kind: Prompt | ||
| name: Assistant | ||
| description: Helpful assistant | ||
| instructions: You are a helpful assistant. You answer questions is the language specified by the user. You return your answers in a JSON format. | ||
| model: | ||
| options: | ||
| temperature: 0.9 | ||
| topP: 0.95 | ||
| outputSchema: | ||
| properties: | ||
| language: | ||
| kind: string | ||
| required: true | ||
| description: The language of the answer. | ||
| answer: | ||
| kind: string | ||
| required: true | ||
| description: The answer text. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| kind: Prompt | ||
| name: Assistant | ||
| description: Helpful assistant | ||
| instructions: You are a helpful assistant. You answer questions using the tools provided. | ||
| model: | ||
| options: | ||
| allowMultipleToolCalls: true | ||
| chatToolMode: auto | ||
| tools: | ||
| - kind: function | ||
| name: GetWeather | ||
| description: Get the weather for a given location. | ||
| bindings: | ||
| get_weather: get_weather | ||
| parameters: | ||
| location: | ||
| kind: string | ||
| description: The city and state, e.g. San Francisco, CA | ||
| required: true | ||
| unit: | ||
| kind: string | ||
| description: The unit of temperature. Possible values are 'celsius' and 'fahrenheit'. | ||
| required: false | ||
| enum: | ||
| - celsius | ||
| - fahrenheit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| kind: Prompt | ||
| name: MicrosoftLearnAgent | ||
| description: Microsoft Learn Agent | ||
| instructions: You answer questions by searching the Microsoft Learn content only. | ||
| model: | ||
| id: =Env.AZURE_FOUNDRY_PROJECT_MODEL_ID | ||
| options: | ||
| temperature: 0.9 | ||
| topP: 0.95 | ||
| connection: | ||
| kind: remote | ||
| endpoint: =Env.AZURE_FOUNDRY_PROJECT_ENDPOINT | ||
| tools: | ||
| - kind: mcp | ||
| name: microsoft_learn | ||
| description: Get information from Microsoft Learn. | ||
| url: https://learn.microsoft.com/api/mcp | ||
| approvalMode: | ||
| kind: never | ||
| allowedTools: | ||
| - microsoft_docs_search |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| kind: Prompt | ||
| name: Assistant | ||
| description: Helpful assistant | ||
| instructions: You are a helpful assistant. You answer questions is the language specified by the user. You return your answers in a JSON format. | ||
| model: | ||
| id: =Env.AZURE_FOUNDRY_PROJECT_MODEL_ID | ||
| options: | ||
| temperature: 0.9 | ||
| topP: 0.95 | ||
| connection: | ||
| kind: remote | ||
| endpoint: =Env.AZURE_FOUNDRY_PROJECT_ENDPOINT | ||
| outputSchema: | ||
| properties: | ||
| language: | ||
| kind: string | ||
| required: true | ||
| description: The language of the answer. | ||
| answer: | ||
| kind: string | ||
| required: true | ||
| description: The answer text. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| kind: Prompt | ||
| name: Assistant | ||
| description: Helpful assistant | ||
| instructions: You are a helpful assistant. You answer questions is the language specified by the user. You return your answers in a JSON format. You must include Chat as the type in your response. | ||
| model: | ||
| id: =Env.OPENAI_MODEL | ||
| provider: OpenAI | ||
| apiType: Chat | ||
| options: | ||
| temperature: 0.9 | ||
| topP: 0.95 | ||
| connection: | ||
| kind: key | ||
| key: =Env.OPENAI_API_KEY | ||
| outputSchema: | ||
| properties: | ||
| language: | ||
| kind: string | ||
| required: true | ||
| description: The language of the answer. | ||
| answer: | ||
| kind: string | ||
| required: true | ||
| description: The answer text. | ||
| type: | ||
| kind: string | ||
| required: true | ||
| description: The type of the response. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| kind: Prompt | ||
| name: Assistant | ||
| description: Helpful assistant | ||
| instructions: You are a helpful assistant. You answer questions is the language specified by the user. You return your answers in a JSON format. You must include Assistants as the type in your response. | ||
| model: | ||
| id: =Env.OPENAI_MODEL | ||
| provider: OpenAI | ||
| apiType: Assistants | ||
| options: | ||
| temperature: 0.9 | ||
| topP: 0.95 | ||
| connection: | ||
| kind: key | ||
| key: =Env.OPENAI_APIKEY | ||
| outputSchema: | ||
| name: AssistantResponse | ||
| description: The response from the assistant. | ||
| properties: | ||
| language: | ||
| kind: string | ||
| required: true | ||
| description: The language of the answer. | ||
| answer: | ||
| kind: string | ||
| required: true | ||
| description: The answer text. | ||
| type: | ||
| kind: string | ||
| required: true | ||
| description: The type of the response. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| kind: Prompt | ||
| name: Assistant | ||
| description: Helpful assistant | ||
| instructions: You are a helpful assistant. You answer questions is the language specified by the user. You return your answers in a JSON format. You must include Responses as the type in your response. | ||
| model: | ||
| id: =Env.OPENAI_MODEL | ||
| provider: OpenAI | ||
| apiType: Responses | ||
| options: | ||
| text: | ||
| verbosity: medium | ||
| connection: | ||
| kind: key | ||
| key: =Env.OPENAI_APIKEY | ||
| outputSchema: | ||
| properties: | ||
| language: | ||
| kind: string | ||
| required: true | ||
| description: The language of the answer. | ||
| answer: | ||
| kind: string | ||
| required: true | ||
| description: The answer text. | ||
| type: | ||
| kind: string | ||
| required: true | ||
| description: The type of the response. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -587,9 +587,11 @@ def __init__( | |
| name: str | None = None, | ||
| description: str | None = None, | ||
| chat_message_store_factory: Callable[[], ChatMessageStoreProtocol] | None = None, | ||
| conversation_id: str | None = None, | ||
| context_providers: ContextProvider | list[ContextProvider] | AggregateContextProvider | None = None, | ||
| middleware: Middleware | list[Middleware] | None = None, | ||
| # chat options | ||
| allow_multiple_tool_calls: bool | None = None, | ||
| conversation_id: str | None = None, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider separating this into it's own PR and getting it into main straight away |
||
| frequency_penalty: float | None = None, | ||
| logit_bias: dict[str | int, float] | None = None, | ||
| max_tokens: int | None = None, | ||
|
|
@@ -634,6 +636,7 @@ def __init__( | |
| Cannot be used together with chat_message_store_factory. | ||
| context_providers: The collection of multiple context providers to include during agent invocation. | ||
| middleware: List of middleware to intercept agent and function invocations. | ||
| allow_multiple_tool_calls: Whether to allow multiple tool calls in a single response. | ||
| frequency_penalty: The frequency penalty to use. | ||
| logit_bias: The logit bias to use. | ||
| max_tokens: The maximum number of tokens to generate. | ||
|
|
@@ -688,6 +691,7 @@ def __init__( | |
| agent_tools = [tool for tool in normalized_tools if not isinstance(tool, MCPTool)] | ||
| self.chat_options = ChatOptions( | ||
| model_id=model_id, | ||
| allow_multiple_tool_calls=allow_multiple_tool_calls, | ||
| conversation_id=conversation_id, | ||
| frequency_penalty=frequency_penalty, | ||
| instructions=instructions, | ||
|
|
@@ -758,6 +762,7 @@ async def run( | |
| messages: str | ChatMessage | list[str] | list[ChatMessage] | None = None, | ||
| *, | ||
| thread: AgentThread | None = None, | ||
| allow_multiple_tool_calls: bool | None = None, | ||
| frequency_penalty: float | None = None, | ||
| logit_bias: dict[str | int, float] | None = None, | ||
| max_tokens: int | None = None, | ||
|
|
@@ -793,6 +798,7 @@ async def run( | |
|
|
||
| Keyword Args: | ||
| thread: The thread to use for the agent. | ||
| allow_multiple_tool_calls: Whether to allow multiple tool calls in a single response. | ||
| frequency_penalty: The frequency penalty to use. | ||
| logit_bias: The logit bias to use. | ||
| max_tokens: The maximum number of tokens to generate. | ||
|
|
@@ -843,6 +849,7 @@ async def run( | |
|
|
||
| co = run_chat_options & ChatOptions( | ||
| model_id=model_id, | ||
| allow_multiple_tool_calls=allow_multiple_tool_calls, | ||
| conversation_id=thread.service_thread_id, | ||
| frequency_penalty=frequency_penalty, | ||
| logit_bias=logit_bias, | ||
|
|
@@ -887,6 +894,7 @@ async def run_stream( | |
| messages: str | ChatMessage | list[str] | list[ChatMessage] | None = None, | ||
| *, | ||
| thread: AgentThread | None = None, | ||
| allow_multiple_tool_calls: bool | None = None, | ||
| frequency_penalty: float | None = None, | ||
| logit_bias: dict[str | int, float] | None = None, | ||
| max_tokens: int | None = None, | ||
|
|
@@ -922,6 +930,7 @@ async def run_stream( | |
|
|
||
| Keyword Args: | ||
| thread: The thread to use for the agent. | ||
| allow_multiple_tool_calls: Whether to allow multiple tool calls in a single response. | ||
| frequency_penalty: The frequency penalty to use. | ||
| logit_bias: The logit bias to use. | ||
| max_tokens: The maximum number of tokens to generate. | ||
|
|
@@ -971,6 +980,7 @@ async def run_stream( | |
|
|
||
| co = run_chat_options & ChatOptions( | ||
| conversation_id=thread.service_thread_id, | ||
| allow_multiple_tool_calls=allow_multiple_tool_calls, | ||
| frequency_penalty=frequency_penalty, | ||
| logit_bias=logit_bias, | ||
| max_tokens=max_tokens, | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use this term it is for internal use only, just use the generic term declarative agents