MISSAOUI commited on
Commit
919ec5c
·
verified ·
1 Parent(s): 2b7e35b

Update app/main.py

Browse files
Files changed (1) hide show
  1. app/main.py +7 -3
app/main.py CHANGED
@@ -1,10 +1,9 @@
1
  from fastapi import FastAPI
2
  from fastapi.middleware.cors import CORSMiddleware
3
  from contextlib import asynccontextmanager
4
-
5
  from app.api import analysis,reports,infos,chatbot
6
  from langchain_community.chat_models import ChatOpenAI
7
- from sentence_transformers import SentenceTransformer
8
  from langchain_community.vectorstores import FAISS
9
  from app.utils.rag import get_chain_disease, get_chain_infos, get_chain_chat
10
  import os, asyncio
@@ -18,9 +17,14 @@ os.environ["HF_HOME"] = "/tmp/cache"
18
 
19
  # Load the model into the writable cache directory
20
 
 
21
  @asynccontextmanager
22
  async def lifespan(app: FastAPI):
23
- embedding_model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2", cache_folder="/tmp/cache")
 
 
 
 
24
 
25
 
26
  vectorstore = await asyncio.to_thread(
 
1
  from fastapi import FastAPI
2
  from fastapi.middleware.cors import CORSMiddleware
3
  from contextlib import asynccontextmanager
4
+ from langchain.embeddings import HuggingFaceEmbeddings
5
  from app.api import analysis,reports,infos,chatbot
6
  from langchain_community.chat_models import ChatOpenAI
 
7
  from langchain_community.vectorstores import FAISS
8
  from app.utils.rag import get_chain_disease, get_chain_infos, get_chain_chat
9
  import os, asyncio
 
17
 
18
  # Load the model into the writable cache directory
19
 
20
+
21
  @asynccontextmanager
22
  async def lifespan(app: FastAPI):
23
+ embedding_model = HuggingFaceEmbeddings(
24
+
25
+ model_name="sentence-transformers/all-MiniLM-L6-v2",
26
+ model_kwargs={"cache_folder": "/tmp/cache","use_auth_token": HUGGINGFACE_API_KEY} # ou sans si pas nécessaire
27
+ )
28
 
29
 
30
  vectorstore = await asyncio.to_thread(