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:
@@ -10,9 +10,39 @@ from typing import Any
|
|||||||
|
|
||||||
import dotenv
|
import dotenv
|
||||||
from leann.api import LeannBuilder, LeannChat
|
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.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()
|
dotenv.load_dotenv()
|
||||||
|
|
||||||
|
|||||||
@@ -205,26 +205,41 @@ class SlackMCPReader:
|
|||||||
tools = await self.list_available_tools()
|
tools = await self.list_available_tools()
|
||||||
message_tool = None
|
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:
|
for tool in tools:
|
||||||
tool_name = tool.get("name", "").lower()
|
tool_name = tool.get("name", "").lower()
|
||||||
if any(
|
if "conversations_history" in tool_name:
|
||||||
keyword in tool_name
|
|
||||||
for keyword in ["message", "history", "channel", "conversation"]
|
|
||||||
):
|
|
||||||
message_tool = tool
|
message_tool = tool
|
||||||
break
|
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:
|
if not message_tool:
|
||||||
raise RuntimeError("No message fetching tool found in MCP server")
|
raise RuntimeError("No message fetching tool found in MCP server")
|
||||||
|
|
||||||
# Prepare tool call parameters
|
# Prepare tool call parameters
|
||||||
tool_params = {"limit": limit}
|
tool_params = {"limit": limit}
|
||||||
if channel:
|
if channel:
|
||||||
# Try common parameter names for channel specification
|
# For conversations_history, use channel_id parameter
|
||||||
for param_name in ["channel", "channel_id", "channel_name"]:
|
if message_tool["name"] == "conversations_history":
|
||||||
tool_params[param_name] = channel
|
tool_params["channel_id"] = channel
|
||||||
break
|
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 = {
|
fetch_request = {
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 534 KiB |
@@ -121,13 +121,21 @@ python -m apps.slack_rag \
|
|||||||
```
|
```
|
||||||
|
|
||||||
### 4.3 Real RAG Query Example
|
### 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.
|
||||||
|
|
||||||

|
### Screenshots
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 452 KiB |
Reference in New Issue
Block a user