Files
agent-framework/python/samples/getting_started/chat_client
T
Nico Möller 2f06fe557a Python : Ollama Connector for Agent Framework (#1104)
* Initial Commit for Olama Connector

* Added Olama Sample

* Add Sample & Fixed Open Telemetry

* Fixed Spelling from Olama to Ollama

* remove"opentelemetry-semantic-conventions-ai ~=0.4.13" since its handled in a different pr

* Added Tool Calling

* Finalizing test cases

* Adjust samples to be more reliable

* Update python/packages/ollama/agent_framework_ollama/_chat_client.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update python/packages/ollama/pyproject.toml

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update python/packages/ollama/tests/test_ollama_chat_client.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update python/packages/ollama/agent_framework_ollama/_chat_client.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Improved Docstrings & Sample

* Update python/packages/ollama/agent_framework_ollama/_chat_client.py

Co-authored-by: Eduard van Valkenburg <eavanvalkenburg@users.noreply.github.com>

* Integrate PR Feedback
- Divided Streaming and Non-Streaming into independent Methods
- Catch Ollama Validation Error
- Add OTEL Provider Name
- Checked Ollama Messages
- Add Usage Statistics

* Revert setting, so it can be none

* Validate Message formatting between AF and Ollama

* Catch Ollama Error and raise a ServiceResponse Error

* Fix mypy error

* remove .vscode comma

* Add Reasoning support & adjust to new structure

* Add Ollama Multimodality and Reasoning

* Add test cases for reasoning

* Add Tests for Error Handling in Ollama Client

* Update python/samples/getting_started/multimodal_input/ollama_chat_multimodal.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Integrated Copilot Feedback

* Implement first PR Feedback

* Adjust Readme files for examples

* Adjust argument passing via additional chat options

* Implemented PR Feedback

* Removing Ollama Package from Core and moving samples

* Fix Link & Adding Samples to Main Sample Readme

* Fixing Links in Readme

* Moved Multimodal and Chat Example

* Fixed Link in ChatClient to Ollama

* Fix AgentFramework Links in Ollama Project

* Fix observability breaking change

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Eduard van Valkenburg <eavanvalkenburg@users.noreply.github.com>
2f06fe557a · 2025-12-16 15:02:38 +00:00
History
..

Chat Client Examples

This folder contains simple examples demonstrating direct usage of various chat clients.

Examples

File Description
azure_assistants_client.py Direct usage of Azure Assistants Client for basic chat interactions with Azure OpenAI assistants.
azure_chat_client.py Direct usage of Azure Chat Client for chat interactions with Azure OpenAI models.
azure_responses_client.py Direct usage of Azure Responses Client for structured response generation with Azure OpenAI models.
chat_response_cancellation.py Demonstrates how to cancel chat responses during streaming, showing proper cancellation handling and cleanup.
azure_ai_chat_client.py Direct usage of Azure AI Chat Client for chat interactions with Azure AI models.
openai_assistants_client.py Direct usage of OpenAI Assistants Client for basic chat interactions with OpenAI assistants.
openai_chat_client.py Direct usage of OpenAI Chat Client for chat interactions with OpenAI models.
openai_responses_client.py Direct usage of OpenAI Responses Client for structured response generation with OpenAI models.

Environment Variables

Depending on which client you're using, set the appropriate environment variables:

For Azure clients:

  • AZURE_OPENAI_ENDPOINT: Your Azure OpenAI endpoint
  • AZURE_OPENAI_CHAT_DEPLOYMENT_NAME: The name of your Azure OpenAI chat deployment
  • AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME: The name of your Azure OpenAI responses deployment

For Azure AI client:

  • AZURE_AI_PROJECT_ENDPOINT: Your Azure AI project endpoint
  • AZURE_AI_MODEL_DEPLOYMENT_NAME: The name of your model deployment

For OpenAI clients:

  • OPENAI_API_KEY: Your OpenAI API key
  • OPENAI_CHAT_MODEL_ID: The OpenAI model to use for chat clients (e.g., gpt-4o, gpt-4o-mini, gpt-3.5-turbo)
  • OPENAI_RESPONSES_MODEL_ID: The OpenAI model to use for responses clients (e.g., gpt-4o, gpt-4o-mini, gpt-3.5-turbo)

For Ollama client:

  • OLLAMA_HOST: Your Ollama server URL (defaults to http://localhost:11434 if not set)
  • OLLAMA_CHAT_MODEL_ID: The Ollama model to use for chat (e.g., llama3.2, llama2, codellama)

Note

: For Ollama, ensure you have Ollama installed and running locally with at least one model downloaded. Visit https://ollama.com/ for installation instructions.