Skip to content

Commit f0def2c

Browse files
authored
Merge pull request #133 from snexus/feature/mcp
Add a quickfix for protobuf incompatibility with chroma. Add 'simple_answer' mcp endpoin
2 parents a954400 + 1b35280 commit f0def2c

File tree

5 files changed

+33
-5
lines changed

5 files changed

+33
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ temp_data/
1717
sample_templates/obsidian_conf_test.yaml
1818
sample_templates/test-templates/*
1919
.venv2
20+
.github/prompts
2021

2122
# Distribution / packaging
2223
.Python

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Interaction with the package is supported through the built-in frontend, or by e
5858
* Simple web interfaces.
5959
* Deep linking into document sections - jump to an individual PDF page or a header in a markdown file.
6060
* Ability to save responses to an offline database for future analysis.
61-
* FastAPI based API + MCP server, allo
61+
* FastAPI based API + MCP server, allowing communicating with RAG via any mcp client, including VSCode/Windsurf/Cursor and others.
6262

6363

6464
## Demo

sample_templates/obsidian_conf.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ semantic_search:
6060
multiquery:
6161
enabled: False
6262
conversation_history_settings:
63-
enabled: True
64-
rewrite_query: True
63+
enabled: False
64+
rewrite_query: False
6565
max_history_length: 2
6666

6767

src/llmsearch/api.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
"""FastAPI server for LLMSearch."""
22

33
import os
4+
5+
# This is a temporary solution due to incompatimbility of ChromaDB with latest version of Protobuf
6+
os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"
7+
48
from functools import lru_cache
59
from typing import Any, List
610

@@ -24,7 +28,7 @@
2428

2529

2630
load_dotenv()
27-
langchain.debug = True # Enable debug mode for langchain # type: ignore
31+
langchain.debug = False
2832

2933

3034
# Load the configuration
@@ -101,7 +105,7 @@ def get_llm_bundle_cached() -> LLMBundle:
101105
description="pyLLMSearch MCP Server",
102106
describe_all_responses=True, # Include all possible response schemas
103107
describe_full_response_schema=True, # Include full JSON schema in descriptions
104-
include_operations=["rag_retrieve_chunks", "rag_generate_answer"],
108+
include_operations=["rag_retrieve_chunks", "rag_generate_answer", "rag_generate_answer_simple"],
105109
)
106110

107111

@@ -145,6 +149,26 @@ async def llmsearch(
145149
)
146150
return output.model_dump()
147151

152+
@api_app.get("/rag", operation_id="rag_generate_answer_simple")
153+
async def llmsearch_simple(
154+
question: str,
155+
label: str = "",
156+
llm_bundle: LLMBundle = Depends(get_llm_bundle_cached),
157+
) -> str:
158+
"""Retrieves answer to the question from the embedded documents, using semantic search."""
159+
if label and (label not in get_config().embeddings.labels):
160+
raise HTTPException(
161+
status_code=404,
162+
detail=f"Label '{label}' doesn't exist. Use GET /labels to get a list of labels.",
163+
)
164+
165+
output = get_and_parse_response(
166+
query=question,
167+
llm_bundle=llm_bundle,
168+
config=get_config(),
169+
label=label,
170+
)
171+
return output.response
148172

149173
@api_app.get("/semantic/{question}", operation_id="rag_retrieve_chunks")
150174
async def semanticsearch(question: str):

src/llmsearch/cli.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import os
22

3+
# This is a temporary solution due to incompatimbility of ChromaDB with latest version of Protobuf
4+
os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"
5+
36
import click
47
import streamlit.web.cli
58
from loguru import logger

0 commit comments

Comments
 (0)