Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -213,7 +213,7 @@ with open("/home/user/app/DataBase/datetimeRecords.json","r") as read:
|
|
213 |
dateTimeRecord=json.load(read)
|
214 |
with column2:
|
215 |
st.header("HISTORY")
|
216 |
-
tab1,tab2,tab3,tab4=st.tabs(["CHAT HISTORY","IMAGES","PROMPT IMPROVEMENT","LOGIN"])
|
217 |
with tab1:
|
218 |
|
219 |
|
@@ -270,7 +270,57 @@ with column2:
|
|
270 |
image = prompts_[-1].crop((0, 0, size, size))
|
271 |
image.putalpha(mask)
|
272 |
st.image(image)
|
273 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
274 |
with tab2:
|
275 |
|
276 |
if "current_image" in dictionary and len(dictionary['current_image']):
|
|
|
213 |
dateTimeRecord=json.load(read)
|
214 |
with column2:
|
215 |
st.header("HISTORY")
|
216 |
+
tab1,tab2,tab3,tab4=st.tabs(["CHAT HISTORY","FREE API","IMAGES","PROMPT IMPROVEMENT","LOGIN"])
|
217 |
with tab1:
|
218 |
|
219 |
|
|
|
270 |
image = prompts_[-1].crop((0, 0, size, size))
|
271 |
image.putalpha(mask)
|
272 |
st.image(image)
|
273 |
+
|
274 |
+
with tab5:
|
275 |
+
st.write("ADD PINECONE API KEY TO GET FREE LLM API")
|
276 |
+
random_val = """
|
277 |
+
def prompt_limmiter(prompt):
|
278 |
+
|
279 |
+
import requests
|
280 |
+
from sentence_transformers import SentenceTransformer
|
281 |
+
from pinecone import Pinecone, ServerlessSpec
|
282 |
+
Gen_api = "https://8417-201-238-124-65.ngrok-free.app/api/llm-response"
|
283 |
+
api_key = "xxxxxxxxxxxxxxxxxxxxxx----pine cone api key---xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
284 |
+
pc = Pinecone(api_key=api_key)
|
285 |
+
model = SentenceTransformer("all-mpnet-base-v2")
|
286 |
+
try:
|
287 |
+
index_name = "quickstart"
|
288 |
+
pc.create_index(
|
289 |
+
name=index_name,
|
290 |
+
dimension=768,
|
291 |
+
metric="cosine",
|
292 |
+
spec=ServerlessSpec(
|
293 |
+
cloud="aws",
|
294 |
+
region="us-east-1"
|
295 |
+
)
|
296 |
+
)
|
297 |
+
except:
|
298 |
+
pass
|
299 |
+
index = pc.Index(index_name)
|
300 |
+
index.upsert(
|
301 |
+
vectors=[
|
302 |
+
{
|
303 |
+
"id": "lorum",
|
304 |
+
"values": [float(i) for i in list(model.encode("lorum"))],
|
305 |
+
"metadata": {"string":str(prompt)}
|
306 |
+
|
307 |
+
}
|
308 |
+
]
|
309 |
+
)
|
310 |
+
|
311 |
+
gen_api_response = requests.post(url = Gen_api,json={"api_key": api_key},verify=False)
|
312 |
+
|
313 |
+
if gen_api_response.json().get("status"):
|
314 |
+
response = index.query(
|
315 |
+
vector=[float(i) for i in model.encode(str(prompt))],
|
316 |
+
top_k=1,
|
317 |
+
include_metadata=True,
|
318 |
+
)
|
319 |
+
|
320 |
+
return response['matches'][0]['metadata']['string']
|
321 |
+
"""
|
322 |
+
with st.container(height=600):
|
323 |
+
st.code(random_val,language="python")
|
324 |
with tab2:
|
325 |
|
326 |
if "current_image" in dictionary and len(dictionary['current_image']):
|