Python client (kernel-memory-client, kernel-memory-cli, semantic-kernel-memory-plugin)
Microsoft Kernel Memory Python Libraries 🐍
This directory contains three Python packages that provide different ways to interact with Microsoft Kernel Memory:
📦 kernel-memory-client
An autogenerated Python client library for interacting with the Kernel Memory API. This client provides low-level access to all Kernel Memory endpoints and operations.
from kernel_memory_client import Client
# Create a client
client = Client(base_url="http://localhost:9001")
# Use the client to interact with Kernel Memory
# ...
Generation Info: The client was autogenerated using the OpenAPI specification (swagger.json) and the openapi-python-client tool:
cd clients/python/kernel-memory-cli
openapi-python-client generate --path ../../swagger.json --config openapi-python-generator-config.yml --overwrrite
Note: The following patch was applied to fix the document upload functionality:
# clients/python/kernel-memory-client/kernel_memory_client/models/upload_document_body.py
@@ -1,11 +1,3 @@
files: Union[Unset, tuple[None, bytes, str]] = UNSET
if not isinstance(self.files, Unset):
- _temp_files = []
- for files_item_data in self.files:
- files_item = files_item_data.to_tuple()
-
- _temp_files.append(files_item)
- files = (None, json.dumps(_temp_files).encode(), "application/json")
-
+ files = files
🖥️ kernel-memory-cli
A command-line interface for Microsoft Kernel Memory that provides an easy way to interact with Kernel Memory services from the terminal.
# Install the CLI
pip install kernel-memory-cli
# Configure the CLI
kernel-memory config --base-url http://localhost:9001
# Upload a document
kernel-memory upload mydocument.pdf
# Search for information
kernel-memory search "my query"
# Ask questions about your documents
kernel-memory ask "What does my document say about machine learning?"
The CLI offers intuitive commands for configuring connections, uploading documents, searching content, and asking questions about your indexed documents.
🔌 semantic-kernel-memory-plugin
A plugin that integrates Kernel Memory with Semantic Kernel, allowing you to use Kernel Memory's document processing and retrieval capabilities within your Semantic Kernel applications.
from semantic_kernel import Kernel
from semantic_kernel_memory_plugin.memory_plugin import MemoryPlugin
from kernel_memory_client import Client, AuthenticatedClient
# Create a Semantic Kernel instance
kernel = Kernel()
# Add the Kernel Memory plugin
memory_client = AuthenticatedClient(
base_url="http://localhost:9001")
memory_plugin = MemoryPlugin(memory_client=memory_client)
kernel.add_plugin(memory_plugin)
# Now use Kernel Memory capabilities in your Semantic Kernel app
# ...
This plugin bridges the powerful memory capabilities of Kernel Memory with the flexible AI orchestration of Semantic Kernel.
Could you provide details about the process to autogenerate these files?
We need to add the usual copyright header to these files, even if autogenerated. Does the tool allow that, otherwise we'll have to do it manually.
Thanks
@dluc Generation info is in README https://github.com/FabianSchurig/kernel-memory/tree/python-client/clients/python#generation-info
@dluc License headers are automatically added via pre-commit hook. https://github.com/FabianSchurig/kernel-memory/blob/python-client/.pre-commit-config.yaml
@dluc Could we merge this, please. I would also like to add an MCP Server next. It would be great to have the Python Packages published.
Do you want to publish on pypi microsoft? I could also publish them on my pypi if it is less overhead for you.
@FabianSchurig thanks for this. It's quite a bit of new code to maintain, and we don't have the resources to merge it into the repo and ensure it stays up to date as things evolve.
I think the best approach is to keep the client in a separate repo on your account, and add a reference to it here, along with some docs on how to use the package.
Closing as part of repository maintenance - no further action planned on this issue.