Spaces:
Runtime error
Runtime error
Update agent.py
Browse files
agent.py
CHANGED
@@ -26,7 +26,7 @@ import uuid
|
|
26 |
import requests
|
27 |
import json
|
28 |
from langchain_core.documents import Document
|
29 |
-
from
|
30 |
|
31 |
#from langchain.embeddings import BERTEmbeddings
|
32 |
#from langchain_community.embeddings import HuggingFaceEmbeddings
|
@@ -64,7 +64,7 @@ from typing import Union
|
|
64 |
from functools import reduce
|
65 |
from youtube_transcript_api import YouTubeTranscriptApi
|
66 |
from youtube_transcript_api._errors import TranscriptsDisabled, VideoUnavailable
|
67 |
-
import
|
68 |
|
69 |
from langchain.schema import Document
|
70 |
|
@@ -388,9 +388,9 @@ docs = [
|
|
388 |
texts = [doc.page_content for doc in docs]
|
389 |
|
390 |
# Initialize the embedding model
|
391 |
-
embedding_model = HuggingFaceEmbeddings(model_name="
|
392 |
|
393 |
-
|
394 |
|
395 |
# Create the FAISS index
|
396 |
vector_store = FAISS.from_documents(docs, embedding_model)
|
|
|
26 |
import requests
|
27 |
import json
|
28 |
from langchain_core.documents import Document
|
29 |
+
from langchain_community.vectorstores import FAISS
|
30 |
|
31 |
#from langchain.embeddings import BERTEmbeddings
|
32 |
#from langchain_community.embeddings import HuggingFaceEmbeddings
|
|
|
64 |
from functools import reduce
|
65 |
from youtube_transcript_api import YouTubeTranscriptApi
|
66 |
from youtube_transcript_api._errors import TranscriptsDisabled, VideoUnavailable
|
67 |
+
from langchain_faiss import FAISS
|
68 |
|
69 |
from langchain.schema import Document
|
70 |
|
|
|
388 |
texts = [doc.page_content for doc in docs]
|
389 |
|
390 |
# Initialize the embedding model
|
391 |
+
embedding_model = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")
|
392 |
|
393 |
+
docs = [Document(page_content=text, metadata={"task_id": item["task_id"]}) for item in data]
|
394 |
|
395 |
# Create the FAISS index
|
396 |
vector_store = FAISS.from_documents(docs, embedding_model)
|