Fix Slack MCP integration and update documentation

- Fix SlackMCPReader to use conversations_history instead of channels_list
- Add fallback imports for leann.interactive_utils and leann.settings
- Update slack-setup-guide.md with real screenshots and improved text
- Remove old screenshot files
This commit is contained in:
aakash
2025-10-18 01:08:34 -07:00
parent 8bdd5a17ba
commit c05650103b
5 changed files with 68 additions and 15 deletions

View File

@@ -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()

View File

@@ -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",

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 534 KiB

View File

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

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 452 KiB