Skip to content

Python client (kernel-memory-client, kernel-memory-cli, semantic-kernel-memory-plugin) #1037

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
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

FabianSchurig
Copy link
Contributor

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.

@FabianSchurig FabianSchurig requested a review from dluc as a code owner March 23, 2025 20:26
Copy link
Contributor Author

@FabianSchurig FabianSchurig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self review done 👍🏻

@dluc
Copy link
Collaborator

dluc commented Mar 23, 2025

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

@FabianSchurig
Copy link
Contributor Author

@FabianSchurig
Copy link
Contributor Author

@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.

@dluc
Copy link
Collaborator

dluc commented Apr 25, 2025

@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.

@dluc dluc added the paused label May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants