-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
95f8592
first work on declarative
eavanvalkenburg 26a3ae4
initial version of the declarative support
eavanvalkenburg 68ab87b
fix tests and mypy
eavanvalkenburg 03aa162
fix parameters of functiontool
eavanvalkenburg 674c863
slight logic improvement
eavanvalkenburg aa90a63
remove path until merge
eavanvalkenburg 5bf781e
updates from comments
eavanvalkenburg b8fcb84
create dispatcher and spec type, json_schema method
eavanvalkenburg daee2ab
fix mypy, skipping model
eavanvalkenburg 70b3326
updated lock
eavanvalkenburg 481b9a1
fixed declarative tests and renamed some other test files
eavanvalkenburg 50e80a9
refined loader
eavanvalkenburg c7e7c6f
updated lock
eavanvalkenburg 1d19a8a
fix mypy
eavanvalkenburg 4654e06
added readme to samples folder
eavanvalkenburg 1210364
fixes from review
eavanvalkenburg bec3f6e
undid test file rename
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 agent support, for python see the [declarative agent python sample folder](../python/samples/getting_started/declarative/). |
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,27 @@ | ||
| 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: | ||
| properties: | ||
| 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 | ||
eavanvalkenburg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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 | ||
eavanvalkenburg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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 |
|---|---|---|
|
|
@@ -59,6 +59,7 @@ | |
| "OPENAI", | ||
| "opentelemetry", | ||
| "OTEL", | ||
| "powerfx", | ||
| "protos", | ||
| "pydantic", | ||
| "pytestmark", | ||
|
|
||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
23 changes: 23 additions & 0 deletions
23
python/packages/core/agent_framework/declarative/__init__.py
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,23 @@ | ||
| # Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| import importlib | ||
| from typing import Any | ||
|
|
||
| IMPORT_PATH = "agent_framework_declarative" | ||
| PACKAGE_NAME = "agent-framework-declarative" | ||
| _IMPORTS = ["__version__", "AgentFactory", "DeclarativeLoaderError", "ProviderLookupError", "ProviderTypeMapping"] | ||
|
|
||
|
|
||
| def __getattr__(name: str) -> Any: | ||
| if name in _IMPORTS: | ||
| try: | ||
| return getattr(importlib.import_module(IMPORT_PATH), name) | ||
| except ModuleNotFoundError as exc: | ||
| raise ModuleNotFoundError( | ||
| f"The '{PACKAGE_NAME}' package is not installed, please do `pip install {PACKAGE_NAME}`" | ||
| ) from exc | ||
| raise AttributeError(f"Module {IMPORT_PATH} has no attribute {name}.") | ||
|
|
||
|
|
||
| def __dir__() -> list[str]: | ||
| return _IMPORTS |
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.
Uh oh!
There was an error while loading. Please reload this page.