diff --git a/apps/base_rag_example.py b/apps/base_rag_example.py index 136b734..d797865 100644 --- a/apps/base_rag_example.py +++ b/apps/base_rag_example.py @@ -10,9 +10,39 @@ from typing import Any import dotenv from leann.api import LeannBuilder, LeannChat -from leann.interactive_utils import create_rag_session + +# Optional import: older PyPI builds may not include interactive_utils +try: + from leann.interactive_utils import create_rag_session +except ImportError: + + def create_rag_session(app_name: str, data_description: str): + class _SimpleSession: + def run_interactive_loop(self, handler): + print(f"Interactive session for {app_name}: {data_description}") + print("Interactive mode not available in this build") + + return _SimpleSession() + + from leann.registry import register_project_directory -from leann.settings import resolve_ollama_host, resolve_openai_api_key, resolve_openai_base_url + +# Optional import: older PyPI builds may not include settings +try: + from leann.settings import resolve_ollama_host, resolve_openai_api_key, resolve_openai_base_url +except ImportError: + # Minimal fallbacks if settings helpers are unavailable + import os + + def resolve_ollama_host(value: str | None) -> str | None: + return value or os.getenv("LEANN_OLLAMA_HOST") or os.getenv("OLLAMA_HOST") + + def resolve_openai_api_key(value: str | None) -> str | None: + return value or os.getenv("OPENAI_API_KEY") + + def resolve_openai_base_url(value: str | None) -> str | None: + return value or os.getenv("OPENAI_BASE_URL") + dotenv.load_dotenv() diff --git a/apps/slack_data/slack_mcp_reader.py b/apps/slack_data/slack_mcp_reader.py index 7580951..e589d04 100644 --- a/apps/slack_data/slack_mcp_reader.py +++ b/apps/slack_data/slack_mcp_reader.py @@ -205,26 +205,41 @@ class SlackMCPReader: tools = await self.list_available_tools() message_tool = None - # Look for a tool that can fetch messages + # Look for a tool that can fetch messages - prioritize conversations_history + message_tool = None + + # First, try to find conversations_history specifically for tool in tools: tool_name = tool.get("name", "").lower() - if any( - keyword in tool_name - for keyword in ["message", "history", "channel", "conversation"] - ): + if "conversations_history" in tool_name: message_tool = tool break + # If not found, look for other message-fetching tools + if not message_tool: + for tool in tools: + tool_name = tool.get("name", "").lower() + if any( + keyword in tool_name + for keyword in ["conversations_search", "message", "history"] + ): + message_tool = tool + break + if not message_tool: raise RuntimeError("No message fetching tool found in MCP server") # Prepare tool call parameters tool_params = {"limit": limit} if channel: - # Try common parameter names for channel specification - for param_name in ["channel", "channel_id", "channel_name"]: - tool_params[param_name] = channel - break + # For conversations_history, use channel_id parameter + if message_tool["name"] == "conversations_history": + tool_params["channel_id"] = channel + else: + # Try common parameter names for channel specification + for param_name in ["channel", "channel_id", "channel_name"]: + tool_params[param_name] = channel + break fetch_request = { "jsonrpc": "2.0", diff --git a/docs/slack-integration-success.png b/docs/slack-integration-success.png deleted file mode 100644 index 179cd05..0000000 Binary files a/docs/slack-integration-success.png and /dev/null differ diff --git a/docs/slack-setup-guide.md b/docs/slack-setup-guide.md index 026267a..96bfbc2 100644 --- a/docs/slack-setup-guide.md +++ b/docs/slack-setup-guide.md @@ -121,13 +121,21 @@ python -m apps.slack_rag \ ``` ### 4.3 Real RAG Query Example -## Real RAG Query Example (Sky Lab Computing “random”) -This example shows a real query against the Sky Lab Computing workspace’s “random” channel using the Slack MCP server, with an embedded screenshot of the terminal output. +This example demonstrates a successful Slack RAG integration query against the Sky Lab Computing workspace's "random" channel. The system successfully retrieves actual conversation messages and performs semantic search with high relevance scores. -### Screenshot +**Key Features Demonstrated:** +- ✅ **Real Slack Integration**: Successfully connects to Slack via MCP server +- ✅ **Actual Message Retrieval**: Fetches real conversation history, not just metadata +- ✅ **Working RAG Pipeline**: Complete index building, search, and response generation +- ✅ **High Relevance Search**: Score of 0.5673 for research papers query +- ✅ **Rich Content**: Real research discussions about AI papers, lab updates, etc. -![Sky Random RAG](videos/rag-sky-random.png) +### Screenshots + +![Sky Random RAG - Real Slack Integration](videos/slack_integration.png) + +![Sky Random RAG - Additional Demo](videos/slack_integration_2.png) ### Prerequisites diff --git a/docs/videos/rag-sky-random.png b/docs/videos/rag-sky-random.png deleted file mode 100644 index fdc011f..0000000 Binary files a/docs/videos/rag-sky-random.png and /dev/null differ