name updated
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import base64
|
|
2 |
import io
|
3 |
import json
|
4 |
import os
|
|
|
5 |
from typing import Any, Dict, List
|
6 |
|
7 |
import chromadb
|
@@ -120,7 +121,7 @@ def main():
|
|
120 |
if api_key:
|
121 |
# Make API call
|
122 |
st.success("Running Gemini!")
|
123 |
-
with st.spinner(
|
124 |
response = call_gemini_api(image_base64, api_key)
|
125 |
|
126 |
with st.expander("Raw output from Gemini"):
|
@@ -221,11 +222,22 @@ def main():
|
|
221 |
token_split_texts += token_splitter.split_text(text)
|
222 |
st.success("Tokenized successfully.")
|
223 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
# Add to vector database
|
225 |
embedding_function = SentenceTransformerEmbeddingFunction()
|
226 |
chroma_client = chromadb.Client()
|
227 |
chroma_collection = chroma_client.create_collection(
|
228 |
-
|
229 |
)
|
230 |
ids = [str(i) for i in range(len(token_split_texts))]
|
231 |
chroma_collection.add(ids=ids, documents=token_split_texts)
|
|
|
2 |
import io
|
3 |
import json
|
4 |
import os
|
5 |
+
import string
|
6 |
from typing import Any, Dict, List
|
7 |
|
8 |
import chromadb
|
|
|
121 |
if api_key:
|
122 |
# Make API call
|
123 |
st.success("Running Gemini!")
|
124 |
+
with st.spinner("Wait for it..."):
|
125 |
response = call_gemini_api(image_base64, api_key)
|
126 |
|
127 |
with st.expander("Raw output from Gemini"):
|
|
|
222 |
token_split_texts += token_splitter.split_text(text)
|
223 |
st.success("Tokenized successfully.")
|
224 |
|
225 |
+
# Generate a random number between 1 billion and 10 billion.
|
226 |
+
random_number: int = np.random.randint(low=1e9, high=1e10)
|
227 |
+
|
228 |
+
# Generate a random string consisting of 10 uppercase letters and digits.
|
229 |
+
random_string: str = "".join(
|
230 |
+
np.random.choice(list(string.ascii_uppercase + string.digits), size=10)
|
231 |
+
)
|
232 |
+
|
233 |
+
# Combine the random number and random string into one identifier.
|
234 |
+
combined_string: str = f"{random_number}{random_string}"
|
235 |
+
|
236 |
# Add to vector database
|
237 |
embedding_function = SentenceTransformerEmbeddingFunction()
|
238 |
chroma_client = chromadb.Client()
|
239 |
chroma_collection = chroma_client.create_collection(
|
240 |
+
combined_string, embedding_function=embedding_function
|
241 |
)
|
242 |
ids = [str(i) for i in range(len(token_split_texts))]
|
243 |
chroma_collection.add(ids=ids, documents=token_split_texts)
|