Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ temp_data/
sample_templates/obsidian_conf_test.yaml
sample_templates/test-templates/*
.venv2
.github/prompts

# Distribution / packaging
.Python
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Interaction with the package is supported through the built-in frontend, or by e
* Simple web interfaces.
* Deep linking into document sections - jump to an individual PDF page or a header in a markdown file.
* Ability to save responses to an offline database for future analysis.
* FastAPI based API + MCP server, allo
* FastAPI based API + MCP server, allowing communicating with RAG via any mcp client, including VSCode/Windsurf/Cursor and others.


## Demo
Expand Down
4 changes: 2 additions & 2 deletions sample_templates/obsidian_conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ semantic_search:
multiquery:
enabled: False
conversation_history_settings:
enabled: True
rewrite_query: True
enabled: False
rewrite_query: False
max_history_length: 2


Expand Down
28 changes: 26 additions & 2 deletions src/llmsearch/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
"""FastAPI server for LLMSearch."""

import os

# This is a temporary solution due to incompatimbility of ChromaDB with latest version of Protobuf
os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"

from functools import lru_cache
from typing import Any, List

Expand All @@ -24,7 +28,7 @@


load_dotenv()
langchain.debug = True # Enable debug mode for langchain # type: ignore
langchain.debug = False


# Load the configuration
Expand Down Expand Up @@ -101,7 +105,7 @@ def get_llm_bundle_cached() -> LLMBundle:
description="pyLLMSearch MCP Server",
describe_all_responses=True, # Include all possible response schemas
describe_full_response_schema=True, # Include full JSON schema in descriptions
include_operations=["rag_retrieve_chunks", "rag_generate_answer"],
include_operations=["rag_retrieve_chunks", "rag_generate_answer", "rag_generate_answer_simple"],
)


Expand Down Expand Up @@ -145,6 +149,26 @@ async def llmsearch(
)
return output.model_dump()

@api_app.get("/rag", operation_id="rag_generate_answer_simple")
async def llmsearch_simple(
question: str,
label: str = "",
llm_bundle: LLMBundle = Depends(get_llm_bundle_cached),
) -> str:
"""Retrieves answer to the question from the embedded documents, using semantic search."""
if label and (label not in get_config().embeddings.labels):
raise HTTPException(
status_code=404,
detail=f"Label '{label}' doesn't exist. Use GET /labels to get a list of labels.",
)

output = get_and_parse_response(
query=question,
llm_bundle=llm_bundle,
config=get_config(),
label=label,
)
return output.response

@api_app.get("/semantic/{question}", operation_id="rag_retrieve_chunks")
async def semanticsearch(question: str):
Expand Down
3 changes: 3 additions & 0 deletions src/llmsearch/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import os

# This is a temporary solution due to incompatimbility of ChromaDB with latest version of Protobuf
os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"

import click
import streamlit.web.cli
from loguru import logger
Expand Down
Loading