AUXteam commited on
Commit
1773826
·
verified ·
1 Parent(s): d27a461

Upload folder using huggingface_hub

Browse files
components/ChatPage.tsx CHANGED
@@ -27,16 +27,28 @@ const ChatButton: React.FC<{ label: string; primary?: boolean; icon?: React.Reac
27
  </button>
28
  );
29
 
30
- const CategoryCard: React.FC<{ title: string; options: { label: string; icon: React.ReactNode }[] }> = ({ title, options }) => (
 
 
 
 
 
31
  <div className="flex flex-col gap-3">
32
  <h3 className="text-[10px] font-bold text-gray-500 uppercase tracking-widest mb-2 ml-1">{title}</h3>
33
  <div className="space-y-1">
34
  {options.map((option) => (
35
- <div key={option.label} className="group flex items-center gap-3 p-3 rounded-xl hover:bg-gray-900/80 cursor-pointer border border-transparent hover:border-gray-800 transition-all duration-200">
36
- <div className="text-gray-500 group-hover:text-white transition-colors w-5 flex justify-center">
 
 
 
 
 
 
 
37
  {option.icon}
38
  </div>
39
- <span className="text-sm font-medium text-gray-400 group-hover:text-gray-200">{option.label}</span>
40
  </div>
41
  ))}
42
  </div>
@@ -133,6 +145,7 @@ const ChatPage: React.FC<ChatPageProps> = ({ onBack, simulationResult, setSimula
133
  const [showNotification, setShowNotification] = useState(false);
134
  const [isSimulating, setIsSimulating] = useState(false);
135
  const [simulationId, setSimulationId] = useState<string>('User Group 1');
 
136
 
137
  useEffect(() => {
138
  const fetchSimulations = async () => {
@@ -200,11 +213,25 @@ const ChatPage: React.FC<ChatPageProps> = ({ onBack, simulationResult, setSimula
200
  alert("Please enter some content first.");
201
  return;
202
  }
203
- const result = await GradioService.generateVariants(msg);
204
- if (Array.isArray(result)) {
205
- alert("Crafted variants:\n\n" + result.join("\n\n"));
206
- } else {
207
- alert("Crafted suggestion: " + JSON.stringify(result));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  }
209
  };
210
 
@@ -298,19 +325,19 @@ const ChatPage: React.FC<ChatPageProps> = ({ onBack, simulationResult, setSimula
298
  <div className="grid grid-cols-1 md:grid-cols-3 gap-8 md:gap-12">
299
  {/* Column 1 */}
300
  <div className="space-y-12">
301
- <CategoryCard title="Survey" options={categories['Survey']} />
302
- <CategoryCard title="Marketing Content" options={categories['Marketing Content']} />
303
  </div>
304
 
305
  {/* Column 2 */}
306
  <div className="space-y-12">
307
- <CategoryCard title="Social Media Posts" options={categories['Social Media Posts']} />
308
  </div>
309
 
310
  {/* Column 3 */}
311
  <div className="space-y-12">
312
- <CategoryCard title="Communication" options={categories['Communication']} />
313
- <CategoryCard title="Product" options={categories['Product']} />
314
  </div>
315
  </div>
316
 
 
27
  </button>
28
  );
29
 
30
+ const CategoryCard: React.FC<{
31
+ title: string;
32
+ options: { label: string; icon: React.ReactNode }[];
33
+ selectedVariation: string;
34
+ onSelect: (label: string) => void;
35
+ }> = ({ title, options, selectedVariation, onSelect }) => (
36
  <div className="flex flex-col gap-3">
37
  <h3 className="text-[10px] font-bold text-gray-500 uppercase tracking-widest mb-2 ml-1">{title}</h3>
38
  <div className="space-y-1">
39
  {options.map((option) => (
40
+ <div
41
+ key={option.label}
42
+ onClick={() => onSelect(option.label)}
43
+ className={`group flex items-center gap-3 p-3 rounded-xl cursor-pointer border transition-all duration-200
44
+ ${selectedVariation === option.label
45
+ ? 'bg-teal-900/20 border-teal-500/50 text-white'
46
+ : 'hover:bg-gray-900/80 border-transparent hover:border-gray-800'}`}
47
+ >
48
+ <div className={`${selectedVariation === option.label ? 'text-teal-400' : 'text-gray-500 group-hover:text-white'} transition-colors w-5 flex justify-center`}>
49
  {option.icon}
50
  </div>
51
+ <span className={`text-sm font-medium ${selectedVariation === option.label ? 'text-teal-100' : 'text-gray-400 group-hover:text-gray-200'}`}>{option.label}</span>
52
  </div>
53
  ))}
54
  </div>
 
145
  const [showNotification, setShowNotification] = useState(false);
146
  const [isSimulating, setIsSimulating] = useState(false);
147
  const [simulationId, setSimulationId] = useState<string>('User Group 1');
148
+ const [selectedVariation, setSelectedVariation] = useState<string>('');
149
 
150
  useEffect(() => {
151
  const fetchSimulations = async () => {
 
213
  alert("Please enter some content first.");
214
  return;
215
  }
216
+
217
+ setIsSimulating(true); // Reuse simulating state for loading
218
+ try {
219
+ // Here we could use an OpenAI compatible endpoint if available.
220
+ // For now we use the generateVariants from GradioService which acts as the LLM helper.
221
+ // We pass the selectedVariation to help the prompt.
222
+ const prompt = selectedVariation ? `[Mode: ${selectedVariation}] ${msg}` : msg;
223
+ const result = await GradioService.generateVariants(prompt);
224
+
225
+ if (Array.isArray(result)) {
226
+ alert(`Crafted variants for ${selectedVariation || 'general content'}:\n\n` + result.join("\n\n"));
227
+ } else {
228
+ alert("Crafted suggestion: " + JSON.stringify(result));
229
+ }
230
+ } catch (e) {
231
+ console.error(e);
232
+ alert("Failed to craft content.");
233
+ } finally {
234
+ setIsSimulating(false);
235
  }
236
  };
237
 
 
325
  <div className="grid grid-cols-1 md:grid-cols-3 gap-8 md:gap-12">
326
  {/* Column 1 */}
327
  <div className="space-y-12">
328
+ <CategoryCard title="Survey" options={categories['Survey']} selectedVariation={selectedVariation} onSelect={setSelectedVariation} />
329
+ <CategoryCard title="Marketing Content" options={categories['Marketing Content']} selectedVariation={selectedVariation} onSelect={setSelectedVariation} />
330
  </div>
331
 
332
  {/* Column 2 */}
333
  <div className="space-y-12">
334
+ <CategoryCard title="Social Media Posts" options={categories['Social Media Posts']} selectedVariation={selectedVariation} onSelect={setSelectedVariation} />
335
  </div>
336
 
337
  {/* Column 3 */}
338
  <div className="space-y-12">
339
+ <CategoryCard title="Communication" options={categories['Communication']} selectedVariation={selectedVariation} onSelect={setSelectedVariation} />
340
+ <CategoryCard title="Product" options={categories['Product']} selectedVariation={selectedVariation} onSelect={setSelectedVariation} />
341
  </div>
342
  </div>
343
 
components/SimulationPage.tsx CHANGED
@@ -47,6 +47,7 @@ const SimulationPage: React.FC<SimulationPageProps> = ({
47
  onBack, onOpenConversation, onOpenChat, user, onLogin, simulationResult, setSimulationResult
48
  }) => {
49
  const [society, setSociety] = useState('User Group 1');
 
50
  const [viewMode, setViewMode] = useState('Job Title');
51
  const [isRefreshing, setIsRefreshing] = useState(false);
52
  const [isBuilding, setIsBuilding] = useState(false);
@@ -62,6 +63,24 @@ const SimulationPage: React.FC<SimulationPageProps> = ({
62
  }
63
  };
64
  window.addEventListener('resize', handleResize);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  return () => window.removeEventListener('resize', handleResize);
66
  }, []);
67
 
@@ -100,16 +119,16 @@ const SimulationPage: React.FC<SimulationPageProps> = ({
100
  {/* Scrollable Content */}
101
  <div className="flex-1 overflow-y-auto p-4 space-y-6">
102
 
103
- {/* Current Focus Group Control */}
104
  <div className="space-y-2">
105
- <label className="text-xs text-gray-500 font-medium uppercase tracking-wider">Current Focus Group</label>
106
  <div className="relative group">
107
  <select
108
  value={society}
109
  onChange={(e) => handleSettingChange(setSociety, e.target.value)}
110
  className="w-full appearance-none bg-[#111] border border-gray-700 text-white rounded-lg px-3 py-2.5 text-sm focus:outline-none focus:border-teal-500 cursor-pointer"
111
  >
112
- <option>User Group 1</option>
113
  </select>
114
  <ChevronDown className="absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 pointer-events-none w-4 h-4" />
115
  </div>
 
47
  onBack, onOpenConversation, onOpenChat, user, onLogin, simulationResult, setSimulationResult
48
  }) => {
49
  const [society, setSociety] = useState('User Group 1');
50
+ const [societies, setSocieties] = useState<string[]>(['User Group 1']);
51
  const [viewMode, setViewMode] = useState('Job Title');
52
  const [isRefreshing, setIsRefreshing] = useState(false);
53
  const [isBuilding, setIsBuilding] = useState(false);
 
63
  }
64
  };
65
  window.addEventListener('resize', handleResize);
66
+
67
+ // Fetch real focus groups
68
+ const fetchSocieties = async () => {
69
+ try {
70
+ const list = await GradioService.listSimulations();
71
+ if (list && list.length > 0) {
72
+ const names = list.map((s: any) => typeof s === 'string' ? s : (s.id || s.name));
73
+ setSocieties(names);
74
+ if (!names.includes(society)) {
75
+ setSociety(names[0]);
76
+ }
77
+ }
78
+ } catch (e) {
79
+ console.error("Failed to fetch focus groups", e);
80
+ }
81
+ };
82
+ fetchSocieties();
83
+
84
  return () => window.removeEventListener('resize', handleResize);
85
  }, []);
86
 
 
119
  {/* Scrollable Content */}
120
  <div className="flex-1 overflow-y-auto p-4 space-y-6">
121
 
122
+ {/* Focus Group Control */}
123
  <div className="space-y-2">
124
+ <label className="text-xs text-gray-500 font-medium uppercase tracking-wider">Focus Group</label>
125
  <div className="relative group">
126
  <select
127
  value={society}
128
  onChange={(e) => handleSettingChange(setSociety, e.target.value)}
129
  className="w-full appearance-none bg-[#111] border border-gray-700 text-white rounded-lg px-3 py-2.5 text-sm focus:outline-none focus:border-teal-500 cursor-pointer"
130
  >
131
+ {societies.map(s => <option key={s} value={s}>{s}</option>)}
132
  </select>
133
  <ChevronDown className="absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 pointer-events-none w-4 h-4" />
134
  </div>
verify_final.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from playwright.sync_api import sync_playwright
2
+ import os
3
+
4
+ def run():
5
+ with sync_playwright() as p:
6
+ browser = p.chromium.launch(headless=True)
7
+ page = browser.new_page()
8
+
9
+ print("Navigating to local dev server...")
10
+ page.goto("http://localhost:3001")
11
+
12
+ # Wait for app
13
+ page.wait_for_selector('text=Branding Content Testing', timeout=30000)
14
+
15
+ # Take screenshot
16
+ os.makedirs("/home/jules/verification", exist_ok=True)
17
+ page.screenshot(path="/home/jules/verification/final_ui.png", full_page=True)
18
+ print("Screenshot saved.")
19
+
20
+ browser.close()
21
+
22
+ if __name__ == "__main__":
23
+ run()