### Knowledge Discovery and Pattern Recognition Examples Source: https://github.com/lpalbou/abstractllm/blob/main/docs/misc/LanceDB_User_Guide.md Illustrates effective strategies for knowledge discovery using /search and /similar commands, including starting broad and narrowing down topics, and finding recurring issues or solution patterns. ```bash # Start broad, then narrow /search programming /search Python programming /search Python async programming # Use similarity for discovery /similar "decorator pattern" /similar "async await best practices" # Find recurring issues /search error TypeError # Analyze solution patterns /similar "fixed the bug by" ``` -------------------------------- ### AbstractLLM Memory System Usage Examples (Python) Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-20-large-refactor.txt Provides practical examples of how to use the AbstractLLM memory system. It covers basic initialization, starting reasoning cycles, adding chat messages, retrieving context for queries, querying memory, checking system health, and persisting data across sessions. ```python # Basic usage memory = HierarchicalMemory() cycle = memory.start_react_cycle("Complex reasoning task") memory.add_chat_message("user", "Explain machine learning") # Advanced features context = memory.get_context_for_query("ML concepts", max_tokens=2000) results = memory.query_memory("machine learning", max_results=10) health = memory.get_memory_health_report() # Cross-session persistence memory.save_to_disk() # Automatically saves cross-session knowledge ``` -------------------------------- ### Running the ALMA-Simple Agent Example Source: https://github.com/lpalbou/abstractllm/blob/main/README.md Shows command-line examples for running the `alma-simple.py` script, demonstrating interactive use, provider switching, and prompt execution with different models. ```bash # Interactive agent with memory and tools python alma-simple.py ``` ```bash # Single query with provider switching python alma-simple.py --provider openai --model gpt-4o-mini \ --prompt "list the files in the current directory" ``` ```bash # Use enhanced models that work well python alma-simple.py --provider ollama --model qwen3-coder:30b \ --prompt "read README.md and summarize it" ``` -------------------------------- ### Effective Search Query Examples Source: https://github.com/lpalbou/abstractllm/blob/main/docs/misc/LanceDB_User_Guide.md Demonstrates how to construct effective search queries in AbstractLLM, moving from specific keywords to more contextual and natural language-based searches for better results. ```bash # Good: Specific and descriptive /search React hooks useState debugging # Better: Include context /search React functional components state management # Best: Natural language with intent /search "why is my React component not re-rendering when state changes" ``` -------------------------------- ### AbstractLLM Reset Command Examples Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-16-lancedb2.txt This section provides examples of how to use the new reset commands in AbstractLLM. It demonstrates the interactive prompts and expected outputs for both the current session reset and the complete storage purge. ```text 1. Current Session Reset (/reset) alma> /reset ⚠️ This will reset current session data (messages, memory, history) Continue? [y/N]: y ✅ Current session reset Resets: - Current conversation history - Working memory and knowledge graph - Command history Preserves: - All LanceDB storage (other sessions intact) - Embeddings cache for performance - Cross-session knowledge and user data 2. Complete Storage Purge (/reset full) alma> /reset full ``` -------------------------------- ### Time-Based Analysis Examples Source: https://github.com/lpalbou/abstractllm/blob/main/docs/misc/LanceDB_User_Guide.md Provides examples of using the /timeframe command for various analysis needs, including daily, work session, and specific task or meeting timeframes. ```bash # Daily analysis /timeframe 2025-09-15T00:00 2025-09-15T23:59 # Work session analysis /timeframe 2025-09-15T09:00 2025-09-15T17:00 # Specific meeting or task /timeframe 2025-09-15T14:00 2025-09-15T15:30 ``` -------------------------------- ### Install AbstractLLM with Core and Provider-Specific Packages Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-16-stream-tool-multiturn.txt Installs the AbstractLLM library with options for various provider integrations. The core installation includes basic features, while specific extras like '[openai]', '[anthropic]', '[ollama]', '[huggingface]', '[mlx]', and '[tools]' add support for different LLM providers and functionalities. A comprehensive '[all]' installation is also available. ```bash pip install abstractllm pip install "abstractllm[openai]" # OpenAI API support pip install "abstractllm[anthropic]" # Anthropic/Claude API support pip install "abstractllm[ollama]" # Ollama local models pip install "abstractllm[huggingface]" # HuggingFace models pip install "abstractllm[mlx]" # Apple Silicon MLX support pip install "abstractllm[tools]" # Enhanced tool system pip install "abstractllm[all]" # All providers (MLX will install on Apple Silicon only) ``` -------------------------------- ### AbstractLLM CLI Usage Examples Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-17-lmstudio-provider.txt Examples demonstrating how to use the AbstractLLM CLI with new defaults and advanced parameter configurations. This includes basic usage with provider selection, setting SOTA parameters, and configuring large context tasks. ```bash # Now uses 8K output tokens and 32K context automatically alma --provider lmstudio --model "qwen/qwen3-next-80b" --prompt "Write detailed explanation" ``` ```bash # All parameters work with centralized config alma --provider lmstudio --seed 12345 --temperature 0.1 --top-p 0.8 --max-tokens 6000 ``` ```bash # Large context tasks alma --provider lmstudio --max-input-tokens 16384 --prompt "Analyze large document" ``` -------------------------------- ### AbstractLLM CLI Usage Examples Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-19-following-potential-bad-trail.txt Examples of using the AbstractLLM CLI to interact with the LM Studio provider, demonstrating basic usage, deterministic generation, and advanced local model parameter tuning. ```bash # Basic usage with enhanced defaults alma --provider lmstudio --model "qwen/qwen3-next-80b" --prompt "Write a detailed explanation" # Deterministic generation alma --provider lmstudio --seed 12345 --temperature 0.1 --prompt "Generate code" # Creative generation with controls alma --provider lmstudio --temperature 0.8 --top-p 0.9 --frequency-penalty 0.3 # High output with context alma --provider lmstudio --max-tokens 6000 --max-input-tokens 16384 # Local model specific parameters alma --provider lmstudio --top-k 40 --repetition-penalty 1.1 --prompt "Creative writing" ``` -------------------------------- ### Start Interactive CLI Mode Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-16-lancedb2.txt Illustrates how to start the AbstractLLM CLI in interactive mode, specifying a provider and model. In this mode, users can input complex questions that leverage tools. ```bash alma --provider ollama --model qwen3-coder:30b user> [any complex question with tools] ``` -------------------------------- ### Example of parsed tool call format Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-19-next.txt An example demonstrating how the enhanced parser handles a bare tool call format while preserving preceding conversational text. ```text I apologize for the oversight. Let me list the files. |tool_call|{"name": "list_files", "arguments": {"directory_path": "."}}|> ``` -------------------------------- ### Configure HuggingFace LLM Providers (Python) Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-16-eval.txt This code example demonstrates how to integrate open-source models from HuggingFace using the `create_llm` function. It includes examples for Qwen3-4B and Microsoft's Phi-4-mini-instruct models. ```python llm = create_llm("huggingface", model="Qwen/Qwen3-4B") llm = create_llm("huggingface", model="microsoft/Phi-4-mini-instruct") ``` -------------------------------- ### Initialize AbstractLLM package Source: https://github.com/lpalbou/abstractllm/blob/main/docs/refactoring/refactoring-implementation-guide.md Defines the setup configuration for the AbstractLLM package, specifying dependencies like OpenAI, Anthropic, and Pydantic. This script creates the distribution metadata required for installation. ```python from setuptools import setup, find_packages setup( name="abstractllm", version="2.0.0", packages=find_packages(), install_requires=[ "openai>=1.0.0", "anthropic>=0.5.0", "requests", "pydantic>=2.0.0" ], python_requires=">=3.8", ) ``` -------------------------------- ### Add LanceDB Usage Examples to Help Output Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-16-lancedb1.txt Extends the help command's example list to include practical demonstrations of LanceDB search queries. This ensures users have clear references for using semantic search and observability tools. ```python examples = [ # Core session management "/save my_session.pkl", "/load my_session.pkl", "/memory 16384", "/temperature 0.3", "/system You are a helpful coding assistant", # LanceDB semantic search examples "/search debugging cache problems", "/search machine learning --from 2025-09-01", "/timeframe 2025-09-15T10:00 2025-09-15T12:15", "/similar how to optimize database queries", "/search error handling --user alice --limit 5", # Memory and observability "/working", "/facts machine learning", "/links", "/context", "/stats" ] ``` -------------------------------- ### Install AbstractLLM Dependencies Source: https://github.com/lpalbou/abstractllm/blob/main/docs/misc/LanceDB_User_Guide.md Installs the necessary Python packages including LanceDB, sentence-transformers, and data processing libraries required for the CLI. ```bash pip install lancedb sentence-transformers numpy pandas pyarrow alma ``` -------------------------------- ### Usage Examples for LLM and Agent Initialization Source: https://github.com/lpalbou/abstractllm/blob/main/docs/final-refactoring/01-architecture-final.md Demonstrates how to initialize simple LLM calls, basic conversations, and full agents using the updated AbstractLLM and AbstractAgent APIs. ```python # Simple LLM call from abstractllm import create_llm llm = create_llm('openai') response = llm.generate("Hello") # Basic Conversation from abstractllm import create_llm, BasicSession llm = create_llm('openai') session = BasicSession(llm) # Full Agent from abstractagent import Agent agent = Agent( llm_config={'provider': 'openai'}, memory_config={'temporal': True} ) ``` -------------------------------- ### Install LanceDB Dependencies Source: https://github.com/lpalbou/abstractllm/blob/main/docs/misc/LanceDB_User_Guide.md Required Python packages for enabling observability features in AbstractLLM. This command installs the LanceDB vector database and sentence-transformers for embedding generation. ```bash pip install lancedb sentence-transformers ``` -------------------------------- ### Run ALMA-Simple Agent Example Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-16-stream-tool-multiturn.txt Provides command-line examples for running the `alma-simple.py` agent script. This script demonstrates an agent with memory, reasoning, and tool capabilities. Options include interactive mode, single query execution with provider switching, and using specific models for coding tasks. ```bash # Interactive agent with memory and tools python alma-simple.py # Single query with provider switching python alma-simple.py --provider openai --model gpt-4o-mini \ --prompt "list the files in the current directory" # Use enhanced models that work well python alma-simple.py --provider ollama --model qwen3-coder:30b \ --prompt "read README.md and summarize it" ``` -------------------------------- ### Configure LM Studio Provider via CLI Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-17-lmstudio-provider.txt Examples of using the 'alma' CLI to interact with the LM Studio provider, demonstrating how to set generation parameters such as temperature, token limits, and penalties. ```bash alma --provider lmstudio --seed 12345 --temperature 0.1 --prompt "Generate code" alma --provider lmstudio --temperature 0.8 --top-p 0.9 --frequency-penalty 0.3 alma --provider lmstudio --max-tokens 6000 --max-input-tokens 16384 alma --provider lmstudio --top-k 40 --repetition-penalty 1.1 --prompt "Creative writing" ``` -------------------------------- ### Enhance Tool Prompt Examples Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/tool_system_analysis.md Provides explicit examples in the system prompt to guide the LLM on correct parameter naming, reducing confusion between similar function arguments. ```text Example 1: <|tool_call|>{"name": "list_files", "arguments": {"directory_path": "docs"}} Example 2: <|tool_call|>{"name": "read_file", "arguments": {"file_path": "example.txt"}} ``` -------------------------------- ### Setup Development Environment Source: https://github.com/lpalbou/abstractllm/blob/main/CONTRIBUTING.md Commands to clone the repository, initialize a Python virtual environment, and install the necessary development dependencies. ```bash git clone https://github.com/lpalbou/abstractllm.git cd abstractllm python -m venv venv source venv/bin/activate pip install -e ".[dev]" ``` -------------------------------- ### ALMA-Simple Agent Command-Line Examples (Bash) Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-16-stream-tool-multiturn.txt Provides examples of using the ALMA-Simple agent from the command line with various LLM providers (Anthropic, OpenAI, Ollama). It covers basic usage, prompt engineering, memory persistence, interactive mode, and controlling tool usage. ```bash # Basic usage with different providers python alma-simple.py --provider anthropic --model claude-3-5-haiku-20241022 \ --prompt "list the files in the current directory" python alma-simple.py --provider openai --model gpt-4o-mini \ --prompt "read README.md and summarize the key features" python alma-simple.py --provider ollama --model qwen3-coder:30b \ --prompt "analyze the project structure" # Advanced usage with memory persistence python alma-simple.py --memory agent_memory.pkl \ --prompt "Remember that I'm working on an AI project" # Interactive mode with verbose logging python alma-simple.py --verbose # Control tool usage iterations python alma-simple.py --max-tool-calls 10 \ --prompt "carefully examine each file in the project" ``` ```bash # OpenAI - Supported models through manual provider improvements python alma-simple.py --provider openai --model gpt-4o-mini \ --prompt "list files" --max-tool-calls 3 python alma-simple.py --provider openai --model gpt-4o \ --prompt "list files" --max-tool-calls 3 # Anthropic - Reliable and fast python alma-simple.py --provider anthropic --model claude-3-5-haiku-20241022 \ --prompt "list files" --max-tool-calls 3 # Ollama - Excellent open-source option python alma-simple.py --provider ollama --model qwen3:4b \ --prompt "read README.md and summarize it" # HuggingFace - Direct model usage python alma-simple.py --provider huggingface --model Qwen/Qwen3-4B \ --prompt "list the files" # MLX - Apple Silicon optimized python alma-simple.py --provider mlx --model mlx-community/GLM-4.5-Air-4bit \ --prompt "list files" ``` -------------------------------- ### Initialize and query an LLM instance Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-17-lancedb3-search-embedding.txt Demonstrates how to create an LLM instance using a specified provider and model, followed by a text generation request. This pattern abstracts the underlying provider implementation details. ```python # Create an LLM instance llm = create_llm("openai", model="gpt-4o-mini") response = llm.generate("Explain quantum computing briefly.") ``` -------------------------------- ### Markdown Documentation: Refactoring Implementation Guide Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-20-large-refactor.txt This markdown document serves as an actionable guide for refactoring the AbstractLLM project. It provides specific commands and code snippets that can be directly used during the implementation phase. It includes a pre-refactoring checklist, starting with backing up the entire project. ```markdown # AbstractLLM Refactoring Implementation Guide *Actionable steps with exact commands and code* ## Pre-Refactoring Checklist ### 1. Backup Everything ```bash # Create complete backup cd /Users/albou/projects ... ``` ## Implementation Steps ... ``` -------------------------------- ### Install and Test AbstractLLM CLI Source: https://github.com/lpalbou/abstractllm/blob/main/docs/final-refactoring/task_04_create_agent_package.md Commands to install the AbstractLLM CLI in development mode and test its basic usage. Includes examples for showing help, running in interactive mode with specific providers/models, and executing a single prompt. ```bash # Install in development mode pip install -e . # Test CLI alma --help # Interactive mode alma --provider ollama --model llama2 # Single prompt alma --prompt "Hello" --provider openai ``` -------------------------------- ### Deprecated Method Wrapper Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-19-single-unified-generate.txt Example of how to maintain backward compatibility while transitioning to the unified API. This pattern uses a deprecation warning to guide users toward the new interface. ```python import warnings def generate_with_tools_streaming(self, *args, **kwargs): warnings.warn("Deprecated: Use generate(stream=True) instead", DeprecationWarning) return self.generate(*args, stream=True, **kwargs) ``` -------------------------------- ### Register and Handle Tools Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-20-large-refactor.txt Demonstrates the simplified tool system, showing how to register a tool function and create a handler for a specific model. ```python from abstractllm.tools import create_handler, register @register def search(query: str) -> str: return f"Results for: {query}" handler = create_handler("gpt-4") request = handler.prepare_request(tools=[search]) ``` -------------------------------- ### Deploy and Publish Packages Source: https://github.com/lpalbou/abstractllm/blob/main/docs/refactoring/refactoring-implementation-guide.md Shell commands to build, verify, and test the installation of the modular packages using setuptools and twine. This workflow ensures that the packages are correctly packaged for distribution. ```bash python setup.py sdist bdist_wheel twine check dist/* pip install ./abstractagent/dist/abstractagent-1.0.0.tar.gz ``` -------------------------------- ### Run AbstractLLM Agent Examples (Bash) Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-16-eval.txt Provides bash commands to run the `alma-simple.py` agent example. It shows how to interactively use the agent, switch providers, and use specific models for tasks like listing files or summarizing documents. ```bash # Interactive agent with memory and tools python alma-simple.py # Single query with provider switching python alma-simple.py --provider openai --model gpt-4o-mini \ --prompt "list the files in the current directory" # Use enhanced models that work well python alma-simple.py --provider ollama --model qwen3-coder:30b \ --prompt "read README.md and summarize it" ``` -------------------------------- ### HierarchicalMemory Usage Example in Python Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-20-large-refactor.txt Demonstrates how to initialize and use the HierarchicalMemory class for advanced reasoning, context retrieval, and cross-session persistence. It covers starting ReAct cycles, adding thoughts and actions, and saving memory to disk. ```python from abstractllm.memory import HierarchicalMemory # Enhanced memory with all features memory = HierarchicalMemory( working_memory_size=10, enable_cross_session_persistence=True ) # Advanced ReAct reasoning cycle = memory.start_react_cycle("Complex multi-step task") cycle.add_thought("Planning approach", confidence=0.9) action_id = cycle.add_action("analyze", {...}, "Gathering data") cycle.add_observation(action_id, results, success=True) # Intelligent context for LLM prompting context = memory.get_context_for_query("task context", max_tokens=2000) # Cross-session knowledge persistence memory.save_to_disk() # Preserves important knowledge ``` -------------------------------- ### Defining and Using Enhanced Tools in Python Source: https://github.com/lpalbou/abstractllm/blob/main/docs/reports/report-new-features.md Provides a guide on how to define an enhanced tool using `EnhancedToolDefinition` with parameters and examples, and then integrate it into a session created with `create_session`. This allows for more sophisticated tool interactions with LLMs. ```python from abstractllm import create_llm, create_session from abstractllm.tools.enhanced_core import EnhancedToolDefinition, ParameterSchema # Define enhanced tool tool = EnhancedToolDefinition( name="search", description="Search the codebase", parameters={ "query": ParameterSchema( type="string", description="Search query" ) }, examples=[...] ) # Use with session session = create_session(provider=create_llm("ollama")) response = session.generate( "Search for test files", tools=[tool] ) ``` -------------------------------- ### Flexible Logging Setup and Usage Source: https://github.com/lpalbou/abstractllm/blob/main/abstractllm/utils/CLAUDE.md Shows how to set up and use the logging system, which allows for independent control of console and file logging levels. It also demonstrates logging requests and responses. ```python from abstractllm.utils.logging import setup_logging, log_request, log_response # Separate console/file control setup_logging(console_level="INFO", file_level="DEBUG") provider = "openai" prompt = "Hello" params = {"temperature": 0.7} response = {"content": "Hi there!"} duration = 0.5 log_request(provider, prompt, params) log_response(provider, response, duration) ``` -------------------------------- ### Setup Project Directory Structure Source: https://github.com/lpalbou/abstractllm/blob/main/docs/final-refactoring/UNIFIED_IMPLEMENTATION_GUIDE.md Initializes the project directory structure for the AbstractMemory package using standard bash commands. This sets up the necessary subdirectories for core components, graph, cognitive, and storage. ```bash cd /Users/albou/projects mkdir -p abstractmemory cd abstractmemory mkdir -p abstractmemory/{core,components,graph,cognitive,storage} ``` -------------------------------- ### Execute LLM via CLI Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-19-following-potential-bad-trail.txt Command-line interface examples for interacting with AbstractLLM providers. Demonstrates how to use default settings, override parameters, and configure context window sizes. ```bash # Basic usage with provider defaults alma --provider lmstudio --model "qwen/qwen3-next-80b" --prompt "Write detailed explanation" # Usage with custom SOTA parameters alma --provider lmstudio --seed 12345 --temperature 0.1 --top-p 0.8 --max-tokens 6000 # Usage with specific context configuration alma --provider lmstudio --max-input-tokens 16384 --prompt "Analyze large document" ``` -------------------------------- ### AI Assistant Tool Call Examples Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-16-stream-tool-multiturn.txt This snippet demonstrates how to invoke the 'read_file', 'list_files', and 'write_file' tools using the specified '<|tool_call|>' format. It includes examples for reading entire files, specific line ranges, listing files with patterns, and writing content to files. ```tool_call <|tool_call|>{"name": "read_file", "arguments": {"file_path": "example.txt"}} <|tool_call|>{"name": "read_file", "arguments": {"file_path": "large.txt", "should_read_entire_file": false, "start_line_one_indexed": 10, "end_line_one_indexed_inclusive": 20}} <|tool_call|>{"name": "list_files", "arguments": {"directory_path": "docs"}} <|tool_call|>{"name": "list_files", "arguments": {"directory_path": "src", "pattern": "*.py", "recursive": true}} <|tool_call|>{"name": "write_file", "arguments": {"file_path": "output.txt", "content": "Hello World"}} <|tool_call|>{"name": "write_file", "arguments": {"file_path": "log.txt", "content": "Error occurred", "mode": "a"}} ``` -------------------------------- ### Get Entity Relationship Evolution Over Time (Python) Source: https://github.com/lpalbou/abstractllm/blob/main/docs/final-refactoring/task_03_create_memory_package.md Tracks how an entity's relationships have evolved within a graph over a specified time period. It identifies facts added or invalidated for the entity between a start and end datetime. ```python def get_entity_evolution(self, entity: str, start: datetime, end: datetime) -> List[Dict[str, Any]]: """Track how entity's relationships evolved over time""" # Find entity node entity_id = None for node_id, data in self.graph.nodes(data=True): if data.get('value') == entity: entity_id = node_id break if not entity_id: return [] evolution = [] # Check all edges involving this entity for u, v, key, data in self.graph.edges(keys=True, data=True): if u == entity_id or v == entity_id: anchor = data.get('anchor') if anchor and start <= anchor.event_time <= end: evolution.append({ 'time': anchor.event_time, 'type': 'fact_added' if data.get('valid') else 'fact_invalidated', 'subject': self.graph.nodes[u]['value'], 'predicate': data['predicate'], 'object': self.graph.nodes[v]['value'] }) return sorted(evolution, key=lambda x: x['time']) ``` -------------------------------- ### Document AbstractLLM Reset Options in LanceDB User Guide Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-16-lancedb2.txt This snippet shows the additions made to the `LanceDB_User_Guide.md` file to document the new storage reset options. It includes markdown formatting for 'Storage Reset Options', 'Current Session Reset', and 'Complete Storage Purge' with explanations and usage examples. ```markdown /export session_analysis.json ``` + ### Storage Reset Options + AbstractLLM provides flexible reset capabilities for different scenarios: + + #### Current Session Reset + ```bash + # Reset only the current session (preserves all other sessions) + /reset + ``` + **What it does:** + - Clears current conversation history + - Resets working memory and knowledge graph + - Preserves all LanceDB storage (other sessions remain intact) + - Maintains embeddings cache for performance + + #### Complete Storage Purge + ```bash + # ⚠️ WARNING: Permanently deletes ALL storage across all sessions + /reset full + ``` + **What it does:** + - **PERMANENTLY DELETES** all sessions from all users + - Removes all interaction history with embeddings + - Deletes all ReAct cycles and reasoning traces + - Purges complete LanceDB database + - Removes all cached embeddings + - Reinitializes fresh storage + + **Safety Features:** + - Requires typing "DELETE" to confirm + - Double confirmation with "yes" + - Cannot be undone + - Clear warnings about permanent data loss + + **Use Cases:** + - `/reset` - Start fresh conversation while keeping history + - `/reset full` - Complete privacy purge or troubleshooting + --- ``` -------------------------------- ### Basic AbstractLLM CLI Usage with LM Studio Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-17-lmstudio-provider.txt Demonstrates fundamental command-line interface (CLI) interactions with AbstractLLM when using the LM Studio provider. This includes specifying the provider, model, and a simple prompt. ```bash alma --provider lmstudio --model "qwen/qwen3-next-80b" --prompt "Hello!" ``` -------------------------------- ### Package Setup Files (Python) Source: https://github.com/lpalbou/abstractllm/blob/main/docs/refactoring/revised-library-separation-analysis.md This code shows the 'setup.py' configurations for each of the AbstractLLM packages: abstractllm, abstractmemory, and abstractagent. It defines the package name, version, and external dependencies for each, ensuring proper installation and management within a Python environment. The dependencies clearly reflect the architectural design. ```python # setup.py for each package # abstractllm/setup.py setup( name="abstractllm", version="2.0.0", dependencies=["openai", "anthropic", ...] ) # abstractmemory/setup.py setup( name="abstractmemory", version="1.0.0", dependencies=["abstractllm>=2.0.0"] ) # abstractagent/setup.py setup( name="abstractagent", version="1.0.0", dependencies=[ "abstractllm>=2.0.0", "abstractmemory>=1.0.0" ] ) ``` -------------------------------- ### Configure Local LLM Providers: Ollama and MLX (Python) Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-16-stream-tool-multiturn.txt Provides examples for setting up local LLM providers using Ollama and MLX. Ollama supports various open-source models like qwen3:4b and qwen3-coder:30b, while MLX is optimized for Apple Silicon (M1/M2/M3) and includes models such as mlx-community/GLM-4.5-Air-4bit and Qwen/Qwen3-4B-MLX-4bit. ```python # Ollama for various open-source models llm = create_llm("ollama", model="qwen3:4b") # Good balance llm = create_llm("ollama", model="qwen3-coder:30b") # Excellent for coding # MLX for Apple Silicon (M1/M2/M3) llm = create_llm("mlx", model="mlx-community/GLM-4.5-Air-4bit") llm = create_llm("mlx", model="Qwen/Qwen3-4B-MLX-4bit") ``` -------------------------------- ### CLI Usage Examples for AbstractLLM Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-17-lmstudio-provider.txt Provides standard command-line interface usage patterns for the AbstractLLM tool, including basic prompts and parameter-tuned execution. ```bash # Basic usage without cognitive overhead alma --provider lmstudio --model "qwen/qwen3-next-80b" --prompt "Hello!" # Usage with specific model parameters alma --provider lmstudio --seed 12345 --temperature 0.3 --prompt "Generate text" ``` -------------------------------- ### Python Example Usage of web_search Source: https://github.com/lpalbou/abstractllm/blob/main/docs/misc/web_search_tool_decorator_summary.md These code snippets demonstrate various ways to call the enhanced web_search function with different queries and parameters. They illustrate practical applications such as researching programming best practices, comparing technologies, getting current news, and finding documentation. ```python web_search("python best practices 2025", num_results=5) ``` ```python web_search("semantic search embedding models comparison", num_results=3) ``` ```python web_search("AI developments 2025") ``` ```python web_search("LanceDB vector database tutorial", num_results=4) ``` -------------------------------- ### Python Example: Listing Files with Head Limit Source: https://github.com/lpalbou/abstractllm/blob/main/docs/misc/helpful_hints_enhancement.md Demonstrates how to use the `list_files` function with a `head_limit` to show a subset of files in the current directory. It also shows the expected output hint when more files are available. ```python # Current directory: 52 files # list_files() with head_limit=10 # Would show: "💡 42 more files available. Use list_files('.', '*', head_limit=None) to see all." ``` -------------------------------- ### Simulating Offline Network Conditions (Bash) Source: https://github.com/lpalbou/abstractllm/blob/main/docs/known_bugs/unauthorized-network-access-startup.md These bash commands show how to disable network interfaces to test AbstractLLM's offline functionality. Examples are provided for macOS (`ifconfig`) and Linux (`systemctl`). After disabling the network, the user can test if the application starts correctly using local providers. ```bash # Disconnect from internet or use airplane mode sudo ifconfig en0 down # macOS # OR sudo systemctl stop NetworkManager # Linux # Test startup alma --provider ollama # Should work immediately ``` -------------------------------- ### Python: Initializing and Running an LLM Session Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-16-stream-tool-multiturn.txt This Python snippet shows the initialization and execution of an LLM session using the AbstractLLM library. It includes setting up the session with a specific model and provider, defining initial messages, and then running the session to get a response. This is a foundational example for interacting with the AbstractLLM framework. ```python from abstractllm.session import Session, Message session = Session( model="mistralai/Mistral-7B-Instruct-v0.1", provider_name="ollama", messages=[ Message(role='user', content='list the local files') ] ) session.run() print(session.get_response()) ``` -------------------------------- ### Create Autonomous Assistant with Grounded Memory (Python) Source: https://github.com/lpalbou/abstractllm/blob/main/docs/final-refactoring/task_04_create_agent_package.md This snippet outlines the setup for an autonomous assistant agent that employs grounded memory. Grounded memory is designed to be user-aware, suggesting a more sophisticated approach to context management for complex, long-term interactions. The specific configuration details for grounded memory are implied but not fully detailed in this example. ```python ```python from abstractagent import Agent ``` ``` -------------------------------- ### Installing AbstractLLM Packages (Bash) Source: https://github.com/lpalbou/abstractllm/blob/main/docs/refactoring/revised-improvement-recommendations.md Provides commands for installing the modular AbstractLLM packages individually or as a complete suite. It demonstrates using pip to install abstractllm, abstractmemory, and abstractagent, including an option to install all dependencies with abstractagent[all]. ```bash # New modular packages pip install abstractllm # Core only pip install abstractmemory # Memory system pip install abstractagent # Agent framework # Or get everything pip install abstractagent[all] # Installs all three ``` -------------------------------- ### Initialize and Use LLM Providers Source: https://github.com/lpalbou/abstractllm/blob/main/README.md Demonstrates how to instantiate different LLM providers using the unified create_llm factory method and perform basic text generation. ```python from abstractllm import create_llm # Create an LLM instance llm = create_llm("openai", model="gpt-4o-mini") response = llm.generate("Explain quantum computing briefly.") print(response) # Switch providers seamlessly anthropic_llm = create_llm("anthropic", model="claude-3-5-sonnet-20241022") response = anthropic_llm.generate("Tell me about yourself.") print(response) ``` -------------------------------- ### Add Examples for New Commands Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-16-stream-multiturn-tool.txt This snippet demonstrates the addition of example usage for the '/react-icp' and '/memory-facts' commands in the examples section of `abstractllm/utils/commands.py`. This provides practical guidance for users on how to invoke these commands. ```python 156 "/load my_session.pkl", 157 "/memory 16384", 158 "/temperature 0.3", 159 + "/react-icp 0.5 0.33", 160 + "/memory-facts 10 0.3 1", 161 "/system You are a helpful coding assistant", 162 "/stream on", 163 "/tools read_file", ``` -------------------------------- ### Advanced Agent Integration with AbstractLLM Source: https://github.com/lpalbou/abstractllm/blob/main/README.md Illustrates setting up an agent with memory, tools, and system prompts using `create_session`. This example showcases how to integrate custom tools and enable memory context and reasoning cycles for more complex interactions. ```python from abstractllm.factory import create_session from abstractllm.tools import tool @tool def get_user_data(user_id: str) -> dict: """Fetch user data from your database.""" return {"name": "Alice", "preferences": ["AI", "coding"]} class CustomerServiceAgent: def __init__(self): self.session = create_session( "anthropic", model="claude-3-5-sonnet-20241022", enable_memory=True, # Alpha feature tools=[get_user_data], system_prompt="You are a helpful customer service agent." ) def handle_request(self, user_id: str, message: str) -> str: prompt = f"User {user_id} says: {message}" response = self.session.generate( prompt, use_memory_context=True, # Remember previous interactions (alpha) create_react_cycle=True # Detailed reasoning (alpha) ) return response.content ``` -------------------------------- ### LLM Provider Integration (Python) Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-16-stream-tool-multiturn.txt Demonstrates how to create LLM instances using different providers such as Ollama, MLX for Apple Silicon, and HuggingFace. This allows for flexible model selection based on hardware and availability. ```python # Ollama for various open-source models llm = create_llm("ollama", model="qwen3:4b") # Good balance llm = create_llm("ollama", model="qwen3-coder:30b") # Excellent for coding # MLX for Apple Silicon (M1/M2/M3) llm = create_llm("mlx", model="mlx-community/GLM-4.5-Air-4bit") llm = create_llm("mlx", model="Qwen/Qwen3-4B-MLX-4bit") ``` ```python llm = create_llm("huggingface", model="Qwen/Qwen3-4B") llm = create_llm("huggingface", model="microsoft/Phi-4-mini-instruct") ``` -------------------------------- ### Define Tool System Prompts for LLM Providers Source: https://github.com/lpalbou/abstractllm/blob/main/docs/reports/2025-09-15-tool-architecture-across-providers.md Examples of how to structure system prompts for tool-enabled LLMs. The Ollama example demonstrates a JSON-based tool definition format, while the OpenAI example shows a simplified descriptive approach. ```text ━━━ SYSTEM PROMPT ━━━ You are an intelligent AI assistant with memory and reasoning capabilities. You are a helpful AI assistant with tool access. Available tools: [ { "name": "read_file", "description": "Read the contents of a file with optional line range.", "parameters": { "type": "object", "properties": { "file_path": {"type": "string"}, "should_read_entire_file": {"type": "boolean"} }, "required": ["file_path"] } } ] EXAMPLES: read_file - Read file contents Example 1: <|tool_call|>{"name": "read_file", "arguments": {"file_path": "example.txt"}} ``` ```text ━━━ SYSTEM PROMPT ━━━ You are an intelligent AI assistant with memory and reasoning capabilities. ━━━ AVAILABLE TOOLS ━━━ • read_file: Read the contents of a file with optional line range. ``` -------------------------------- ### AbstractLLM CLI Usage with SOTA Parameters (LM Studio) Source: https://github.com/lpalbou/abstractllm/blob/main/docs/devs/2025-09-17-lmstudio-provider.txt Illustrates how to use the AbstractLLM CLI with LM Studio while specifying advanced parameters for model generation. This includes setting a seed, top-p, and temperature for controlled output. ```bash alma --provider lmstudio --seed 12345 --top-p 0.8 --temperature 0.3 ```