Spaces:
Paused
Paused
Upload folder using huggingface_hub
Browse files- components/SimulationPage.tsx +2 -2
- services/gradioService.ts +4 -1
- vite.config.ts +2 -1
components/SimulationPage.tsx
CHANGED
|
@@ -452,11 +452,11 @@ const SimulationPage: React.FC<SimulationPageProps> = ({
|
|
| 452 |
setIsBuilding(true);
|
| 453 |
try {
|
| 454 |
// 1. Generate personas based on profile and company info
|
| 455 |
-
const personas = await GradioService.generatePersonas(formData.companyInfo, formData.customerProfile,
|
| 456 |
|
| 457 |
// 2. Generate social network for these personas
|
| 458 |
const groupName = formData.customerProfile.substring(0, 20);
|
| 459 |
-
await GradioService.generateSocialNetwork(groupName,
|
| 460 |
|
| 461 |
// 3. Save to backend
|
| 462 |
await fetch('/api/save-data', {
|
|
|
|
| 452 |
setIsBuilding(true);
|
| 453 |
try {
|
| 454 |
// 1. Generate personas based on profile and company info
|
| 455 |
+
const personas = await GradioService.generatePersonas(formData.companyInfo, formData.customerProfile, Math.ceil(formData.personaScale / 20));
|
| 456 |
|
| 457 |
// 2. Generate social network for these personas
|
| 458 |
const groupName = formData.customerProfile.substring(0, 20);
|
| 459 |
+
await GradioService.generateSocialNetwork(groupName, formData.personaScale, 'scale_free', groupName);
|
| 460 |
|
| 461 |
// 3. Save to backend
|
| 462 |
await fetch('/api/save-data', {
|
services/gradioService.ts
CHANGED
|
@@ -7,7 +7,10 @@ export class GradioService {
|
|
| 7 |
|
| 8 |
static async getClient() {
|
| 9 |
if (!this.client) {
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
| 11 |
}
|
| 12 |
return this.client;
|
| 13 |
}
|
|
|
|
| 7 |
|
| 8 |
static async getClient() {
|
| 9 |
if (!this.client) {
|
| 10 |
+
// Use HF Token from environment if available (set via vite define or process.env)
|
| 11 |
+
// For browser, we check if it was injected during build
|
| 12 |
+
const token = (import.meta as any).env?.VITE_HF_TOKEN || null;
|
| 13 |
+
this.client = await Client.connect(HF_SPACE, token ? { hf_token: token } : {});
|
| 14 |
}
|
| 15 |
return this.client;
|
| 16 |
}
|
vite.config.ts
CHANGED
|
@@ -22,7 +22,8 @@ export default defineConfig(({ mode }) => {
|
|
| 22 |
],
|
| 23 |
define: {
|
| 24 |
'process.env.API_KEY': JSON.stringify(env.GEMINI_API_KEY),
|
| 25 |
-
'process.env.GEMINI_API_KEY': JSON.stringify(env.GEMINI_API_KEY)
|
|
|
|
| 26 |
},
|
| 27 |
resolve: {
|
| 28 |
alias: {
|
|
|
|
| 22 |
],
|
| 23 |
define: {
|
| 24 |
'process.env.API_KEY': JSON.stringify(env.GEMINI_API_KEY),
|
| 25 |
+
'process.env.GEMINI_API_KEY': JSON.stringify(env.GEMINI_API_KEY),
|
| 26 |
+
'import.meta.env.VITE_HF_TOKEN': JSON.stringify(process.env.HF_TOKEN || '')
|
| 27 |
},
|
| 28 |
resolve: {
|
| 29 |
alias: {
|