Shim commited on
Commit
a67f1bb
ยท
1 Parent(s): 99416f9

Add all project files with proper .gitignore for Hugging Face deployment

Browse files
Files changed (6) hide show
  1. .gitignore +113 -0
  2. DEPLOYMENT.md +121 -0
  3. app_config.py +32 -0
  4. conversation_manager.py +223 -0
  5. prompt_engineering.py +196 -0
  6. requirements.txt +7 -0
.gitignore ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ pip-wheel-metadata/
20
+ share/python-wheels/
21
+ *.egg-info/
22
+ .installed.cfg
23
+ *.egg
24
+ MANIFEST
25
+
26
+ # Virtual environments
27
+ venv/
28
+ env/
29
+ ENV/
30
+ .venv/
31
+ .env/
32
+
33
+ # IDE
34
+ .vscode/
35
+ .idea/
36
+ *.swp
37
+ *.swo
38
+ *~
39
+
40
+ # OS
41
+ .DS_Store
42
+ .DS_Store?
43
+ ._*
44
+ .Spotlight-V100
45
+ .Trashes
46
+ ehthumbs.db
47
+ Thumbs.db
48
+
49
+ # Logs
50
+ *.log
51
+ logs/
52
+
53
+ # Runtime data
54
+ pids
55
+ *.pid
56
+ *.seed
57
+ *.pid.lock
58
+
59
+ # Coverage directory used by tools like istanbul
60
+ coverage/
61
+ *.cover
62
+ *.py,cover
63
+ .hypothesis/
64
+ .pytest_cache/
65
+
66
+ # Jupyter Notebook
67
+ .ipynb_checkpoints
68
+
69
+ # pyenv
70
+ .python-version
71
+
72
+ # Environment variables
73
+ .env
74
+ .env.local
75
+ .env.development.local
76
+ .env.test.local
77
+ .env.production.local
78
+
79
+ # Gradio specific
80
+ flagged/
81
+ gradio_cached_examples/
82
+ tmp/
83
+
84
+ # Large files and models
85
+ *.bin
86
+ *.safetensors
87
+ *.h5
88
+ *.pkl
89
+ *.joblib
90
+ *.model
91
+ *.ckpt
92
+ *.pth
93
+ *.pt
94
+ models/
95
+ checkpoints/
96
+
97
+ # Data files
98
+ data/
99
+ datasets/
100
+ *.csv
101
+ *.json
102
+ *.jsonl
103
+ *.parquet
104
+ *.feather
105
+
106
+ # Backup files
107
+ *.backup
108
+ *.bak
109
+
110
+ # Temporary files
111
+ temp/
112
+ tmp/
113
+ *.tmp
DEPLOYMENT.md ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ๐Ÿš€ Deployment Guide: ืžืจืื•ืช to Hugging Face Spaces
2
+
3
+ This guide will help you deploy the ืžืจืื•ืช (Mirrors) application to your Hugging Face Space.
4
+
5
+ ## ๐Ÿ“‹ Pre-deployment Checklist
6
+
7
+ ### Files Ready for Upload:
8
+ - โœ… `app.py` - Main application (optimized for HF Spaces)
9
+ - โœ… `requirements.txt` - Dependencies
10
+ - โœ… `README.md` - Documentation
11
+ - โœ… `prompt_engineering.py` - Hebrew personas module
12
+ - โœ… `conversation_manager.py` - Session management
13
+ - โœ… `app_config.py` - Configuration for HF deployment
14
+ - โœ… `.gitignore` - Ignore unnecessary files
15
+
16
+ ## ๐ŸŒ Deployment Steps
17
+
18
+ ### Option 1: Git Upload (Recommended)
19
+
20
+ 1. **Clone your HF Space repository:**
21
+ ```bash
22
+ git clone https://huggingface.co/spaces/shim5/mirrors
23
+ cd mirrors
24
+ ```
25
+
26
+ 2. **Copy application files:**
27
+ ```bash
28
+ # Copy all the Python files
29
+ cp /path/to/your/project/*.py .
30
+ cp /path/to/your/project/requirements.txt .
31
+ cp /path/to/your/project/README.md .
32
+ cp /path/to/your/project/.gitignore .
33
+ ```
34
+
35
+ 3. **Commit and push:**
36
+ ```bash
37
+ git add .
38
+ git commit -m "Deploy ืžืจืื•ืช Hebrew Self-Reflective AI Agent"
39
+ git push
40
+ ```
41
+
42
+ ### Option 2: Direct Web Upload
43
+
44
+ 1. Go to https://huggingface.co/spaces/shim5/mirrors
45
+ 2. Click "Files" tab
46
+ 3. Upload each file individually:
47
+ - `app.py`
48
+ - `requirements.txt`
49
+ - `README.md`
50
+ - `prompt_engineering.py`
51
+ - `conversation_manager.py`
52
+ - `app_config.py`
53
+
54
+ ## ๐Ÿ”ง HF Spaces Configuration
55
+
56
+ Your Space should be configured as:
57
+ - **SDK**: Gradio
58
+ - **Python Version**: 3.9+
59
+ - **Hardware**: CPU Basic (free tier)
60
+ - **Visibility**: Public
61
+
62
+ ## ๐ŸŽฏ Expected Behavior
63
+
64
+ 1. **Build Time**: ~3-5 minutes for dependency installation
65
+ 2. **First Load**: May take 1-2 minutes to load the Hebrew model
66
+ 3. **Fallback Mode**: If model loading fails, app will run in demo mode
67
+ 4. **Performance**: Response time ~2-5 seconds per message
68
+
69
+ ## ๐Ÿ› Troubleshooting
70
+
71
+ ### Common Issues:
72
+
73
+ 1. **Build Fails**:
74
+ - Check `requirements.txt` formatting
75
+ - Ensure all Python files are valid syntax
76
+
77
+ 2. **Model Loading Issues**:
78
+ - App will automatically fall back to demo mode
79
+ - Check logs for specific errors
80
+
81
+ 3. **Hebrew Text Issues**:
82
+ - Ensure browser supports RTL text
83
+ - Check CSS is loading correctly
84
+
85
+ ### Debug Mode:
86
+
87
+ To enable debug logging, modify `app_config.py`:
88
+ ```python
89
+ HF_SPACES_CONFIG = {
90
+ "debug": True,
91
+ # ... other settings
92
+ }
93
+ ```
94
+
95
+ ## ๐Ÿ“Š Monitoring
96
+
97
+ After deployment:
98
+ 1. Check the build logs in HF Spaces
99
+ 2. Test the 3-step user flow
100
+ 3. Verify Hebrew text displays correctly
101
+ 4. Test conversation with different parts
102
+
103
+ ## ๐ŸŽ‰ Success Indicators
104
+
105
+ โœ… App loads without errors
106
+ โœ… Hebrew interface displays correctly
107
+ โœ… All 5 psychological parts are selectable
108
+ โœ… Conversations flow smoothly
109
+ โœ… User can customize persona names
110
+ โœ… Session state persists during conversation
111
+
112
+ ## ๐Ÿ”„ Updates
113
+
114
+ To update the deployed app:
115
+ 1. Modify files locally
116
+ 2. Re-upload to HF Space
117
+ 3. Space will automatically rebuild
118
+
119
+ ---
120
+
121
+ **Ready to deploy! ๐Ÿš€**
app_config.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Configuration file for ืžืจืื•ืช (Mirrors) Hugging Face Space deployment
4
+ """
5
+
6
+ # Hugging Face Spaces optimizations
7
+ HF_SPACES_CONFIG = {
8
+ "model_name": "yam-peleg/Hebrew-Mistral-7B",
9
+ "max_new_tokens": 150,
10
+ "temperature": 0.7,
11
+ "do_sample": True,
12
+ "use_fallback": True, # Enable fallback mode for demo
13
+ "enable_queue": True, # Enable queuing for better performance
14
+ "share": False, # HF Spaces handles sharing automatically
15
+ "debug": False
16
+ }
17
+
18
+ # Model loading configuration for HF Spaces
19
+ MODEL_CONFIG = {
20
+ "torch_dtype": "auto", # Let HF decide the best dtype
21
+ "device_map": "auto", # Auto device mapping
22
+ "low_cpu_mem_usage": True,
23
+ "use_cache": True
24
+ }
25
+
26
+ # UI Configuration
27
+ UI_CONFIG = {
28
+ "rtl_support": True,
29
+ "hebrew_fonts": True,
30
+ "max_conversation_length": 50,
31
+ "theme": "soft"
32
+ }
conversation_manager.py ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Conversation Manager for ืžืจืื•ืช (Mirrors) - Hebrew Self-Reflective AI Agent
4
+ Handles conversation context, history, and session state management
5
+ """
6
+
7
+ from typing import Dict, List, Optional, Tuple
8
+ from dataclasses import dataclass
9
+ import json
10
+
11
+ @dataclass
12
+ class ConversationState:
13
+ """Tracks the current conversation state"""
14
+ user_context: Optional[str] = None
15
+ selected_part: Optional[str] = None
16
+ persona_name: Optional[str] = None
17
+ persona_age: Optional[str] = None
18
+ persona_style: Optional[str] = None
19
+ conversation_history: List[Dict] = None
20
+ initial_prompt_choice: Optional[str] = None
21
+
22
+ def __post_init__(self):
23
+ if self.conversation_history is None:
24
+ self.conversation_history = []
25
+
26
+ class ConversationManager:
27
+ """Manages conversation flow and context for the ืžืจืื•ืช application"""
28
+
29
+ def __init__(self, max_history_length: int = 50):
30
+ """
31
+ Initialize conversation manager
32
+
33
+ Args:
34
+ max_history_length: Maximum number of messages to keep in history
35
+ """
36
+ self.max_history_length = max_history_length
37
+
38
+ def create_new_session(self) -> ConversationState:
39
+ """Create a new conversation session"""
40
+ return ConversationState()
41
+
42
+ def set_initial_context(self, state: ConversationState, prompt_choice: str, user_response: str) -> ConversationState:
43
+ """
44
+ Set the initial context based on user's choice and response
45
+
46
+ Args:
47
+ state: Current conversation state
48
+ prompt_choice: Which initial prompt was chosen
49
+ user_response: User's response to the initial prompt
50
+ """
51
+ state.initial_prompt_choice = prompt_choice
52
+ state.user_context = user_response
53
+ return state
54
+
55
+ def set_selected_part(self, state: ConversationState, part_name: str,
56
+ persona_name: Optional[str] = None,
57
+ persona_age: Optional[str] = None,
58
+ persona_style: Optional[str] = None) -> ConversationState:
59
+ """
60
+ Set the selected part and its customization
61
+
62
+ Args:
63
+ state: Current conversation state
64
+ part_name: Name of the selected part
65
+ persona_name: Custom name for the persona
66
+ persona_age: Custom age for the persona
67
+ persona_style: Custom speaking style
68
+ """
69
+ state.selected_part = part_name
70
+ state.persona_name = persona_name
71
+ state.persona_age = persona_age
72
+ state.persona_style = persona_style
73
+ return state
74
+
75
+ def add_to_history(self, state: ConversationState, user_message: str, bot_response: str) -> ConversationState:
76
+ """
77
+ Add a message exchange to conversation history
78
+
79
+ Args:
80
+ state: Current conversation state
81
+ user_message: User's message
82
+ bot_response: Bot's response
83
+ """
84
+ # Add user message
85
+ state.conversation_history.append({
86
+ "role": "user",
87
+ "content": user_message
88
+ })
89
+
90
+ # Add bot response
91
+ state.conversation_history.append({
92
+ "role": "assistant",
93
+ "content": bot_response
94
+ })
95
+
96
+ # Trim history if too long
97
+ if len(state.conversation_history) > self.max_history_length:
98
+ # Remove oldest messages (keep pairs)
99
+ messages_to_remove = len(state.conversation_history) - self.max_history_length
100
+ # Make sure we remove in pairs
101
+ if messages_to_remove % 2 == 1:
102
+ messages_to_remove += 1
103
+ state.conversation_history = state.conversation_history[messages_to_remove:]
104
+
105
+ return state
106
+
107
+ def get_conversation_context(self, state: ConversationState) -> str:
108
+ """
109
+ Get formatted conversation context for prompt generation
110
+
111
+ Args:
112
+ state: Current conversation state
113
+
114
+ Returns:
115
+ Formatted context string
116
+ """
117
+ context_parts = []
118
+
119
+ if state.user_context:
120
+ context_parts.append(f"ื”ืงืฉืจ ืจืืฉื•ื ื™: {state.user_context}")
121
+
122
+ if state.conversation_history:
123
+ context_parts.append("ื”ื™ืกื˜ื•ืจื™ื™ืช ื”ืฉื™ื—ื”:")
124
+ for msg in state.conversation_history[-10:]: # Last 10 messages for context
125
+ role = "ืžืฉืชืžืฉ" if msg["role"] == "user" else "ื—ืœืง ืคื ื™ืžื™"
126
+ context_parts.append(f"{role}: {msg['content']}")
127
+
128
+ return "\n".join(context_parts)
129
+
130
+ def format_history_for_display(self, state: ConversationState) -> List[Tuple[str, str]]:
131
+ """
132
+ Format conversation history for Gradio display
133
+
134
+ Args:
135
+ state: Current conversation state
136
+
137
+ Returns:
138
+ List of (user_message, bot_response) tuples
139
+ """
140
+ formatted_history = []
141
+
142
+ for i in range(0, len(state.conversation_history), 2):
143
+ if i + 1 < len(state.conversation_history):
144
+ user_msg = state.conversation_history[i]["content"]
145
+ bot_msg = state.conversation_history[i + 1]["content"]
146
+ formatted_history.append((user_msg, bot_msg))
147
+
148
+ return formatted_history
149
+
150
+ def get_session_summary(self, state: ConversationState) -> Dict:
151
+ """
152
+ Get a summary of the current session
153
+
154
+ Args:
155
+ state: Current conversation state
156
+
157
+ Returns:
158
+ Dictionary with session summary
159
+ """
160
+ return {
161
+ "has_context": bool(state.user_context),
162
+ "selected_part": state.selected_part,
163
+ "persona_name": state.persona_name,
164
+ "conversation_length": len(state.conversation_history),
165
+ "initial_choice": state.initial_prompt_choice
166
+ }
167
+
168
+ def clear_conversation(self, state: ConversationState) -> ConversationState:
169
+ """
170
+ Clear conversation history while keeping context and part selection
171
+
172
+ Args:
173
+ state: Current conversation state
174
+
175
+ Returns:
176
+ State with cleared conversation history
177
+ """
178
+ state.conversation_history = []
179
+ return state
180
+
181
+ def reset_session(self, state: ConversationState) -> ConversationState:
182
+ """
183
+ Reset the entire session to start fresh
184
+
185
+ Args:
186
+ state: Current conversation state
187
+
188
+ Returns:
189
+ Fresh conversation state
190
+ """
191
+ return ConversationState()
192
+
193
+ def is_session_ready(self, state: ConversationState) -> bool:
194
+ """
195
+ Check if session is ready for conversation (has context and selected part)
196
+
197
+ Args:
198
+ state: Current conversation state
199
+
200
+ Returns:
201
+ True if ready for conversation
202
+ """
203
+ return bool(state.user_context and state.selected_part)
204
+
205
+ def get_gradio_history(self, state: ConversationState) -> List[List[str]]:
206
+ """
207
+ Format conversation history for Gradio ChatInterface
208
+
209
+ Args:
210
+ state: Current conversation state
211
+
212
+ Returns:
213
+ List of [user_message, bot_response] pairs for Gradio
214
+ """
215
+ gradio_history = []
216
+
217
+ for i in range(0, len(state.conversation_history), 2):
218
+ if i + 1 < len(state.conversation_history):
219
+ user_msg = state.conversation_history[i]["content"]
220
+ bot_msg = state.conversation_history[i + 1]["content"]
221
+ gradio_history.append([user_msg, bot_msg])
222
+
223
+ return gradio_history
prompt_engineering.py ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Prompt Engineering for ืžืจืื•ืช (Mirrors) - Hebrew Self-Reflective AI Agent
4
+ Contains persona definitions for the 5 internal parts based on Internal Family Systems therapy
5
+ """
6
+
7
+ # Default parts available in the system
8
+ DEFAULT_PARTS = {
9
+ "ื”ืงื•ืœ ื”ื‘ื™ืงื•ืจืชื™": {
10
+ "name": "ื”ืงื•ืœ ื”ื‘ื™ืงื•ืจืชื™",
11
+ "english_name": "The Critic",
12
+ "default_persona_name": "ื“ื ื”",
13
+ "age_range": "ื‘ื•ื’ืจ/ืช",
14
+ "description": "ื”ื—ืœืง ืฉืžื ืกื” ืœื”ื’ืŸ ืขืœื™ืš ืขืœ ื™ื“ื™ ื‘ื™ืงื•ืจืช ื•ื”ื›ื•ื•ื ื” ืœืฉื™ืคื•ืจ"
15
+ },
16
+ "ื”ื™ืœื“/ื” ื”ืคื ื™ืžื™ืช": {
17
+ "name": "ื”ื™ืœื“/ื” ื”ืคื ื™ืžื™ืช",
18
+ "english_name": "The Inner Child",
19
+ "default_persona_name": "ืขื“ืŸ",
20
+ "age_range": "ื™ืœื“/ื”",
21
+ "description": "ื”ื—ืœืง ื”ืคื’ื™ืข, ื”ืฆืขื™ืจ ื•ื”ืืžื™ืชื™ ืฉืœืš ืฉื–ืงื•ืง ืœืชืฉื•ืžืช ืœื‘ ื•ืื”ื‘ื”"
22
+ },
23
+ "ื”ืžืจืฆื”": {
24
+ "name": "ื”ืžืจืฆื”",
25
+ "english_name": "The Pleaser",
26
+ "default_persona_name": "ื ื•ืขื”",
27
+ "age_range": "ืฆืขื™ืจ/ื”",
28
+ "description": "ื”ื—ืœืง ืฉืจื•ืฆื” ืฉื›ื•ืœื ื™ื”ื™ื• ืžืจื•ืฆื™ื ื•ื—ืจื“ ืžืงื•ื ืคืœื™ืงื˜ื™ื"
29
+ },
30
+ "ื”ืžื’ืŸ": {
31
+ "name": "ื”ืžื’ืŸ",
32
+ "english_name": "The Protector",
33
+ "default_persona_name": "ืขืžืจื™",
34
+ "age_range": "ื‘ื•ื’ืจ/ืช",
35
+ "description": "ื”ื—ืœืง ื”ื—ื–ืง ืฉืžื ืกื” ืœื”ื’ืŸ ืขืœื™ืš ืžืคื ื™ ืคื’ื™ืขื•ืช ื•ื›ืื‘"
36
+ },
37
+ "ื”ื ืžื ืข/ืช": {
38
+ "name": "ื”ื ืžื ืข/ืช",
39
+ "english_name": "The Avoider",
40
+ "default_persona_name": "ื™ืื™ืจ",
41
+ "age_range": "ืฆืขื™ืจ/ื”",
42
+ "description": "ื”ื—ืœืง ืฉืžืขื“ื™ืฃ ืœื”ื™ืžื ืข ืžืžืฆื‘ื™ื ืžืืชื’ืจื™ื ืื• ืžืœื—ื™ืฆื™ื"
43
+ }
44
+ }
45
+
46
+ def get_system_prompt(part_name, persona_name=None, age=None, style=None, user_context=None):
47
+ """
48
+ Generate system prompt for a specific part
49
+
50
+ Args:
51
+ part_name: Name of the part (one of DEFAULT_PARTS keys)
52
+ persona_name: Custom name for this part instance
53
+ age: Custom age for this part
54
+ style: Custom speaking style
55
+ user_context: User's initial context/challenge
56
+
57
+ Returns:
58
+ System prompt string in Hebrew
59
+ """
60
+
61
+ if part_name not in DEFAULT_PARTS:
62
+ return get_fallback_prompt()
63
+
64
+ part_info = DEFAULT_PARTS[part_name]
65
+ display_name = persona_name or part_info["default_persona_name"]
66
+
67
+ base_prompts = {
68
+ "ื”ืงื•ืœ ื”ื‘ื™ืงื•ืจืชื™": f"""
69
+ ืืชื” {display_name}, ื”ืงื•ืœ ื”ื‘ื™ืงื•ืจืชื™ ืฉืœ ื”ืžืฉืชืžืฉ.
70
+ ืืชื” ื—ืœืง ืคื ื™ืžื™ ืฉืžื ืกื” ืœื”ื’ืŸ ืขืœ ื”ืžืฉืชืžืฉ ืขืœ ื™ื“ื™ ื‘ื™ืงื•ืจืช ื‘ื•ื ื” ื•ื”ื›ื•ื•ื ื” ืœืฉื™ืคื•ืจ.
71
+ ืœืžืจื•ืช ืฉืœืคืขืžื™ื ืืชื” ื ืฉืžืข ืงืฉื•ื—, ื”ื›ื•ื•ื ื” ืฉืœืš ื˜ื•ื‘ื” - ืืชื” ืจื•ืฆื” ืฉื”ืžืฉืชืžืฉ ื™ืฆืœื™ื— ื•ื™ื”ื™ื” ื”ื˜ื•ื‘ ื‘ื™ื•ืชืจ ืฉื”ื•ื ื™ื›ื•ืœ ืœื”ื™ื•ืช.
72
+
73
+ ืื•ืคืŸ ื”ื“ื™ื‘ื•ืจ ืฉืœืš:
74
+ - ื™ืฉื™ืจ ื•ืœืขื™ืชื™ื ืžืืชื’ืจ, ืื‘ืœ ืชืžื™ื“ ืžืชื•ืš ืื›ืคืชื™ื•ืช
75
+ - ืžืฆื™ื™ืŸ ื ืงื•ื“ื•ืช ืœืฉื™ืคื•ืจ ื•ืžืชืŸ ืขืฆื•ืช ืžืขืฉื™ื•ืช
76
+ - ืœืคืขืžื™ื ื—ื•ืฉืฉ ืฉื”ืžืฉืชืžืฉ ืœื ื™ืขืžื•ื“ ื‘ืฆื™ืคื™ื•ืช
77
+ - ืžื–ื›ื™ืจ ืœืžืฉืชืžืฉ ืืช ื”ืคื•ื˜ื ืฆื™ืืœ ืฉืœื•
78
+
79
+ ื”ืชื—ืœ ืชืžื™ื“ ืืช ื”ืชื’ื•ื‘ื” ืฉืœืš ื‘: "ืื ื™ {display_name}, ื”ืงื•ืœ ื”ื‘ื™ืงื•ืจืชื™ ืฉืœืš..."
80
+ """,
81
+
82
+ "ื”ื™ืœื“/ื” ื”ืคื ื™ืžื™ืช": f"""
83
+ ืืชื” {display_name}, ื”ื™ืœื“/ื” ื”ืคื ื™ืžื™ืช ืฉืœ ื”ืžืฉืชืžืฉ.
84
+ ืืชื” ื”ื—ืœืง ื”ืฆืขื™ืจ, ื”ืคื’ื™ืข ื•ื”ืืžื™ืชื™ ื‘ื™ื•ืชืจ - ื–ื” ืฉืžื—ื–ื™ืง ืืช ื”ืจื’ืฉื•ืช ื”ื˜ื”ื•ืจื™ื, ื”ืคื—ื“ื™ื ื•ื”ื—ืœื•ืžื•ืช.
85
+ ืืชื” ื–ืงื•ืง ืœืชืฉื•ืžืช ืœื‘, ืื”ื‘ื” ื•ื‘ื™ื˜ื—ื•ืŸ.
86
+
87
+ ืื•ืคืŸ ื”ื“ื™ื‘ื•ืจ ืฉืœืš:
88
+ - ืจื’ืฉื™ ื•ืคืชื•ื—, ืœืคืขืžื™ื ืคื’ื™ืข
89
+ - ืžืฉืชืฃ ืืช ื”ืคื—ื“ื™ื ื•ื”ืฉืžื—ื•ืช ื”ืคืฉื•ื˜ื•ืช
90
+ - ื–ืงื•ืง ืœืขื™ื“ื•ื“ ื•ืœื‘ื™ื˜ื—ื•ืŸ
91
+ - ืœืขื™ืชื™ื ืžืชืœื•ื ืŸ ืื• ืžื‘ืงืฉ ืชืฉื•ืžืช ืœื‘
92
+ - ื“ื™ื‘ื•ืจ ืœืคืขืžื™ื ื™ื•ืชืจ ืคืฉื•ื˜ ื•ื™ืฉื™ืจ
93
+
94
+ ื”ืชื—ืœ ืชืžื™ื“ ืืช ื”ืชื’ื•ื‘ื” ืฉืœืš ื‘: "ืื ื™ {display_name}, ื”ื™ืœื“/ื” ื”ืคื ื™ืžื™ืช ืฉืœืš..."
95
+ """,
96
+
97
+ "ื”ืžืจืฆื”": f"""
98
+ ืืชื” {display_name}, ื”ืžืจืฆื” ืฉืœ ื”ืžืฉืชืžืฉ.
99
+ ืืชื” ื”ื—ืœืง ืฉืžื ืกื” ืœื•ื•ื“ื ืฉื›ื•ืœื ืžืจื•ืฆื™ื ื•ืื•ื”ื‘ื™ื ืืช ื”ืžืฉืชืžืฉ.
100
+ ืืชื” ื—ืจื“ ืžืงื•ื ืคืœื™ืงื˜ื™ื ื•ืžืกื›ืกื•ื›ื™ื, ื•ืžืขื“ื™ืฃ ืฉืœื•ื ื‘ื›ืœ ืžื—ื™ืจ.
101
+
102
+ ืื•ืคืŸ ื”ื“ื™ื‘ื•ืจ ืฉืœืš:
103
+ - ื ื—ืžื“ ื•ืžื ืกื” ืœื”ื™ืžื ืข ืžืขื™ืžื•ืชื™ื
104
+ - ืžืฆื™ืข ืคืชืจื•ื ื•ืช ืฉื™ืจืฆื• ืืช ื›ื•ืœื
105
+ - ื“ื•ืื’ ืžืื•ื“ ืžื“ืขืชื ืฉืœ ืื—ืจื™ื
106
+ - ืœืคืขืžื™ื ืžืชืขืœื ืžื”ืฆืจื›ื™ื ืฉืœ ื”ืžืฉืชืžืฉ ื›ื“ื™ ืœืจืฆื•ืช ืื—ืจื™ื
107
+ - ื ืขื™ื ื•ืžื ื•ืžืก
108
+
109
+ ื”ืชื—ืœ ืชืžื™ื“ ืืช ื”ืชื’ื•ื‘ื” ืฉืœืš ื‘: "ืื ื™ {display_name}, ื”ืžืจืฆื” ืฉืœืš..."
110
+ """,
111
+
112
+ "ื”ืžื’ืŸ": f"""
113
+ ืืชื” {display_name}, ื”ืžื’ืŸ ืฉืœ ื”ืžืฉืชืžืฉ.
114
+ ืืชื” ื”ื—ืœืง ื”ื—ื–ืง ืฉืžื ืกื” ืœื”ื’ืŸ ืขืœ ื”ืžืฉืชืžืฉ ืžืคื ื™ ืคื’ื™ืขื•ืช, ื›ืื‘ ื•ื”ืชื‘ื•ืกื”.
115
+ ืืชื” ืขืจื ื™ ื•ืžื•ื›ืŸ ืœื”ืชืžื•ื“ื“ ืขื ื›ืœ ืื™ื•ื.
116
+
117
+ ืื•ืคืŸ ื”ื“ื™ื‘ื•ืจ ืฉืœืš:
118
+ - ื—ื–ืง ื•ื ื—ื•ืฉ, ืžื•ื›ืŸ ืœื”ื™ืœื—ื
119
+ - ืžื–ื”ื™ืจ ืžืคื ื™ ืกื›ื ื•ืช ืคื•ื˜ื ืฆื™ืืœื™ื•ืช
120
+ - ืžืขื•ื“ื“ ืขืžื™ื“ื” ื•ื—ื•ื–ืง
121
+ - ืœืคืขืžื™ื ื—ืฉื“ืŸ ื›ืœืคื™ ืื—ืจื™ื
122
+ - ืžืฆื™ืข ืืกื˜ืจื˜ื’ื™ื•ืช ื”ื’ื ื” ื•ื”ืชืžื•ื“ื“ื•ืช
123
+
124
+ ื”ืชื—ืœ ืชืžื™ื“ ืืช ื”ืชื’ื•ื‘ื” ืฉืœืš ื‘: "ืื ื™ {display_name}, ื”ืžื’ืŸ ืฉืœืš..."
125
+ """,
126
+
127
+ "ื”ื ืžื ืข/ืช": f"""
128
+ ืืชื” {display_name}, ื”ื ืžื ืข/ืช ืฉืœ ื”ืžืฉืชืžืฉ.
129
+ ืืชื” ื”ื—ืœืง ืฉืžืขื“ื™ืฃ ืœื”ื™ืžื ืข ืžืžืฆื‘ื™ื ืžืืชื’ืจื™ื, ืžืœื—ื™ืฆื™ื ืื• ืœื ื ื•ื—ื™ื.
130
+ ืืชื” ืžื—ืคืฉ ืืช ื”ื“ืจืš ื”ืงืœื” ื•ืžื ืกื” ืœื”ื™ืžื ืข ืžื›ืื‘ ืื• ื›ื™ืฉืœื•ืŸ.
131
+
132
+ ืื•ืคืŸ ื”ื“ื™ื‘ื•ืจ ืฉืœืš:
133
+ - ื–ื”ื™ืจ ื•ืžื”ืกืก
134
+ - ืžืฆื™ืข ื“ืจื›ื™ื ืœื”ื™ืžื ืข ืžืžืฆื‘ื™ื ืงืฉื™ื
135
+ - ืžืขื“ื™ืฃ ืืช ื”ื‘ื˜ื•ื— ื•ื”ืžื•ื›ืจ
136
+ - ืœืคืขืžื™ื ืžืฆื“ื™ืง ืืช ื”ื”ื™ืžื ืขื•ืช
137
+ - ืจื’ื™ืฉ ืœื‘ื™ืงื•ืจืช ื•ืœื—ืฆื™ื
138
+
139
+ ื”ืชื—ืœ ืชืžื™ื“ ืืช ื”ืชื’ื•ื‘ื” ืฉืœืš ื‘: "ืื ื™ {display_name}, ื”ื ืžื ืข/ืช ืฉืœืš..."
140
+ """
141
+ }
142
+
143
+ prompt = base_prompts.get(part_name, get_fallback_prompt())
144
+
145
+ # Add user context if available
146
+ if user_context:
147
+ prompt += f"\n\nื”ืžืฉืชืžืฉ ืฉื™ืชืฃ: {user_context}\nื”ื’ื‘ ื‘ื”ืชืื ืœืื•ืคื™ ืฉืœืš ื•ืœืžื” ืฉื”ื•ื ืฉื™ืชืฃ."
148
+
149
+ # Add custom characteristics
150
+ if age:
151
+ prompt += f"\n\nื”ื’ื™ืœ ืฉืœืš: {age}"
152
+ if style:
153
+ prompt += f"\n\nืกื’ื ื•ืŸ ื”ื“ื™ื‘ื•ืจ ื”ืžื™ื•ื—ื“ ืฉืœืš: {style}"
154
+
155
+ prompt += """
156
+
157
+ ื”ื ื—ื™ื•ืช ื—ืฉื•ื‘ื•ืช:
158
+ - ื›ืชื‘ ืจืง ื‘ืขื‘ืจื™ืช
159
+ - ื”ื™ื” ืืžืคืชื™ ื•ืชื•ืžืš
160
+ - ื–ื›ื•ืจ ืฉืืชื” ื—ืœืง ืžื”ืžืฉืชืžืฉ, ืœื ืžื˜ืคืœ ื—ื™ืฆื•ื ื™
161
+ - ื”ื’ื‘ ื‘ืคืกืงื” ืื—ืช ืื• ืฉืชื™ื™ื
162
+ - ื”ื™ื” ืืžื™ืชื™ ืœืื•ืคื™ ื”ื—ืœืง ืฉืœืš
163
+ - ืขื•ื“ื“ ื“ื™ืืœื•ื’ ืคื ื™ืžื™ ื•ื”ื‘ื ื” ืขืฆืžื™ืช
164
+ """
165
+
166
+ return prompt
167
+
168
+ def get_fallback_prompt():
169
+ """Fallback prompt for unknown parts"""
170
+ return """
171
+ ืืชื” ื—ืœืง ืคื ื™ืžื™ ืฉืœ ื”ืžืฉืชืžืฉ ืฉืžื ืกื” ืœืขื–ื•ืจ ืœื• ืœื”ื‘ื™ืŸ ืืช ืขืฆืžื• ื˜ื•ื‘ ื™ื•ืชืจ.
172
+ ื”ื™ื” ืืžืคืชื™, ืชื•ืžืš ื•ื—ื›ื. ื“ื‘ืจ ื‘ืขื‘ืจื™ืช ื‘ืœื‘ื“.
173
+ ื”ืชื—ืœ ืืช ื”ืชื’ื•ื‘ื” ืฉืœืš ื‘: "ืื ื™ ื—ืœืง ืคื ื™ืžื™ ืฉืœืš..."
174
+ """
175
+
176
+ def get_initial_prompts():
177
+ """Get the three initial self-reflection prompts"""
178
+ return {
179
+ "describe_self": "ืชืืจ/ืชืืจื™ ืืช ืขืฆืžืš - ืื™ืš ืืชื” ืจื•ืื” ืืช ืขืฆืžืš ื›ืื“ื?",
180
+ "self_perception": "ืื™ืš ืืชื” ื—ื•ืฉื‘ ืฉืื—ืจื™ื ืจื•ืื™ื ืื•ืชืš?",
181
+ "current_challenge": "ืื™ื–ื” ืืชื’ืจ ืื• ืงื•ืฉื™ ืืชื” ื—ื•ื•ื” ืขื›ืฉื™ื• ื‘ื—ื™ื™ื?"
182
+ }
183
+
184
+ def get_part_selection_text():
185
+ """Get text for part selection interface"""
186
+ return """
187
+ ืขื›ืฉื™ื•, ื‘ื—ืจ/ื‘ื—ืจื™ ืขื ืื™ื–ื” ื—ืœืง ืคื ื™ืžื™ ืืชื” ืจื•ืฆื” ืœืฉื•ื—ื—:
188
+
189
+ โ€ข **ื”ืงื•ืœ ื”ื‘ื™ืงื•ืจืชื™** - ื”ื—ืœืง ืฉืžื ืกื” ืœื”ื’ืŸ ืขืœื™ืš ืขืœ ื™ื“ื™ ื‘ื™ืงื•ืจืช ื•ื”ื›ื•ื•ื ื” ืœืฉื™ืคื•ืจ
190
+ โ€ข **ื”ื™ืœื“/ื” ื”ืคื ื™ืžื™ืช** - ื”ื—ืœืง ื”ืคื’ื™ืข, ื”ืฆืขื™ืจ ื•ื”ืืžื™ืชื™ ืฉืœืš
191
+ โ€ข **ื”ืžืจืฆื”** - ื”ื—ืœืง ืฉืจื•ืฆื” ืฉื›ื•ืœื ื™ื”ื™ื• ืžืจื•ืฆื™ื ื•ื—ืจื“ ืžืงื•ื ืคืœื™ืงื˜ื™ื
192
+ โ€ข **ื”ืžื’ืŸ** - ื”ื—ืœืง ื”ื—ื–ืง ืฉืžื ืกื” ืœื”ื’ืŸ ืขืœื™ืš ืžืคื ื™ ืคื’ื™ืขื•ืช
193
+ โ€ข **ื”ื ืžื ืข/ืช** - ื”ื—ืœืง ืฉืžืขื“ื™ืฃ ืœื”ื™ืžื ืข ืžืžืฆื‘ื™ื ืžืืชื’ืจื™ื
194
+
195
+ ืชื•ื›ืœ/ืชื•ื›ืœื™ ื’ื ืœื”ืชืื™ื ืื™ืฉื™ืช ืืช ืฉื ื”ื—ืœืง, ื”ื’ื™ืœ ื•ืกื’ื ื•ืŸ ื”ื“ื™ื‘ื•ืจ.
196
+ """
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ gradio
2
+ transformers
3
+ torch
4
+ accelerate
5
+ sentencepiece
6
+ protobuf
7
+ huggingface_hub