### Example 1: Philosophy Setup (Plato's Symposium) Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-cli/USER_GUIDE.md A practical example demonstrating how to set up the tool for analyzing philosophical texts, specifically Plato's Symposium. It covers starting the TUI, loading configuration and documents, and posing analytical queries. ```bash # 1. Start TUI ./target/release/graphrag-cli # 2. In Command Mode (use Shift+Tab to switch modes) /config docs-example/symposium_config.toml /load docs-example/platos_symposium.txt # 3. Wait for processing (estimated 30-60 seconds) # 4. In Query Mode (use Shift+Tab to return to Query Mode) What does Socrates say about love? Who are the main speakers in the Symposium? Explain the myth of the androgyne ``` -------------------------------- ### Basic GraphRAG 'Hello World' Example Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-core/QUICKSTART.md A minimal Rust program demonstrating GraphRAG's core functionality. It initializes GraphRAG with a short text, asks a question, and prints the answer. Requires the 'graphrag-core' and 'tokio' dependencies. ```rust use graphrag_core::prelude::*; #[tokio::main] async fn main() -> Result<()> { // Create GraphRAG instance with your document let mut graphrag = GraphRAG::quick_start( "Albert Einstein was a theoretical physicist who developed the theory of relativity. \ He was born in Germany in 1879 and later moved to the United States. \ Einstein received the Nobel Prize in Physics in 1921." ).await?; // Ask questions let answer = graphrag.ask("Where was Einstein born?").await?; println!("Answer: {}", answer); Ok(()) } ``` -------------------------------- ### Quick Start: Hybrid Pipeline Configuration Source: https://github.com/automataia/graphrag-rs/blob/main/HOW_IT_WORKS.md Steps to set up and run the Hybrid Pipeline. This involves copying a configuration template, editing file paths, and executing the Rust example. ```bash cp config/templates/hybrid_pipeline.toml my_config.toml # Edit paths in my_config.toml cargo run --example your_example -- my_config.toml ``` -------------------------------- ### Complete GraphRAG-py Example with File Loading and Interactive Q&A Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag_py/QUICK_START.md A comprehensive example demonstrating a full GraphRAG-py application. It initializes GraphRAG, loads documents from text files in a './documents' directory, builds the knowledge graph, and then enters an interactive loop for users to ask questions and receive answers. ```python import asyncio from pathlib import Path from graphrag_py import PyGraphRAG async def knowledge_base(): # Initialize rag = PyGraphRAG.default_local() # Load documents print("Loading documents...") docs_dir = Path("./documents") for file in docs_dir.glob("*.txt"): print(f" - {file.name}") with open(file) as f: await rag.add_document_from_text(f.read()) # Build graph print("Building knowledge graph...") await rag.build_graph() print(f"✓ Ready! {rag}") # Interactive Q&A while True: question = input("\nAsk a question (or 'quit'): ") if question.lower() in ['quit', 'exit', 'q']: break answer = await rag.ask(question) print(f"\nAnswer: {answer}") if __name__ == "__main__": asyncio.run(knowledge_base()) ``` -------------------------------- ### Setup Ollama Server and Pull Model Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-wasm/README.md Provides bash commands to install Ollama, pull a specific language model (e.g., llama3.1:8b), and start the Ollama server with Cross-Origin Resource Sharing (CORS) enabled for browser access. This setup is necessary when using the Ollama HTTP backend. ```bash # Install Ollama curl -fsSL https://ollama.com/install.sh | sh # Pull a model ollama pull llama3.1:8b # Start server with CORS enabled OLLAMA_ORIGINS="http://localhost:8080" ollama serve ``` -------------------------------- ### Quick Start: Semantic Pipeline Configuration Source: https://github.com/automataia/graphrag-rs/blob/main/HOW_IT_WORKS.md Steps to set up and run the Semantic Pipeline. This involves copying a configuration template, editing file paths, and executing the Rust example. It requires an LLM. ```bash cp config/templates/semantic_pipeline.toml my_config.toml # Edit paths in my_config.toml cargo run --example your_example -- my_config.toml ``` -------------------------------- ### GraphRAG CLI Quick Start Example Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-cli/README.md A comprehensive example demonstrating how to set up a TOML configuration file, load and process a document, and then interact with the graphrag-cli either through its TUI or direct command-line queries. ```bash # 1. Create a config file (or use an example from config/templates/) cat > my_config.toml << EOF [general] output_dir = "./output" log_level = "info" [pipeline] workflows = ["extract_text", "extract_entities", "build_graph"] [pipeline.text_extraction] chunk_size = 500 chunk_overlap = 100 [ollama] enabled = true host = "http://localhost" port = 11434 chat_model = "llama3.1:8b" embedding_model = "nomic-embed-text" EOF # 2. Load and process your document (NOTE: Real LLM processing takes time!) # Small docs (5-10 pages): 5-15 minutes # Medium docs (50-100 pages): 30-60 minutes # Large docs (500-1000 pages): 2-4 hours ./target/release/graphrag_cli load your_document.txt --config my_config.toml # 3. Start the interactive TUI to query ./target/release/graphrag_cli --config my_config.toml tui # Or query directly from command line ./target/release/graphrag_cli --config my_config.toml query "What are the main themes?" ``` -------------------------------- ### Install Prerequisites for GraphRAG-py Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag_py/QUICK_START.md Installs necessary prerequisites for GraphRAG-py: Rust for building the project and Ollama for running language models. It also pulls the required 'llama3' and 'nomic-embed-text' models from Ollama. ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh curl -fsSL https://ollama.ai/install.sh | sh ollama pull llama3 ollama pull nomic-embed-text ``` -------------------------------- ### Basic Usage Example Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag_py/COMPLETION_REPORT.md A simple Python script demonstrating the fundamental usage of the GraphRAG bindings. This example serves as a quick start guide for new users to integrate GraphRAG into their projects. ```python # examples/basic_usage.py from graphrag.index.loading import load_documents from graphrag.index.graph.build import build_graph_from_documents from graphrag.index.graph.query import query_graph def main(): # Load documents from a directory documents = load_documents("./data") # Build the knowledge graph graph = build_graph_from_documents(documents) # Query the graph response = query_graph(graph, "What is the main topic?") print(response) if __name__ == "__main__": main() ``` -------------------------------- ### Setup GraphRAG CLI Wizard (Bash) Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-core/README.md Shows how to initiate the GraphRAG CLI setup wizard for interactive configuration. It includes examples for using templates and specifying custom output paths. ```bash graphrag-cli setup # With template: graphrag-cli setup --template legal # Custom output: graphrag-cli setup --output ./my-config.toml ``` -------------------------------- ### Complete GraphRAG Example with TypedBuilder Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-core/QUICKSTART.md A comprehensive Rust example integrating multiple GraphRAG features. It uses TypedBuilder for configuration, adds a document from text, builds the knowledge graph, and performs a query, displaying the formatted results. ```rust use graphrag_core::prelude::*; #[tokio::main] async fn main() -> Result<()> { // 1. Create and configure let mut graphrag = TypedBuilder::new() .with_output_dir("./knowledge-base") .with_ollama() .with_chunk_size(500) .with_top_k(10) .build_and_init()?; // 2. Add documents graphrag.add_document_from_text( "GraphRAG is a powerful knowledge graph system that combines \ graph-based retrieval with RAG (Retrieval-Augmented Generation). \ It was developed to improve question answering over documents." )?; // 3. Build knowledge graph graphrag.build_graph().await?; // 4. Query let explained = graphrag.ask_explained("What is GraphRAG?").await?; // 5. Display results println!("{}", explained.format_display()); Ok(()) } ``` -------------------------------- ### Example: Create and Use a Workspace Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-cli/USER_GUIDE.md A step-by-step example demonstrating the creation of a workspace, obtaining its ID, and then launching the TUI (Text-based User Interface) associated with that workspace. It also shows how to load configuration and documents within the TUI. ```bash # 1. Create workspace ./target/release/graphrag-cli workspace create philosophy_research # Output will show the created workspace name and ID # Example Output: # ✅ Workspace created successfully! # Name: philosophy_research # ID: a1b2c3d4-e5f6-7890-abcd-ef1234567890 # # Use it with: graphrag-cli tui --workspace a1b2c3d4-e5f6-7890-abcd-ef1234567890 # 2. Start TUI with the workspace (replace with the actual ID) ./target/release/graphrag-cli --workspace a1b2c3d4-e5f6-7890-abcd-ef1234567890 # 3. Inside the TUI, load configuration and documents (in Command Mode) /config docs-example/symposium_config.toml /load docs-example/platos_symposium.txt ``` -------------------------------- ### GraphRAG First Project Setup (Bash) Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-cli/USER_GUIDE.md A step-by-step guide using bash commands to set up your first GraphRAG project. This includes creating a project directory, generating a basic configuration file, and preparing the documents directory. ```bash # 1. Create project directory mkdir -p ~/graphrag-projects/philosophy cd ~/graphrag-projects/philosophy # 2. Create configuration file cat > config.toml << 'EOF' [llm] provider = "ollama" model = "qwen3:8b" temperature = 0.7 [embeddings] provider = "ollama" model = "nomic-embed-text" [text.chunking] method = "semantic" max_tokens = 500 [entity.extraction] use_gleaning = true max_iterations = 2 EOF # 3. Prepare documents mkdir documents # Copy your documents to ./documents/ ``` -------------------------------- ### Install Rust and WASM Target Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-wasm/QUICK_START.md Installs Rust, adds the WebAssembly target for compilation, and installs the Trunk build tool. These are essential prerequisites for building and running the GraphRAG WASM application. ```bash # Install Rust (if not already installed) curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # Add WebAssembly target rustup target add wasm32-unknown-unknown # Install Trunk (WASM build tool) cargo install trunk ``` -------------------------------- ### Start GraphRAG WASM Development Server Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-wasm/QUICK_START.md Navigates to the application directory and starts the development server using Trunk. This command enables hot reloading for a seamless development experience, making the application accessible at http://localhost:8080. ```bash # Navigate to the graphrag-wasm directory cd /home/dio/graphrag-rs/graphrag-wasm # Start the development server (with hot reload) trunk serve # The app will be available at http://localhost:8080 ``` -------------------------------- ### Configure GraphRAG with a TOML File Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-core/QUICKSTART.md This example shows how to configure GraphRAG using an external 'graphrag.toml' file. It covers settings like output directory, chunk size, and Ollama integration. The configuration is then loaded into the GraphRAG instance. ```toml output_dir = "./output" chunk_size = 1000 [ollama] enabled = true host = "localhost" port = 11434 chat_model = "llama3.2:3b" ``` ```rust use graphrag_core::prelude::*; let config = Config::from_toml_file("graphrag.toml")?; let mut graphrag = GraphRAG::new(config)?; graphrag.initialize()?; ``` -------------------------------- ### GraphRAG-cli Setup Wizard Command Source: https://github.com/automataia/graphrag-rs/blob/main/README.md Bash command to launch the interactive setup wizard for the GraphRAG-cli tool. This wizard guides users through the configuration process for setting up GraphRAG. ```bash # Interactive configuration wizard graphrag-cli setup ``` -------------------------------- ### Full GraphRAG Usage Example (Rust) Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-core/README.md A comprehensive example demonstrating the initialization and usage of GraphRAG in Rust. It covers quick start and typed builder initialization, adding documents, building the knowledge graph, and querying with and without explanations. ```rust use graphrag_core::prelude::*; #[tokio::main] async fn main() -> Result<()> { // Option 1: Quick start (simplest) let mut graphrag = GraphRAG::quick_start("Your document text").await?; // Option 2: TypedBuilder (compile-time safe) let mut graphrag = TypedBuilder::new() .with_output_dir("./output") .with_ollama() .with_chunk_size(512) .build_and_init()?; // Add documents graphrag.add_document_from_text("Document content here")?; graphrag.add_document_from_file("path/to/document.txt")?; // Build knowledge graph graphrag.build_graph().await?; // Query let answer = graphrag.ask("What are the main topics?").await?; println!("{}", answer); // Or with explanations let explained = graphrag.ask_explained("What are the main topics?").await?; println!("{}", explained.format_display()); Ok(()) } ``` -------------------------------- ### Start Qdrant with Docker Compose Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-server/README.md This command starts the Qdrant vector database using Docker Compose. Ensure you have Docker and Docker Compose installed. This is a prerequisite for using Qdrant as a storage backend. ```bash cd graphrag-server docker-compose up -d ``` -------------------------------- ### Troubleshooting Ollama Not Running Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-core/QUICKSTART.md This bash snippet provides commands to start the Ollama service and pull necessary language models. These steps are crucial for enabling GraphRAG's semantic and hybrid approaches that rely on local LLM execution. ```bash # Start Ollama ollama serve # Pull required models ollama pull llama3.2:3b ollama pull nomic-embed-text ``` -------------------------------- ### GraphRAG-CLI Querying Examples Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-cli/USER_GUIDE.md Demonstrates how to execute various analytical queries in GraphRAG-CLI's query mode, including thematic, specific entity, and comparative queries. ```bash # Execute analytical queries What are the main philosophical concepts discussed? # Queries about specific entities Tell me about Socrates and his ideas # Comparative queries Compare Plato's and Aristotle's views on reality # Thematic queries What are the main themes in these documents? ``` -------------------------------- ### Setup Ollama for Local Embeddings (Bash) Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-core/EMBEDDINGS_CONFIG.md These commands install and start the Ollama service, then pull a specific embedding model. This is a prerequisite for using Ollama as an embedding provider in GraphRAG. ```bash # Install and start Ollama ollama serve & ollama pull nomic-embed-text ``` -------------------------------- ### Quick Start GraphRAG Initialization and Query Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-core/README.md Demonstrates the quickest way to initialize GraphRAG with document text and ask a question. It leverages the `quick_start` function for simplified setup and then uses the `ask` method for retrieval. ```rust use graphrag_core::prelude::*; #[tokio::main] async fn main() -> Result<()> { let mut graphrag = GraphRAG::quick_start("Your document text here").await?; let answer = graphrag.ask("What is the main topic?").await?; println!("{}", answer); Ok(()) } ``` -------------------------------- ### Verify GraphRAG-py Installation Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag_py/QUICK_START.md Runs a verification script to check if the GraphRAG-py installation was successful. It executes 'verify_installation.py' using 'uv run' and expects a success message. ```bash uv run python verify_installation.py ``` -------------------------------- ### Prerequisites: Install Ollama Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag_py/README.md Installs Ollama, a tool for running large language models locally. This is recommended for getting started with GraphRAG-py, especially for local LLM support. ```bash # macOS/Linux curl -fsSL https://ollama.ai/install.sh | sh # Then pull a model ollama pull llama3 ``` -------------------------------- ### Add GraphRAG Dependency to Cargo.toml Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-core/QUICKSTART.md This snippet shows how to add the graphrag-core dependency with the 'starter' feature and the tokio runtime to your project's Cargo.toml file. Ensure you have Rust 1.70+ installed. ```toml [dependencies] graphrag-core = { version = "0.1", features = ["starter"] } tokio = { version = "1", features = ["full"] } ``` -------------------------------- ### CLI Setup Wizard for GraphRAG Configuration Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-core/templates/README.md Demonstrates how to use the GraphRAG CLI to set up a configuration file interactively, selecting a specific template for a given use case. This is the recommended method for quick setup. ```bash # Interactive setup with template selection graphrag-cli setup --template legal --output ./graphrag.toml ``` -------------------------------- ### Quick Start GraphRAG-rs Initialization and Query in Rust Source: https://github.com/automataia/graphrag-rs/blob/main/README.md A concise Rust example demonstrating how to quickly initialize GraphRAG-rs with document text and perform an asynchronous query. It utilizes the `graphrag_core::prelude::*` for essential components and `tokio` for async execution. ```rust use graphrag_core::prelude::*; #[tokio::main] async fn main() -> Result<()> { let mut graphrag = GraphRAG::quick_start("Your document text").await?; let answer = graphrag.ask("What is this about?").await?; println!("{}", answer); Ok(()) } ``` -------------------------------- ### Example 2: Multi-Document Analysis Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-cli/USER_GUIDE.md Demonstrates how to perform analysis across multiple documents. This involves starting the CLI with a specific configuration, loading several text files sequentially, checking statistics, and then asking comparative or thematic queries. ```bash # 1. Start with a specific configuration file ./target/release/graphrag-cli --config config/templates/academic_research.toml # 2. Load multiple documents (in Command Mode) /load papers/paper1.txt /load papers/paper2.txt /load papers/paper3.txt # 3. Check statistics about the loaded data /stats # 4. Perform analytical queries (in Query Mode) Compare the methodologies used in the three papers What are the common themes across all documents? List all authors mentioned ``` -------------------------------- ### Trunk Build Commands (Bash) Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-wasm/UI_UX_DESIGN.md Provides essential commands for building the project using Trunk, a command-line tool for Rust-based web applications. It covers development server startup, release builds for production, and release builds with specific features enabled for optimization. ```bash # Development trunk serve # Production trunk build --release # With optimizations trunk build --release --features hydrate ``` -------------------------------- ### Setting Up Sectoral Templates via CLI Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-core/QUICKSTART.md This snippet demonstrates how to set up a specific sectoral template using the GraphRAG command-line interface. It's a straightforward way to initialize GraphRAG with pre-configured settings for domains like legal. ```bash graphrag-cli setup --template legal ``` -------------------------------- ### Configure GraphRAG using Environment Variables Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-core/QUICKSTART.md This example demonstrates how to override GraphRAG configuration settings using environment variables. After setting the variables, loading the configuration in code will automatically pick them up. This is useful for dynamic deployment scenarios. ```bash export GRAPHRAG_OLLAMA_HOST=my-server export GRAPHRAG_OLLAMA_PORT=8080 export GRAPHRAG_CHUNK_SIZE=1000 ``` ```rust use graphrag_core::prelude::*; // Automatically uses env vars let config = Config::load()?; // Then use config to initialize GraphRAG ``` -------------------------------- ### Production Setup: Qdrant, Ollama, and GraphRAG Server Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-server/README.md This sequence of commands outlines a production setup for GraphRAG. It involves starting Qdrant via Docker Compose, running Ollama locally to serve embeddings, and then launching the GraphRAG server with specific environment variables and features enabled. Finally, it shows how to add documents and query the system using cURL. ```bash # 1. Start Qdrant docker-compose up -d # 2. Start Ollama ollama serve & ollama pull nomic-embed-text # 3. Start GraphRAG server export EMBEDDING_BACKEND=ollama export QDRANT_URL=http://localhost:6334 cargo run --release --bin graphrag-server --features "qdrant,ollama" # 4. Add documents with real embeddings curl -X POST http://localhost:8080/api/documents \ -H "Content-Type: application/json" \ -d '{"title":"AI Safety","content":"AI safety research focuses on..."}' # 5. Query with semantic search curl -X POST http://localhost:8080/api/query \ -H "Content-Type: application/json" \ -d '{"query":"Tell me about AI safety","top_k":5}' ``` -------------------------------- ### Run GraphRAG Examples (Bash) Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag_py/README.md Instructions for running the provided examples, such as `basic_usage.py` and `document_qa.py`. It requires the Ollama service to be running beforehand. ```bash # Make sure Ollama is running first ollama serve # Run basic example uv run python examples/basic_usage.py # Run document Q&A example uv run python examples/document_qa.py ``` -------------------------------- ### GraphRAG Error Handling with Suggestions Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-core/QUICKSTART.md This Rust code snippet illustrates how to handle errors returned by GraphRAG operations. It shows how to access the error message, retrieve actionable suggestions, and potentially display code examples provided with the suggestion. ```rust use graphrag_core::prelude::*; // Assuming 'graphrag' is an initialized GraphRAG instance match graphrag.ask("question").await { Ok(answer) => println!("{}", answer), Err(e) => { // Get actionable suggestion let suggestion = e.suggestion(); println!("Error: {}", e); println!("Suggestion: {}", suggestion.action); // Code example (if available) if let Some(code) = suggestion.code_example { println!("Try:\n{}", code); } } } ``` -------------------------------- ### Start Qdrant and GraphRAG Server (Rust) Source: https://context7.com/automataia/graphrag-rs/llms.txt Instructions for starting the Qdrant database using Docker and launching the GraphRAG server with or without Qdrant support. This involves using Docker commands and Cargo commands. ```bash docker run -p 6333:6333 -p 6334:6334 qdrant/qdrant cargo run --bin graphrag-server --features qdrant cargo run --bin graphrag-server --no-default-features ``` -------------------------------- ### Configure GraphRAG-py with a TOML File Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag_py/QUICK_START.md Explains how to customize GraphRAG-py's behavior using a TOML configuration file. It shows an example `config.toml` specifying LLM provider, model, temperature, and retrieval strategy, and how to load this configuration when creating the `PyGraphRAG` instance. ```toml [llm] provider = "ollama" model = "llama3" temperature = 0.7 [retrieval] strategy = "adaptive" top_k = 5 ``` ```python rag = PyGraphRAG.from_config("config.toml") ``` -------------------------------- ### Build GraphRAG-py using uv or pip Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag_py/QUICK_START.md Builds the GraphRAG-py package. It offers two options: using 'uv' for faster dependency management and building, or using 'pip' with 'maturin'. The 'maturin develop' command compiles the Rust backend and installs the Python package in editable mode. ```bash cd graphrag_py # Option A: Using uv (faster) uv sync uv run maturin develop # Option B: Using pip pip install maturin maturin develop ``` -------------------------------- ### Start Local Server (Python, Node.js, Rust) Source: https://github.com/automataia/graphrag-rs/blob/main/examples/wasm-multi-doc-demo/README.md Instructions for starting a local HTTP server to serve the demo application. This is necessary to handle CORS requests and access local files. ```bash # Option 1: Python python3 -m http.server 8080 # Option 2: Node.js http-server npx http-server -p 8080 # Option 3: Rust simple-http-server # cargo install simple-http-server # simple-http-server -p 8080 ``` -------------------------------- ### GraphRAG-RS Example Search in Rust Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-cli/USER_GUIDE.md A Rust code snippet demonstrating a real search example, possibly related to the Symposium, within the GraphRAG-RS project. ```rust examples/symposium_real_search.rs ``` -------------------------------- ### GraphRAG-RS Example Pipeline in Rust Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-cli/USER_GUIDE.md A Rust code snippet representing an example of a multi-document pipeline, likely used within the GraphRAG-RS project for processing documents. ```rust examples/multi_document_pipeline.rs ``` -------------------------------- ### Create and Run a Basic GraphRAG-py Program Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag_py/QUICK_START.md Demonstrates the creation and execution of a simple GraphRAG-py program. It initializes a local GraphRAG instance, adds a document about Rust, builds the knowledge graph, and then asks a question about the creator of Rust. The program uses asyncio for asynchronous operations. ```python import asyncio from graphrag_py import PyGraphRAG async def main(): # 1. Create GraphRAG instance rag = PyGraphRAG.default_local() # 2. Add a document await rag.add_document_from_text(""" Rust is a systems programming language that runs blazingly fast, prevents segfaults, and guarantees thread safety. It was created by Graydon Hoare and first released in 2010. """) # 3. Build the knowledge graph print("Building graph...") await rag.build_graph() # 4. Ask questions answer = await rag.ask("Who created Rust?") print(f"Answer: {answer}") if __name__ == "__main__": asyncio.run(main()) ``` -------------------------------- ### Development Setup Commands in Bash Source: https://github.com/automataia/graphrag-rs/blob/main/README.md Outlines essential bash commands for setting up and developing the GraphRAG-RS project. This includes cloning the repository, running tests, enabling debug logging, and checking code quality with `clippy` and `fmt`. ```bash # Clone repository git clone https://github.com/your-username/graphrag-rs.git cd graphrag-rs # Run tests cargo test # Run with debug info RUST_LOG=debug cargo run # Check code quality cargo clippy cargo fmt --check ``` -------------------------------- ### Entity Extraction Configuration (TOML) Source: https://github.com/automataia/graphrag-rs/blob/main/HOW_IT_WORKS.md Demonstrates two TOML configuration examples for entity extraction. Example 1 uses fast pattern-based extraction with no LLM, while Example 2 uses high-quality LLM-based extraction with Ollama. ```toml [entity_extraction] enabled = true min_confidence = 0.7 use_gleaning = false # ← Pattern-based extraction [ollama] enabled = false # ← No LLM needed ``` ```toml [entity_extraction] enabled = true min_confidence = 0.6 # ← Lower for philosophical nuance use_gleaning = true # ← LLM-based extraction max_gleaning_rounds = 4 # ← 4 refinement passes [ollama] enabled = true chat_model = "llama3.1:8b" # ← LLM for extraction ``` -------------------------------- ### Install Development Tools (Bash) Source: https://github.com/automataia/graphrag-rs/blob/main/examples/web-app/README.md Installs Trunk, a WASM bundler, and wasm-bindgen-cli for WebAssembly development. It also adds the wasm32-unknown-unknown target for Rust. ```bash cargo install trunk wasm-bindgen-cli rustup target add wasm32-unknown-unknown ``` -------------------------------- ### Production Build and Optimization Commands (Bash) Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-wasm/QUICK_START.md This snippet outlines bash commands for building and optimizing the project for production. It covers full release builds, additional WASM optimization using `wasm-opt`, and compression using `brotli`. It also includes notes on serving with compression and setting the correct MIME type. ```bash # Full optimization trunk build --release # Additional WASM optimization wasm-opt dist/*.wasm -O3 -o dist/optimized.wasm # Compress with Brotli brotli dist/*.wasm # Serve with compression # Ensure your server sends proper WASM MIME type: # Content-Type: application/wasm # Content-Encoding: br ``` -------------------------------- ### Development Server Commands (Bash) Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-wasm/QUICK_START.md This snippet provides bash commands for running the development server using `trunk`. It includes options for fast rebuilds, specifying a port, and enabling release optimizations for faster runtime performance during development. ```bash # Fast rebuilds with trunk serve trunk serve # With specific port trunk serve --port 3000 # With release optimizations (slower build, faster runtime) trunk serve --release ``` -------------------------------- ### Install Windows Build Tools for GraphRAG-rs Source: https://github.com/automataia/graphrag-rs/blob/main/README.md Guides users to install Visual Studio Build Tools with C++ support and the `wasm32-unknown-unknown` Rust target for Windows. ```bash # Install Visual Studio Build Tools with C++ support # Or use Visual Studio Community with C++ development tools # Install Rust with Windows target support rustup target add wasm32-unknown-unknown ``` -------------------------------- ### Get Default Configuration (GET /api/config/default) Source: https://github.com/automataia/graphrag-rs/blob/main/graphrag-server/README.md Fetches the system's default configuration settings. This endpoint is useful for understanding the baseline parameters or for starting a new configuration. ```bash curl http://localhost:8080/api/config/default ```