Spaces:
Runtime error
Runtime error
Update sherlock2.py
Browse files- sherlock2.py +6 -5
sherlock2.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import google.generativeai as genai
|
|
|
2 |
import streamlit as st
|
3 |
from bs4 import BeautifulSoup
|
4 |
import wikipedia
|
@@ -35,19 +36,19 @@ sherlock_guidelines = """
|
|
35 |
* Be confident in your deductions but remain open to new information and alternative perspectives.
|
36 |
"""
|
37 |
|
38 |
-
# Generate embeddings
|
39 |
-
|
40 |
|
41 |
# Function for embedding generation (using models/embedding-001)
|
42 |
def generate_embeddings_from_documents(extracted_text):
|
43 |
-
"""Generates embeddings for a list of extracted text documents using the 'models/embedding-001' model
|
44 |
and the appropriate task type."""
|
45 |
embeddings = []
|
46 |
for text in extracted_text:
|
47 |
try:
|
48 |
# Determine the appropriate task type (e.g., "RETRIEVAL_DOCUMENT" for search/similarity)
|
49 |
-
task_type = "RETRIEVAL_DOCUMENT"
|
50 |
-
response =
|
51 |
embeddings.append(response["embedding"])
|
52 |
except Exception as e:
|
53 |
st.error(f"Error generating embeddings: {e}")
|
|
|
1 |
import google.generativeai as genai
|
2 |
+
import google.ai.generativelanguage as glm
|
3 |
import streamlit as st
|
4 |
from bs4 import BeautifulSoup
|
5 |
import wikipedia
|
|
|
36 |
* Be confident in your deductions but remain open to new information and alternative perspectives.
|
37 |
"""
|
38 |
|
39 |
+
# Generate embeddings using the Gemini Embedding API
|
40 |
+
embed_model = 'models/embedding-001'
|
41 |
|
42 |
# Function for embedding generation (using models/embedding-001)
|
43 |
def generate_embeddings_from_documents(extracted_text):
|
44 |
+
"""Generates embeddings for a list of extracted text documents using the 'models/embedding-001' model
|
45 |
and the appropriate task type."""
|
46 |
embeddings = []
|
47 |
for text in extracted_text:
|
48 |
try:
|
49 |
# Determine the appropriate task type (e.g., "RETRIEVAL_DOCUMENT" for search/similarity)
|
50 |
+
task_type = "RETRIEVAL_DOCUMENT"
|
51 |
+
response = genai.embed_content(model=embed_model, content=text, task_type=task_type)
|
52 |
embeddings.append(response["embedding"])
|
53 |
except Exception as e:
|
54 |
st.error(f"Error generating embeddings: {e}")
|