Spaces:
Runtime error
Runtime error
jamescalam
commited on
Commit
•
23aa474
1
Parent(s):
f682c4d
Update app.py
Browse files
app.py
CHANGED
@@ -61,7 +61,17 @@ def encode_text(text: str):
|
|
61 |
|
62 |
def prompt_query(text: str):
|
63 |
embeds = encode_text(text)
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
prompts = [
|
66 |
match['metadata']['prompt'] for match in xc['matches']
|
67 |
]
|
@@ -115,7 +125,17 @@ def test_image(_id, image):
|
|
115 |
|
116 |
def prompt_image(text: str):
|
117 |
embeds = encode_text(text)
|
118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
image_urls = [
|
120 |
match['metadata']['image_url'] for match in xc['matches']
|
121 |
]
|
|
|
61 |
|
62 |
def prompt_query(text: str):
|
63 |
embeds = encode_text(text)
|
64 |
+
try:
|
65 |
+
xc = index.query(embeds, top_k=30, include_metadata=True)
|
66 |
+
except Exception as e:
|
67 |
+
print(f"Error during query: {e}")
|
68 |
+
# reinitialize connection
|
69 |
+
pinecone.init(api_key=PINECONE_KEY, environment='us-west1-gcp')
|
70 |
+
index = pinecone.Index(index_id)
|
71 |
+
try:
|
72 |
+
xc = index.query(embeds, top_k=30, include_metadata=True)
|
73 |
+
except Exception as e:
|
74 |
+
raise ValueError(e)
|
75 |
prompts = [
|
76 |
match['metadata']['prompt'] for match in xc['matches']
|
77 |
]
|
|
|
125 |
|
126 |
def prompt_image(text: str):
|
127 |
embeds = encode_text(text)
|
128 |
+
try:
|
129 |
+
xc = index.query(embeds, top_k=9, include_metadata=True)
|
130 |
+
except Exception as e:
|
131 |
+
print(f"Error during query: {e}")
|
132 |
+
# reinitialize connection
|
133 |
+
pinecone.init(api_key=PINECONE_KEY, environment='us-west1-gcp')
|
134 |
+
index = pinecone.Index(index_id)
|
135 |
+
try:
|
136 |
+
xc = index.query(embeds, top_k=9, include_metadata=True)
|
137 |
+
except Exception as e:
|
138 |
+
raise ValueError(e)
|
139 |
image_urls = [
|
140 |
match['metadata']['image_url'] for match in xc['matches']
|
141 |
]
|