Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,14 +7,14 @@ from prompts import prompts
|
|
| 7 |
from constants import JSON_SCHEMA_FOR_GPT, UPDATED_MODEL_ONLY_SCHEMA, JSON_SCHEMA_FOR_LOC_ONLY
|
| 8 |
from gpt import runAssistant, checkRunStatus, retrieveThread, createAssistant, saveFileOpenAI, startAssistantThread, \
|
| 9 |
create_chat_completion_request_open_ai_for_summary, addMessageToThread, create_image_completion_request_gpt
|
| 10 |
-
from summarizer import create_brand_html, create_langchain_openai_query
|
| 11 |
from theme import flux_generated_image, flux_generated_image_seed
|
| 12 |
import time
|
| 13 |
from PIL import Image
|
| 14 |
import io
|
| 15 |
from streamlit_gsheets import GSheetsConnection
|
| 16 |
|
| 17 |
-
|
| 18 |
|
| 19 |
|
| 20 |
def process_run(st, thread_id, assistant_id):
|
|
@@ -40,6 +40,8 @@ def page5():
|
|
| 40 |
key="Caption Generation System Prompt")
|
| 41 |
caption_prompt = st.text_area("Caption Prompt", value=prompts["CAPTION_PROMPT"],
|
| 42 |
key="Caption Generation Prompt")
|
|
|
|
|
|
|
| 43 |
st.text("Running on Claude")
|
| 44 |
col1, col2 = st.columns([1, 2])
|
| 45 |
with col1:
|
|
@@ -48,6 +50,7 @@ def page5():
|
|
| 48 |
print(st.session_state["system_prompt"])
|
| 49 |
st.session_state["caption_system_prompt"] = caption_system_prompt
|
| 50 |
st.session_state["caption_prompt"] = caption_prompt
|
|
|
|
| 51 |
st.success("Saved your prompts")
|
| 52 |
with col2:
|
| 53 |
if st.button("Start Testing!"):
|
|
@@ -88,9 +91,20 @@ def page2():
|
|
| 88 |
st.session_state['brand_link'] = brand_link
|
| 89 |
if st.button("Get Brand Summary"):
|
| 90 |
if brand_link:
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
st.success("Brand summary fetched!")
|
| 95 |
else:
|
| 96 |
st.warning("Please add a brand link.")
|
|
|
|
| 7 |
from constants import JSON_SCHEMA_FOR_GPT, UPDATED_MODEL_ONLY_SCHEMA, JSON_SCHEMA_FOR_LOC_ONLY
|
| 8 |
from gpt import runAssistant, checkRunStatus, retrieveThread, createAssistant, saveFileOpenAI, startAssistantThread, \
|
| 9 |
create_chat_completion_request_open_ai_for_summary, addMessageToThread, create_image_completion_request_gpt
|
| 10 |
+
from summarizer import create_brand_html, create_langchain_openai_query, create_screenshot_from_scrap_fly
|
| 11 |
from theme import flux_generated_image, flux_generated_image_seed
|
| 12 |
import time
|
| 13 |
from PIL import Image
|
| 14 |
import io
|
| 15 |
from streamlit_gsheets import GSheetsConnection
|
| 16 |
|
| 17 |
+
conn = st.connection("gsheets", type=GSheetsConnection)
|
| 18 |
|
| 19 |
|
| 20 |
def process_run(st, thread_id, assistant_id):
|
|
|
|
| 40 |
key="Caption Generation System Prompt")
|
| 41 |
caption_prompt = st.text_area("Caption Prompt", value=prompts["CAPTION_PROMPT"],
|
| 42 |
key="Caption Generation Prompt")
|
| 43 |
+
brand_summary_prompt = st.text_area("Prompt for Brand Summary", value=prompts["BRAND_SUMMARY_PROMPT"],
|
| 44 |
+
key="Brand summary prompt")
|
| 45 |
st.text("Running on Claude")
|
| 46 |
col1, col2 = st.columns([1, 2])
|
| 47 |
with col1:
|
|
|
|
| 50 |
print(st.session_state["system_prompt"])
|
| 51 |
st.session_state["caption_system_prompt"] = caption_system_prompt
|
| 52 |
st.session_state["caption_prompt"] = caption_prompt
|
| 53 |
+
st.session_state["brand_prompt"] = brand_summary_prompt
|
| 54 |
st.success("Saved your prompts")
|
| 55 |
with col2:
|
| 56 |
if st.button("Start Testing!"):
|
|
|
|
| 91 |
st.session_state['brand_link'] = brand_link
|
| 92 |
if st.button("Get Brand Summary"):
|
| 93 |
if brand_link:
|
| 94 |
+
st.text("Using Scrapfly")
|
| 95 |
+
brand_summary_html = create_screenshot_from_scrap_fly(brand_link)
|
| 96 |
+
if brand_summary_html["success"]:
|
| 97 |
+
brand_image_embed = embed_base64_for_claude(brand_summary_html["location"])
|
| 98 |
+
brand_summary_response = create_claude_image_request_for_image_captioning(
|
| 99 |
+
"Fashion expert of understanding brand details",
|
| 100 |
+
st.session_state["brand_prompt"], brand_image_embed)
|
| 101 |
+
st.session_state['brand_summary'] = brand_summary_response
|
| 102 |
+
else:
|
| 103 |
+
st.text(f"Scrapfly failed due to: {brand_summary_html["error"]}")
|
| 104 |
+
st.text("Using Langchain")
|
| 105 |
+
brand_summary_html = create_brand_html(brand_link)
|
| 106 |
+
brand_summary = create_langchain_openai_query(brand_summary_html)
|
| 107 |
+
st.session_state['brand_summary'] = brand_summary
|
| 108 |
st.success("Brand summary fetched!")
|
| 109 |
else:
|
| 110 |
st.warning("Please add a brand link.")
|