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
16 changes: 12 additions & 4 deletions backend/chatbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ def parse_output(output: list) -> tuple[str, list[str], list[str]]:
logging.error(f"Output is not a list: {type(output)}")
return fail_msg, [], []
if len(output) < MIN_OUTPUT_LENGTH:
logging.error(f"Output too short: {len(output)} elements (expected >= {MIN_OUTPUT_LENGTH})")
logging.error(
f"Output too short: {len(output)} elements (expected >= {MIN_OUTPUT_LENGTH})"
)
return fail_msg, [], []

# Validate last element contains generation
Expand All @@ -106,7 +108,9 @@ def parse_output(output: list) -> tuple[str, list[str], list[str]]:
key = "rag_generate" if is_rag else "generate"

if key not in last:
logging.error(f"Missing '{key}' key in final output. Available keys: {list(last.keys())}")
logging.error(
f"Missing '{key}' key in final output. Available keys: {list(last.keys())}"
)
return fail_msg, [], []

if "messages" not in last[key]:
Expand Down Expand Up @@ -261,12 +265,16 @@ def main() -> None:
console.print("\n[yellow]Interrupted. Goodbye![/yellow]")
except ValueError as e:
console.print(f"[bold red]Configuration Error:[/bold red] {str(e)}")
console.print("[yellow]Check your environment variables and try again.[/yellow]")
console.print(
"[yellow]Check your environment variables and try again.[/yellow]"
)
if debug:
logging.exception("Configuration error")
except ConnectionError as e:
console.print(f"[bold red]Connection Error:[/bold red] {str(e)}")
console.print("[yellow]Check your network connection and database availability.[/yellow]")
console.print(
"[yellow]Check your network connection and database availability.[/yellow]"
)
if debug:
logging.exception("Connection error")
except Exception as e:
Expand Down
16 changes: 8 additions & 8 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ dependencies = [
"google-cloud-storage>=2.19.0",
"httpx>=0.28.1",
"huggingface-hub[cli]==0.34.4",
"langchain==0.3.27",
"langchain-community==0.3.27",
"langchain-google-genai==2.1.9",
"langchain-google-vertexai==2.0.28",
"langchain-huggingface==0.3.1",
"langchain>=1.2.12",
"langchain-community>=0.4.1",
"langchain-google-genai>=4.2.1",
"langchain-google-vertexai>=3.2.2",
"langchain-huggingface>=1.2.1",
"langchain-mcp-adapters>=0.1.9",
"langchain-ollama==0.3.6",
"langgraph>=0.7.0",
"langgraph-checkpoint>=3.0.0",
"langchain-ollama>=1.0.1",
"langgraph>=1.1.0",
"langgraph-checkpoint>=4.0.0",
"markdown==3.8.2",
"myst-parser==4.0.1",
"nest-asyncio>=1.6.0",
Expand Down
2 changes: 1 addition & 1 deletion backend/src/agents/retriever_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from langgraph.graph import START, StateGraph
from langgraph.graph.state import CompiledStateGraph
from langchain.prompts import ChatPromptTemplate
from langchain_core.prompts import ChatPromptTemplate
from langchain_google_vertexai import ChatVertexAI
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain_ollama import ChatOllama
Expand Down
2 changes: 1 addition & 1 deletion backend/src/agents/retriever_mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from ..openroad_mcp.client.client import get_tools
from langgraph.graph import END
from .retriever_typing import AgentState
from langchain.prompts import ChatPromptTemplate
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.tools.base import ToolException
from langchain_google_vertexai import ChatVertexAI
from langchain_google_genai import ChatGoogleGenerativeAI
Expand Down
4 changes: 2 additions & 2 deletions backend/src/agents/retriever_rag.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from langchain_core.messages import AnyMessage
from langgraph.graph import END
from langchain_core.tools import BaseTool
from langchain.prompts import ChatPromptTemplate
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import JsonOutputParser
from langchain.tools.render import render_text_description
from langchain_core.tools.render import render_text_description
from langchain_google_vertexai import ChatVertexAI
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain_ollama import ChatOllama
Expand Down
4 changes: 2 additions & 2 deletions backend/src/agents/retriever_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from dotenv import load_dotenv

from langchain_core.tools import tool
from langchain.retrievers import EnsembleRetriever
from langchain.retrievers import ContextualCompressionRetriever
from langchain_classic.retrievers import EnsembleRetriever
from langchain_classic.retrievers import ContextualCompressionRetriever

from ..chains.hybrid_retriever_chain import HybridRetrieverChain
from ..tools.format_docs import format_docs
Expand Down
2 changes: 1 addition & 1 deletion backend/src/chains/base_chain.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional, Union, Any

from langchain.prompts import ChatPromptTemplate
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
from langchain_google_vertexai import ChatVertexAI
from langchain_google_genai import ChatGoogleGenerativeAI
Expand Down
2 changes: 1 addition & 1 deletion backend/src/chains/bm25_retriever_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from langchain_community.retrievers import BM25Retriever
from langchain_core.vectorstores import VectorStoreRetriever
from langchain.docstore.document import Document
from langchain_core.documents import Document
from langchain_google_vertexai import ChatVertexAI
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain_ollama import ChatOllama
Expand Down
8 changes: 3 additions & 5 deletions backend/src/chains/hybrid_retriever_chain.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import os
from typing import Optional, Union, Any

from langchain.retrievers import EnsembleRetriever
from langchain.retrievers import ContextualCompressionRetriever
from langchain_classic.retrievers import EnsembleRetriever
from langchain_classic.retrievers import ContextualCompressionRetriever
from langchain_core.runnables import RunnableParallel, RunnablePassthrough
from langchain_community.cross_encoders import HuggingFaceCrossEncoder
from langchain_google_vertexai import ChatVertexAI
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain_ollama import ChatOllama
from langchain.retrievers.document_compressors.cross_encoder_rerank import (
CrossEncoderReranker,
)
from langchain_classic.retrievers.document_compressors import CrossEncoderReranker

from .base_chain import BaseChain
from .similarity_retriever_chain import SimilarityRetrieverChain
Expand Down
2 changes: 1 addition & 1 deletion backend/src/chains/multi_retriever_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain_ollama import ChatOllama
from langchain_core.runnables import RunnableParallel, RunnablePassthrough
from langchain.retrievers import EnsembleRetriever
from langchain_classic.retrievers import EnsembleRetriever

from .base_chain import BaseChain
from .similarity_retriever_chain import SimilarityRetrieverChain
Expand Down
2 changes: 1 addition & 1 deletion backend/src/chains/similarity_retriever_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Optional, Tuple, Any, Union

from langchain_core.runnables import RunnableParallel, RunnablePassthrough
from langchain.docstore.document import Document
from langchain_core.documents import Document
from langchain_google_vertexai import ChatVertexAI
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain_ollama import ChatOllama
Expand Down
2 changes: 1 addition & 1 deletion backend/src/openroad_mcp/server/orfs/orfs_make.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from src.openroad_mcp.server.orfs.orfs_tools import ORFS
from langchain.prompts import ChatPromptTemplate
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import JsonOutputParser
from src.prompts.prompt_templates import env_prompt_template

Expand Down
4 changes: 2 additions & 2 deletions backend/src/tools/chunk_documents.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.docstore.document import Document
from langchain_text_splitters import RecursiveCharacterTextSplitter
from langchain_core.documents import Document


def chunk_documents(
Expand Down
2 changes: 1 addition & 1 deletion backend/src/tools/format_docs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from langchain.docstore.document import Document
from langchain_core.documents import Document

from ..prompts.prompt_templates import gh_discussion_prompt_template

Expand Down
2 changes: 1 addition & 1 deletion backend/src/tools/process_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from tqdm import tqdm
from typing import Optional

from langchain.docstore.document import Document
from langchain_core.documents import Document
from langchain_community.document_loaders import UnstructuredHTMLLoader
from langchain_text_splitters import RecursiveCharacterTextSplitter

Expand Down
2 changes: 1 addition & 1 deletion backend/src/tools/process_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
from typing import Any

from langchain.docstore.document import Document
from langchain_core.documents import Document

logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO").upper())

Expand Down
2 changes: 1 addition & 1 deletion backend/src/tools/process_md.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from bs4 import BeautifulSoup
from typing import Optional

from langchain.docstore.document import Document
from langchain_core.documents import Document
from langchain_text_splitters import RecursiveCharacterTextSplitter
from .chunk_documents import chunk_documents

Expand Down
2 changes: 1 addition & 1 deletion backend/src/tools/process_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from dotenv import load_dotenv
from pypdf.errors import PdfStreamError

from langchain.docstore.document import Document
from langchain_core.documents import Document
from langchain_community.document_loaders import PyPDFLoader
from langchain_text_splitters import RecursiveCharacterTextSplitter

Expand Down
6 changes: 2 additions & 4 deletions backend/src/vectorstores/faiss.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from langchain_huggingface import HuggingFaceEmbeddings
from langchain_google_genai import GoogleGenerativeAIEmbeddings
from langchain_google_vertexai import VertexAIEmbeddings
from langchain.docstore.document import Document
from langchain_core.documents import Document

from ..tools.process_md import process_md
from ..tools.process_pdf import process_pdf_docs
Expand Down Expand Up @@ -45,9 +45,7 @@ def __init__(
logging.info("Using Google GenerativeAI embeddings...")

elif embeddings_type == "GOOGLE_VERTEXAI":
self.embedding_model = VertexAIEmbeddings(
model_name=self.embeddings_model_name
)
self.embedding_model = VertexAIEmbeddings(model=self.embeddings_model_name)
logging.info("Using Google VertexAI embeddings...")

elif embeddings_type == "HF":
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/test_base_chain.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from unittest.mock import Mock
from langchain.prompts import ChatPromptTemplate
from langchain_core.prompts import ChatPromptTemplate

from src.chains.base_chain import BaseChain

Expand Down
2 changes: 1 addition & 1 deletion backend/tests/test_bm25_retriever_chain.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from unittest.mock import Mock, patch
from langchain.docstore.document import Document
from langchain_core.documents import Document

from src.chains.bm25_retriever_chain import BM25RetrieverChain

Expand Down
2 changes: 1 addition & 1 deletion backend/tests/test_chunk_documents.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from langchain.docstore.document import Document
from langchain_core.documents import Document

from src.tools.chunk_documents import chunk_documents

Expand Down
4 changes: 2 additions & 2 deletions backend/tests/test_faiss_vectorstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from unittest.mock import Mock, patch

from langchain_community.vectorstores.utils import DistanceStrategy
from langchain.docstore.document import Document
from langchain_core.documents import Document

from src.vectorstores.faiss import FAISSVectorDatabase

Expand Down Expand Up @@ -55,7 +55,7 @@ def test_init_with_google_vertexai_embeddings(self):
)

assert db.embeddings_model_name == "textembedding-gecko@001"
mock_vertex.assert_called_once_with(model_name="textembedding-gecko@001")
mock_vertex.assert_called_once_with(model="textembedding-gecko@001")

def test_init_with_invalid_embeddings_type(self):
"""Test initialization with invalid embeddings type raises error."""
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/test_format_docs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from langchain.docstore.document import Document
from langchain_core.documents import Document

from src.tools.format_docs import format_docs, CHUNK_SEPARATOR

Expand Down
11 changes: 1 addition & 10 deletions backend/tests/test_process_md.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from unittest.mock import patch
from langchain_core.documents import Document

from src.tools.process_md import md_to_text

Expand Down Expand Up @@ -263,8 +264,6 @@ def test_process_md_without_splitting(
'{"test.md": "https://example.com"}'
)

from langchain.docstore.document import Document

mock_docs = [
Document(page_content="Test content", metadata={"source": "test.md"})
]
Expand Down Expand Up @@ -300,8 +299,6 @@ def test_process_md_with_splitting(
'{"test.md": "https://example.com"}'
)

from langchain.docstore.document import Document

mock_doc = Document(page_content="Test content", metadata={"source": "test.md"})
mock_load_docs.return_value = [mock_doc]
mock_split.return_value = [mock_doc]
Expand Down Expand Up @@ -343,8 +340,6 @@ def test_process_md_missing_source_in_dict(
"{}" # Empty JSON
)

from langchain.docstore.document import Document

mock_docs = [
Document(page_content="Test content", metadata={"source": "missing.md"})
]
Expand Down Expand Up @@ -388,8 +383,6 @@ def test_process_md_logs_warning_for_missing_source(
mock_listdir.return_value = ["file.md"]
mock_open.return_value.__enter__.return_value.read.return_value = "{}"

from langchain.docstore.document import Document

mock_docs = [
Document(page_content="Test content", metadata={"source": "missing.md"})
]
Expand All @@ -414,8 +407,6 @@ def test_process_md_realistic_workflow(
mock_listdir.return_value = ["installation.md", "usage.md"]
mock_open.return_value.__enter__.return_value.read.return_value = '{"installation.md": "https://docs.example.com/install", "usage.md": "https://docs.example.com/usage"}'

from langchain.docstore.document import Document

mock_docs = [
Document(
page_content="Installation content",
Expand Down
Loading
Loading