Spaces:
Runtime error
Runtime error
Update hybrid_search.py
Browse files10 unmodified lines11121314151617181920212223242511 unmodified lines3738394041424344454647484950515253244 unmodified lines29829930030130230330430530630710 unmodified linesfrom langchain_core.runnables import RunnablePassthroughfrom langchain_core.output_parsers import StrOutputParserfrom langchain_huggingface import HuggingFaceEmbeddingsfrom langchain_chroma import Chromafrom langchain_ollama import OllamaLLMclass ArloRAGPipeline:def __init__(self,documents_path: str = "data/complete_arlo_docs.json",persist_directory: str = "data/chromadb",model_name: str = "llama3.1",enable_web_search: bool = True):self.documents_path = documents_path11 unmodified linesdef check_ollama_connection(self) -> bool:"""Health check to ensure Ollama server is reachable"""print(f"π Checking connection to Ollama at {self.base_url}...")try:response = requests.get(f"{self.base_url}/api/tags", timeout=5)if response.status_code == 200:print("β Ollama server is UP!")return Trueexcept Exception as e:print(f"β Could not connect to Ollama: {e}")print(" Make sure 'ollama serve' is running")return Falsedef load_documents(self):244 unmodified linesdef setup_rag_chain(self):"""Initialize Ollama LLM"""print(f"π€ Setting up LLM ({self.model_name})...")self.llm = OllamaLLM(model=self.model_name,temperature=0.1,base_url=self.base_url)print(f"β LLM ready")10 unmodified lines1112131415161718192021222324252611 unmodified lines383940414243444546244 unmodified lines29129229329429529629729829930010 unmodified linesfrom langchain_core.runnables import RunnablePassthroughfrom langchain_core.output_parsers import StrOutputParserfrom langchain_huggingface import HuggingFaceEmbeddings#from langchain_chroma import Chromaimport osfrom langchain_groq import ChatGroqclass ArloRAGPipeline:def __init__(self,documents_path: str = "data/complete_arlo_docs.json",persist_directory: str = "data/chromadb",model_name: str = "llama-3.1-70b-versatile",enable_web_search: bool = True):self.documents_path = documents_path11 unmodified linesdef check_ollama_connection(self) -> bool:"""Check if Groq API key is available"""import osreturn bool(os.getenv("GROQ_API_KEY"))def load_documents(self):244 unmodified linesdef setup_rag_chain(self):"""Initialize Ollama LLM"""print(f"π€ Setting up LLM ({self.model_name})...")self.llm = ChatGroq(model=self.model_name,temperature=0,groq_api_key=os.getenv("GROQ_API_KEY"))print(f"β LLM ready")
hybrid_search.py+11-18