-
Notifications
You must be signed in to change notification settings - Fork 730
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
Open
eavanvalkenburg
wants to merge
15
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,928
−7
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
92c0906
first work on declarative
eavanvalkenburg c0ac17d
initial version of the declarative support
eavanvalkenburg a2f25ee
fix tests and mypy
eavanvalkenburg 5752dda
fix parameters of functiontool
eavanvalkenburg 66311ef
slight logic improvement
eavanvalkenburg 06fbe34
remove path until merge
eavanvalkenburg 3d279d9
updates from comments
eavanvalkenburg 0378069
create dispatcher and spec type, json_schema method
eavanvalkenburg ab7a0a7
fix mypy, skipping model
eavanvalkenburg a38d503
updated lock
eavanvalkenburg 1c8aa67
fixed declarative tests and renamed some other test files
eavanvalkenburg 6d447ca
refined loader
eavanvalkenburg 652fb01
updated lock
eavanvalkenburg b885fa5
fix mypy
eavanvalkenburg 644c9d6
added readme to samples folder
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 | ||
| 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
| 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.
File renamed without changes.
File renamed without changes.
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.