Spaces:
Sleeping
Sleeping
Commit
Β·
4f85312
1
Parent(s):
23c0787
Refined rizz
Browse files
api/routers/reply_generator.py
CHANGED
|
@@ -13,7 +13,6 @@ graph = reply_generator.run()
|
|
| 13 |
|
| 14 |
class UserRequest(BaseModel):
|
| 15 |
image_base64: str
|
| 16 |
-
user_query: Optional[str] = None
|
| 17 |
tones: Optional[List[str]] = None
|
| 18 |
|
| 19 |
@router.post("/reply-generator")
|
|
@@ -27,7 +26,6 @@ async def generate_reply(request: UserRequest):
|
|
| 27 |
stored_data['conversation_context'] = conversation_text
|
| 28 |
|
| 29 |
result = graph.invoke({
|
| 30 |
-
'messages': [request.user_query],
|
| 31 |
'tones': request.tones,
|
| 32 |
'conversation_chat': stored_data['conversation_context']
|
| 33 |
},config=config)
|
|
|
|
| 13 |
|
| 14 |
class UserRequest(BaseModel):
|
| 15 |
image_base64: str
|
|
|
|
| 16 |
tones: Optional[List[str]] = None
|
| 17 |
|
| 18 |
@router.post("/reply-generator")
|
|
|
|
| 26 |
stored_data['conversation_context'] = conversation_text
|
| 27 |
|
| 28 |
result = graph.invoke({
|
|
|
|
| 29 |
'tones': request.tones,
|
| 30 |
'conversation_chat': stored_data['conversation_context']
|
| 31 |
},config=config)
|
src/pickup_line_generator/generate.py
CHANGED
|
@@ -12,8 +12,8 @@ class Generate:
|
|
| 12 |
|
| 13 |
def run(self, state:State):
|
| 14 |
messages = [SystemMessage(content=pickup_line_prompt),
|
| 15 |
-
FunctionMessage(name='attrubutes',content=f'''The attributes of person are: {state['attributes']}'''),
|
| 16 |
-
|
| 17 |
pickup_lines = reply_llm.with_structured_output(PickupFormatter).invoke(messages)
|
| 18 |
return {
|
| 19 |
'messages':[{'role': 'assistant', 'content': str(pickup_lines.model_dump())}],
|
|
|
|
| 12 |
|
| 13 |
def run(self, state:State):
|
| 14 |
messages = [SystemMessage(content=pickup_line_prompt),
|
| 15 |
+
FunctionMessage(name='attrubutes',content=f'''The attributes of person are: {state['attributes']}\n. The user is saying: {state['messages'][-1]}'''),
|
| 16 |
+
HumanMessage(content=f'''The required tone: {state["tones"]}''')]
|
| 17 |
pickup_lines = reply_llm.with_structured_output(PickupFormatter).invoke(messages)
|
| 18 |
return {
|
| 19 |
'messages':[{'role': 'assistant', 'content': str(pickup_lines.model_dump())}],
|
src/reply_generator/generate.py
CHANGED
|
@@ -19,7 +19,7 @@ class Generate:
|
|
| 19 |
print(reply.model_dump())
|
| 20 |
|
| 21 |
return {
|
| 22 |
-
'messages':[{'role': 'assistant', 'content': str(reply.model_dump())}],
|
| 23 |
'replies': reply.model_dump()
|
| 24 |
}
|
| 25 |
|
|
|
|
| 19 |
print(reply.model_dump())
|
| 20 |
|
| 21 |
return {
|
| 22 |
+
'messages':[{'role': 'assistant', 'content': f'''The generated replies are: {str(reply.model_dump())}'''}],
|
| 23 |
'replies': reply.model_dump()
|
| 24 |
}
|
| 25 |
|
streamlit/pages/check_looks.py
CHANGED
|
@@ -3,7 +3,9 @@ import requests
|
|
| 3 |
import base64
|
| 4 |
|
| 5 |
# FastAPI endpoint
|
| 6 |
-
API_URL = "https://dvorakinnovationai-revel-rizz-api.hf.space/api/looks-analyzer"
|
|
|
|
|
|
|
| 7 |
|
| 8 |
st.set_page_config(page_title="Looks Analyzer", page_icon="π§βπ¨", layout="centered")
|
| 9 |
|
|
|
|
| 3 |
import base64
|
| 4 |
|
| 5 |
# FastAPI endpoint
|
| 6 |
+
API_URL = "https://dvorakinnovationai-revel-rizz-api.hf.space/api/looks-analyzer"
|
| 7 |
+
# API_URL = "http://127.0.0.1:8000//api/looks-analyzer"
|
| 8 |
+
|
| 9 |
|
| 10 |
st.set_page_config(page_title="Looks Analyzer", page_icon="π§βπ¨", layout="centered")
|
| 11 |
|
streamlit/pages/pickup_line_generator.py
CHANGED
|
@@ -2,7 +2,9 @@ import streamlit as st
|
|
| 2 |
import requests
|
| 3 |
|
| 4 |
# FastAPI endpoint
|
| 5 |
-
API_URL = "https://dvorakinnovationai-revel-rizz-api.hf.space/api/pickup-line-generator"
|
|
|
|
|
|
|
| 6 |
|
| 7 |
st.set_page_config(page_title="Pickup Line Generator", page_icon="π", layout="centered")
|
| 8 |
|
|
@@ -32,7 +34,7 @@ if st.button("Generate Pickup Line"):
|
|
| 32 |
attributes_list = [attr.strip() for attr in attributes.split(",") if attr.strip()]
|
| 33 |
|
| 34 |
payload = {
|
| 35 |
-
"user_query": user_query if user_query.strip() else
|
| 36 |
"tones": tones if tones else None,
|
| 37 |
"attributes": attributes_list,
|
| 38 |
}
|
|
|
|
| 2 |
import requests
|
| 3 |
|
| 4 |
# FastAPI endpoint
|
| 5 |
+
API_URL = "https://dvorakinnovationai-revel-rizz-api.hf.space/api/pickup-line-generator"
|
| 6 |
+
# API_URL = "http://127.0.0.1:8000//api/pickup-line-generator"
|
| 7 |
+
|
| 8 |
|
| 9 |
st.set_page_config(page_title="Pickup Line Generator", page_icon="π", layout="centered")
|
| 10 |
|
|
|
|
| 34 |
attributes_list = [attr.strip() for attr in attributes.split(",") if attr.strip()]
|
| 35 |
|
| 36 |
payload = {
|
| 37 |
+
"user_query": user_query if user_query.strip() else '',
|
| 38 |
"tones": tones if tones else None,
|
| 39 |
"attributes": attributes_list,
|
| 40 |
}
|
streamlit/pages/reply_generator.py
CHANGED
|
@@ -3,8 +3,8 @@ import requests
|
|
| 3 |
import base64
|
| 4 |
|
| 5 |
# FastAPI endpoint
|
| 6 |
-
API_URL = "https://dvorakinnovationai-revel-rizz-api.hf.space/api/reply-generator"
|
| 7 |
-
|
| 8 |
|
| 9 |
st.set_page_config(page_title="Reply Generator", page_icon="π¬", layout="centered")
|
| 10 |
|
|
@@ -15,7 +15,6 @@ st.write("Upload image of chat , ask a question, and get AI-powered replies.")
|
|
| 15 |
uploaded_file = st.file_uploader("Upload an image (JPG/PNG)", type=["jpg", "jpeg", "png"])
|
| 16 |
|
| 17 |
# User query input
|
| 18 |
-
user_query = st.text_area("Enter your query", placeholder="Type your question here...")
|
| 19 |
|
| 20 |
# Tones (multi-select)
|
| 21 |
available_tones = ["formal", "casual", "friendly", "professional", "humorous"]
|
|
@@ -25,8 +24,7 @@ tones = st.multiselect("Select tones (optional)", available_tones)
|
|
| 25 |
if st.button("Generate Reply"):
|
| 26 |
if uploaded_file is None:
|
| 27 |
st.error("β οΈ Please upload an image first.")
|
| 28 |
-
|
| 29 |
-
st.error("β οΈ Please enter a query.")
|
| 30 |
else:
|
| 31 |
try:
|
| 32 |
# Convert image to base64
|
|
@@ -35,7 +33,6 @@ if st.button("Generate Reply"):
|
|
| 35 |
|
| 36 |
payload = {
|
| 37 |
"image_base64": image_base64,
|
| 38 |
-
"user_query": user_query,
|
| 39 |
"tones": tones if tones else None,
|
| 40 |
}
|
| 41 |
|
|
|
|
| 3 |
import base64
|
| 4 |
|
| 5 |
# FastAPI endpoint
|
| 6 |
+
API_URL = "https://dvorakinnovationai-revel-rizz-api.hf.space/api/reply-generator"
|
| 7 |
+
# API_URL = "http://127.0.0.1:8000//api/reply-generator"
|
| 8 |
|
| 9 |
st.set_page_config(page_title="Reply Generator", page_icon="π¬", layout="centered")
|
| 10 |
|
|
|
|
| 15 |
uploaded_file = st.file_uploader("Upload an image (JPG/PNG)", type=["jpg", "jpeg", "png"])
|
| 16 |
|
| 17 |
# User query input
|
|
|
|
| 18 |
|
| 19 |
# Tones (multi-select)
|
| 20 |
available_tones = ["formal", "casual", "friendly", "professional", "humorous"]
|
|
|
|
| 24 |
if st.button("Generate Reply"):
|
| 25 |
if uploaded_file is None:
|
| 26 |
st.error("β οΈ Please upload an image first.")
|
| 27 |
+
|
|
|
|
| 28 |
else:
|
| 29 |
try:
|
| 30 |
# Convert image to base64
|
|
|
|
| 33 |
|
| 34 |
payload = {
|
| 35 |
"image_base64": image_base64,
|
|
|
|
| 36 |
"tones": tones if tones else None,
|
| 37 |
}
|
| 38 |
|