clean final: HF Inference API embeddings (no disk)
Browse files
rag.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
# rag.py –- bullet-proof: online fetch with fallback on any error
|
| 2 |
from __future__ import annotations
|
| 3 |
import os, re, json, requests
|
| 4 |
from functools import lru_cache
|
|
@@ -6,7 +5,7 @@ from typing import List, Tuple
|
|
| 6 |
|
| 7 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
| 8 |
from langchain_community.vectorstores import FAISS
|
| 9 |
-
from langchain_huggingface import HuggingFaceEndpoint
|
| 10 |
from langchain_core.prompts import PromptTemplate
|
| 11 |
from langchain.chains import RetrievalQA
|
| 12 |
from supabase import create_client
|
|
@@ -96,8 +95,6 @@ def get_texts() -> List[str]:
|
|
| 96 |
def get_vectorstore() -> FAISS:
|
| 97 |
texts = get_texts()
|
| 98 |
|
| 99 |
-
# HF Inference Providers – zero disk, zero cache
|
| 100 |
-
from langchain_huggingface import HuggingFaceInferenceAPIEmbeddings
|
| 101 |
embeddings = HuggingFaceInferenceAPIEmbeddings(
|
| 102 |
api_key=HF_TOKEN,
|
| 103 |
model_name="sentence-transformers/all-MiniLM-L6-v2"
|
|
|
|
|
|
|
| 1 |
from __future__ import annotations
|
| 2 |
import os, re, json, requests
|
| 3 |
from functools import lru_cache
|
|
|
|
| 5 |
|
| 6 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
| 7 |
from langchain_community.vectorstores import FAISS
|
| 8 |
+
from langchain_huggingface import HuggingFaceEndpoint, HuggingFaceInferenceAPIEmbeddings # ✅ FIXED: added missing import
|
| 9 |
from langchain_core.prompts import PromptTemplate
|
| 10 |
from langchain.chains import RetrievalQA
|
| 11 |
from supabase import create_client
|
|
|
|
| 95 |
def get_vectorstore() -> FAISS:
|
| 96 |
texts = get_texts()
|
| 97 |
|
|
|
|
|
|
|
| 98 |
embeddings = HuggingFaceInferenceAPIEmbeddings(
|
| 99 |
api_key=HF_TOKEN,
|
| 100 |
model_name="sentence-transformers/all-MiniLM-L6-v2"
|