tarujain8 commited on
Commit
a3400d1
·
1 Parent(s): 2458e9b

feat: add startup logs and sleep delay to start script for service initialization

Browse files
.gitignore CHANGED
@@ -1,4 +1,12 @@
1
  __pycache__/
2
  .env
3
  *.pyc
4
- velra_env/
 
 
 
 
 
 
 
 
 
1
  __pycache__/
2
  .env
3
  *.pyc
4
+ velra_env/
5
+ .venv/
6
+ venv/
7
+
8
+
9
+ velra_env/
10
+ __pycache__/
11
+ *.pyc
12
+ .env
backend/app.py CHANGED
@@ -37,6 +37,9 @@ app = FastAPI()
37
 
38
  MAX_FILES = 5
39
 
 
 
 
40
 
41
  @app.post("/detect_perspective")
42
  async def detect_perspective_route(
 
37
 
38
  MAX_FILES = 5
39
 
40
+ @app.get("/")
41
+ async def root():
42
+ return {"status": "running"}
43
 
44
  @app.post("/detect_perspective")
45
  async def detect_perspective_route(
backend/services/ocr_service.py CHANGED
@@ -2,7 +2,7 @@ import pytesseract
2
  from PIL import Image
3
 
4
  # 👇 ADD THIS LINE (VERY IMPORTANT FOR WINDOWS)
5
- pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe"
6
 
7
 
8
  def extract_text_from_images(image_paths):
 
2
  from PIL import Image
3
 
4
  # 👇 ADD THIS LINE (VERY IMPORTANT FOR WINDOWS)
5
+ # pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe"
6
 
7
 
8
  def extract_text_from_images(image_paths):
fine_tune_prompts.py ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ ANALYST_FILE = "backend/agents/analyst.py"
4
+ PSYCHOLOGY_FILE = "backend/agents/psychology.py"
5
+ STRATEGY_FILE = "backend/agents/strategy.py"
6
+
7
+ ANALYST_NEW = '''from backend.llm.factory import get_llm
8
+ from backend.utils import safe_invoke
9
+
10
+ ANALYST_PROMPT = """
11
+ You are Velra, an elite relationship profiler. You must distinguish between "Playful Tension" and "Hostile Dismissiveness".
12
+
13
+ ## DIFFERENTIATION GUIDE:
14
+ - **PLAYFUL TENSION (Green Flag):** Teasing, "Maybe I like you", "That's suspicious", "Too much talking". This is bonding. (SCORE: 70-90)
15
+ - **HOSTILE DISMISSIVENESS (Red Flag):** "Okay and?", "I was busy (after 3 days)", "You're overreacting", "Nevermind". This is distancing. (SCORE: 10-30)
16
+
17
+ ## CRITICAL RULES
18
+ - If the chat is warm and reciprocal (even if it's teasing), do NOT call it toxic.
19
+ - If the chat shows one person being rude or ignoring the other, call it out as a Red Flag.
20
+ - Reference specific words (e.g., "Alex's 'maybe I like you' is a direct escalation of intimacy masked as a tease.")
21
+
22
+ ## INPUT CONTEXT
23
+ Chat:
24
+ {chat}
25
+
26
+ User's Feelings:
27
+ {feelings}
28
+
29
+ ## INSTRUCTIONS FOR JSON FIELDS:
30
+ - **interest_level**: If it's mutual flirting, say "High mutual interest".
31
+ - **emotional_tone**: E.g., "Playful/Warm", "Teasing", "Cold/Dismissive", or "Hostile".
32
+ - **effort_level**: Note if it's balanced.
33
+ - **trend**: "Escalating intimacy", "Withdrawal", or "Stagnant".
34
+ - **hidden_meaning**: Decode the subtext accurately.
35
+ - **attachment_signal**: E.g., "Secure/Playful", "Avoidant-Dismissive", "Anxious Protest".
36
+ - **communication_health**: "High (Playful)", "Toxic (Dismissive)", or "Neutral".
37
+ - **summary**: 2 sentences. Be specific to THIS conversation.
38
+
39
+ Return ONLY valid JSON.
40
+ {{
41
+ "interest_level": "",
42
+ "emotional_tone": "",
43
+ "effort_level": "",
44
+ "sarcasm_detected": "",
45
+ "trend": "",
46
+ "hidden_meaning": "",
47
+ "attachment_signal": "",
48
+ "communication_health": "",
49
+ "emotional_risk": "",
50
+ "confidence": "",
51
+ "summary": ""
52
+ }}
53
+ """
54
+
55
+ def analyze_conversation(chat, feelings=""):
56
+ llm = get_llm()
57
+ prompt = ANALYST_PROMPT.format(chat=chat, feelings=feelings)
58
+ return safe_invoke(llm, prompt)
59
+ '''
60
+
61
+ PSYCHOLOGY_NEW = '''from backend.llm.factory import get_llm
62
+ from backend.utils import safe_invoke
63
+
64
+ PSYCHOLOGY_PROMPT = """
65
+ You are Velra, an elite psychological profiler. You must calculate risk and alignment with extreme precision.
66
+
67
+ ## RISK LEVEL LOGIC:
68
+ - **HIGH RISK:** Gaslighting, disrespect ("okay and?"), ignoring texts for days while posting on social media, breadcrumbing.
69
+ - **LOW RISK:** Mutual flirting, playful teasing, consistent replies, "I love you".
70
+ - **MODERATE RISK:** Ambiguity, mixed signals, uncertainty about where it's going.
71
+
72
+ ## COMPATIBILITY SCORE LOGIC (0-100):
73
+ - **80-95:** Mutual interest, "I love you", or high-vibe flirting (like Nina/Alex).
74
+ - **10-30:** Dismissive behavior, one-sided effort, disrespect.
75
+
76
+ ## CONTEXT
77
+ Chat:
78
+ {chat}
79
+
80
+ User's Feelings:
81
+ {feelings}
82
+
83
+ ## INSTRUCTIONS FOR JSON FIELDS:
84
+ - **user_intent**: What the user wants.
85
+ - **partner_intent**: What the partner's behavior REVEALS.
86
+ - **psychological_dynamic**: E.g., "Escalating Romance", "Avoidant Shielding", "Secure Playfulness".
87
+ - **emotional_availability**: Mutual or One-sided?
88
+ - **risk_level**: "High", "Moderate", or "Low". Follow the Risk Level Logic.
89
+ - **compatibility_score**: A number string. Follow the Score Logic.
90
+ - **confidence**: "High", "Medium", "Low".
91
+
92
+ Return ONLY valid JSON.
93
+ {{
94
+ "user_intent": "",
95
+ "partner_intent": "",
96
+ "psychological_dynamic": "",
97
+ "emotional_availability": "",
98
+ "risk_level": "",
99
+ "compatibility_score": "",
100
+ "confidence": ""
101
+ }}
102
+ """
103
+
104
+ def analyze_psychology(chat, feelings):
105
+ llm = get_llm()
106
+ prompt = PSYCHOLOGY_PROMPT.format(chat=chat, feelings=feelings)
107
+ return safe_invoke(llm, prompt)
108
+ '''
109
+
110
+ STRATEGY_NEW = '''from backend.llm.factory import get_llm
111
+ from backend.utils import safe_invoke
112
+
113
+ STRATEGY_PROMPT = """
114
+ You are Velra, the ultimate relationship strategist.
115
+
116
+ ## ACTION BRANCHING:
117
+ 1. **IF POSITIVE/FLIRTY :** Suggest escalating. "Lean into the flirting," "Ask them out." Do NOT suggest "detaching" or "hard boundaries."
118
+ 2. **IF NEGATIVE/DISMISSIVE (like Lucas "okay and?"):** Suggest protecting yourself. "Detach," "Enforce boundaries." Do NOT suggest "warm emojis."
119
+
120
+ ## CONTEXT
121
+ {context}
122
+
123
+ ## INSTRUCTIONS FOR JSON FIELDS:
124
+ - **truth**: The core reality. (e.g., "He is clearly into you and is using teasing to test the waters.")
125
+ - **warning**: E.g., "Don't play it too cool or you'll miss the window of opportunity."
126
+ - **action_advice**: The exact next move.
127
+ - **suggested_replies**: 1-3 texts. Calibrate to the tone.
128
+ - **detachment_path**: "Not recommended for this positive connection" OR a real exit path.
129
+ - **reconnection_path**: Only if needed.
130
+ - **hero_insight**: A profound 1-sentence takeaway.
131
+ - **personalized_advice**: 2 sentences tailored to the user's specific feelings.
132
+
133
+ Return ONLY valid JSON.
134
+ {{
135
+ "truth": "",
136
+ "warning": "",
137
+ "action_advice": "",
138
+ "suggested_replies": [],
139
+ "detachment_path": "",
140
+ "reconnection_path": "",
141
+ "hero_insight": "",
142
+ "personalized_advice": ""
143
+ }}
144
+ """
145
+
146
+ def generate_strategy(context):
147
+ llm = get_llm()
148
+ prompt = STRATEGY_PROMPT.format(context=context)
149
+ return safe_invoke(llm, prompt)
150
+ '''
151
+
152
+ with open(ANALYST_FILE, "w", encoding="utf-8") as f:
153
+ f.write(ANALYST_NEW)
154
+
155
+ with open(PSYCHOLOGY_FILE, "w", encoding="utf-8") as f:
156
+ f.write(PSYCHOLOGY_NEW)
157
+
158
+ with open(STRATEGY_FILE, "w", encoding="utf-8") as f:
159
+ f.write(STRATEGY_NEW)
160
+
161
+ print("Prompts fine-tuned for high-discernment between Flirting and Dismissiveness!")
start.sh CHANGED
@@ -1,6 +1,14 @@
1
  #!/bin/bash
2
 
3
- uvicorn backend.app:app --host 0.0.0.0 --port 8000 &
 
 
 
 
 
 
 
 
4
 
5
  streamlit run frontend/app.py \
6
  --server.port 7860 \
 
1
  #!/bin/bash
2
 
3
+ echo "STARTING FASTAPI..."
4
+
5
+ uvicorn backend.app:app \
6
+ --host 0.0.0.0 \
7
+ --port 8000 &
8
+
9
+ sleep 5
10
+
11
+ echo "STARTING STREAMLIT..."
12
 
13
  streamlit run frontend/app.py \
14
  --server.port 7860 \