๐ง Claude AI EnhancementsMarch 29, 2026โ
Tests passing
Claude Memory Importer
A utility to batch-upload custom datasets or memory snippets into Claude AI for personalized interactions. This tool helps developers pre-load domain-specific knowledge or project context to tailor Claude's responses to their exact needs.
What It Does
- Supports JSON and CSV input formats.
- Validates and sanitizes input data.
- Handles errors gracefully during data upload.
- Provides detailed upload results for each memory snippet.
Installation
Install the required Python package:
pip install pandasUsage
Run the script using the command line:
python claude_memory_importer.py --file <path_to_file> --api-key <your_api_key>Arguments
--file: Path to the input JSON or CSV file containing memory snippets.--api-key: Your Claude API key.
Example
python claude_memory_importer.py --file snippets.json --api-key your_api_keySource Code
import argparse
import pandas as pd
import os
class MockAnthropic:
def __init__(self, api_key):
self.api_key = api_key
def create_memory(self, content):
if "error" in content.lower():
raise Exception("API error")
return {"status": "success", "content": content}
def validate_and_sanitize_data(df):
"""
Validates and sanitizes the input data.
Args:
df (pd.DataFrame): DataFrame containing the memory snippets.
Returns:
pd.DataFrame: Sanitized DataFrame.
Raises:
ValueError: If required columns are missing or data is invalid.
"""
required_columns = ['id', 'content']
for col in required_columns:
if col not in df.columns:
raise ValueError(f"Missing required column: {col}")
# Drop rows with missing values in required columns
df = df.dropna(subset=required_columns)
# Ensure 'id' is unique
if not df['id'].is_unique:
raise ValueError("Duplicate IDs found in the input data.")
return df
def upload_memory_snippets(file_path, api_key):
"""
Batch uploads memory snippets to Claude AI.
Args:
file_path (str): Path to the input JSON or CSV file.
api_key (str): Claude API key.
Returns:
list: A list of results for each memory snippet upload.
"""
# Load the input file
try:
if file_path.endswith('.json'):
data = pd.read_json(file_path, lines=True)
elif file_path.endswith('.csv'):
data = pd.read_csv(file_path)
else:
raise ValueError("Unsupported file format. Only JSON and CSV are supported.")
except Exception as e:
raise ValueError(f"Error reading input file: {e}")
# Validate and sanitize the data
try:
data = validate_and_sanitize_data(data)
except ValueError as e:
raise ValueError(f"Data validation error: {e}")
# Initialize the Claude API client
client = MockAnthropic(api_key=api_key)
results = []
# Upload each memory snippet
for _, row in data.iterrows():
snippet_id = row['id']
content = row['content']
try:
response = client.create_memory(content=content)
results.append({"id": snippet_id, "status": "success", "response": response})
except Exception as e:
results.append({"id": snippet_id, "status": "error", "error": str(e)})
return results
def main():
parser = argparse.ArgumentParser(description="Claude Memory Importer: Batch-upload memory snippets to Claude AI.")
parser.add_argument('--file', required=True, help="Path to the input JSON or CSV file containing memory snippets.")
parser.add_argument('--api-key', required=True, help="Claude API key.")
args = parser.parse_args()
try:
results = upload_memory_snippets(args.file, args.api_key)
for result in results:
if result['status'] == 'success':
print(f"Snippet ID {result['id']} uploaded successfully.")
else:
print(f"Error uploading snippet ID {result['id']}: {result['error']}")
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
main()Community
Downloads
ยทยทยท
Rate this tool
No ratings yet โ be the first!
Details
- Tool Name
- claude_memory_importer
- Category
- Claude AI Enhancements
- Generated
- March 29, 2026
- Tests
- Passing โ
- Fix Loops
- 3
Quick Install
Clone just this tool:
git clone --depth 1 --filter=blob:none --sparse \ https://github.com/ptulin/autoaiforge.git cd autoaiforge git sparse-checkout set generated_tools/2026-03-29/claude_memory_importer cd generated_tools/2026-03-29/claude_memory_importer pip install -r requirements.txt 2>/dev/null || true python claude_memory_importer.py