Spaces:
Runtime error
Runtime error
update
Browse files
app.py
CHANGED
@@ -17,6 +17,21 @@ GOOGLE_API_KEY=os.environ['GOOGLE_API_KEY']
|
|
17 |
|
18 |
loader = WebBaseLoader("https://www.google.com/finance/?hl=en")
|
19 |
docs = loader.load()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
# If there is no environment variable set for the API key, you can pass the API
|
21 |
# key to the parameter `google_api_key` of the `ChatGoogleGenerativeAI` function:
|
22 |
# `google_api_key="key"`.
|
|
|
17 |
|
18 |
loader = WebBaseLoader("https://www.google.com/finance/?hl=en")
|
19 |
docs = loader.load()
|
20 |
+
|
21 |
+
gemini_embeddings = GoogleGenerativeAIEmbeddings(model="models/embedding-001")
|
22 |
+
|
23 |
+
# Save to disk
|
24 |
+
vectorstore = Chroma.from_documents(
|
25 |
+
documents=docs, # Data
|
26 |
+
embedding=gemini_embeddings, # Embedding model
|
27 |
+
persist_directory="./chroma_db" # Directory to save data
|
28 |
+
)
|
29 |
+
|
30 |
+
vectorstore_disk = Chroma(
|
31 |
+
persist_directory="./chroma_db", # Directory of db
|
32 |
+
embedding_function=gemini_embeddings # Embedding model
|
33 |
+
)
|
34 |
+
retriever = vectorstore_disk.as_retriever(search_kwargs={"k": 1})
|
35 |
# If there is no environment variable set for the API key, you can pass the API
|
36 |
# key to the parameter `google_api_key` of the `ChatGoogleGenerativeAI` function:
|
37 |
# `google_api_key="key"`.
|