-
Notifications
You must be signed in to change notification settings - Fork 680
Python : Ollama Connector for Agent Framework #1104
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
nmoeller
wants to merge
42
commits into
microsoft:main
Choose a base branch
from
nmoeller:features/python_olama_connector
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.
+1,364
−8
Open
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
06828ee
Initial Commit for Olama Connector
nmoeller 02c4852
Merge remote-tracking branch 'origin/main' into nmoeller/olamaconnector
nmoeller beab7d4
Added Olama Sample
nmoeller 80cf98d
Add Sample & Fixed Open Telemetry
nmoeller afc7190
Fixed Spelling from Olama to Ollama
nmoeller cbdb533
remove"opentelemetry-semantic-conventions-ai ~=0.4.13" since its hand…
nmoeller c1f2ee6
Merge branch 'main' into features/python_olama_connector
nmoeller 3518527
Added Tool Calling
nmoeller 545b52e
Merge remote-tracking branch 'origin/main' into features/python_olama…
nmoeller 9c93812
Merge remote-tracking branch 'origin/main' into features/python_olama…
nmoeller 460be3c
Finalizing test cases
nmoeller 1c4115a
Merge branch 'main' into features/python_olama_connector
nmoeller 279392d
Adjust samples to be more reliable
nmoeller efac8b7
Merge branch 'features/python_olama_connector' of https://github.com/…
nmoeller 0e62fd8
Update python/packages/ollama/agent_framework_ollama/_chat_client.py
nmoeller ea7f1d5
Update python/packages/ollama/pyproject.toml
nmoeller 0abeec6
Update python/packages/ollama/tests/test_ollama_chat_client.py
nmoeller d2e2f1b
Update python/packages/ollama/agent_framework_ollama/_chat_client.py
nmoeller 133fd12
Improved Docstrings & Sample
nmoeller 22e7438
Merge branch 'features/python_olama_connector' of https://github.com/…
nmoeller 8a78094
Update python/packages/ollama/agent_framework_ollama/_chat_client.py
nmoeller f96f817
Integrate PR Feedback
nmoeller 9a09b52
Merge branch 'features/python_olama_connector' of https://github.com/…
nmoeller d28bea0
Revert setting, so it can be none
nmoeller 1030b50
Validate Message formatting between AF and Ollama
nmoeller 290d2f7
Catch Ollama Error and raise a ServiceResponse Error
nmoeller 883e51a
Merge remote-tracking branch 'origin/main' into features/python_olama…
nmoeller 79933f8
Fix mypy error
nmoeller 604b545
remove .vscode comma
nmoeller 2e0da1e
Merge remote-tracking branch 'origin/main' into features/python_olama…
nmoeller d180c2c
Add Reasoning support & adjust to new structure
nmoeller c09242b
Add Ollama Multimodality and Reasoning
nmoeller f0bc638
Add test cases for reasoning
nmoeller 9d39405
Merge branch 'main' into features/python_olama_connector
nmoeller 83ba556
Add Tests for Error Handling in Ollama Client
nmoeller 9df622e
Update python/samples/getting_started/multimodal_input/ollama_chat_mu…
nmoeller 3c697dc
Merge branch 'features/python_olama_connector' of https://github.com/…
nmoeller ce819ef
Integrated Copilot Feedback
nmoeller 637f2a8
Merge branch 'main' into features/python_olama_connector
nmoeller 1eecd6d
Implement first PR Feedback
nmoeller 14614c7
Adjust Readme files for examples
nmoeller e74dd4e
Adjust argument passing via additional chat options
nmoeller 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
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 @@ | ||
| # Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| import importlib | ||
| from typing import Any | ||
|
|
||
| PACKAGE_NAME = "agent_framework_ollama" | ||
| PACKAGE_EXTRA = "ollama" | ||
| _IMPORTS = [ | ||
| "OllamaChatClient", | ||
| "OllamaSettings", | ||
| "__version__", | ||
| ] | ||
|
|
||
|
|
||
| def __getattr__(name: str) -> Any: | ||
| if name in _IMPORTS: | ||
| try: | ||
| return getattr(importlib.import_module(PACKAGE_NAME), name) | ||
| except ModuleNotFoundError as exc: | ||
| raise ModuleNotFoundError( | ||
| f"The '{PACKAGE_EXTRA}' extra is not installed, please do `pip install agent-framework-{PACKAGE_EXTRA}`" | ||
| ) from exc | ||
| raise AttributeError(f"Module {PACKAGE_NAME} has no attribute {name}.") | ||
|
|
||
|
|
||
| def __dir__() -> list[str]: | ||
| return _IMPORTS |
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,13 @@ | ||
| # Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| from agent_framework_ollama import ( | ||
| OllamaChatClient, | ||
| OllamaSettings, | ||
| __version__, | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "OllamaChatClient", | ||
| "OllamaSettings", | ||
| "__version__", | ||
| ] |
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 |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) Microsoft Corporation. | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE |
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,9 @@ | ||
| # Get Started with Microsoft Agent Framework Ollama | ||
|
|
||
| Please install this package as the extra for `agent-framework`: | ||
|
|
||
| ```bash | ||
| pip install agent-framework-ollama --pre | ||
| ``` | ||
|
|
||
| and see the [README](https://github.com/microsoft/agent-framework/tree/main/python/README.md) for more information. |
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,16 @@ | ||
| # Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| import importlib.metadata | ||
|
|
||
| from ._chat_client import OllamaChatClient, OllamaSettings | ||
|
|
||
| try: | ||
| __version__ = importlib.metadata.version(__name__) | ||
| except importlib.metadata.PackageNotFoundError: | ||
| __version__ = "0.0.0" # Fallback for development mode | ||
|
|
||
| __all__ = [ | ||
| "OllamaChatClient", | ||
| "OllamaSettings", | ||
| "__version__", | ||
| ] |
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.
please don't add things without first discussing why we need this, not saying we won't need this, but we don't want to just add stuff for everything.
Uh oh!
There was an error while loading. Please reload this page.
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.
Let me share my thought when I was adding this and why it could be useful :
These were just my idea for adding this to the core package, like I said very happy to implement this just in the Ollama Package.