Spaces:
Running
Running
Use existing HF token for private agent requests
Browse files- .env.example +1 -3
- src/agent-session.ts +1 -1
- src/config.ts +1 -1
- src/server.ts +1 -1
.env.example
CHANGED
|
@@ -7,8 +7,6 @@ ANALYSIS_PROXY_SECRET=replace-with-a-random-secret-of-at-least-32-characters
|
|
| 7 |
# Deploy the stateless Agent service separately and use its private URL/key here.
|
| 8 |
AGENT_API_URL=https://shoraky-sporalize-agent.hf.space
|
| 9 |
AGENT_API_KEY=replace-with-the-Agent-service-secret
|
| 10 |
-
# Read-scoped Hugging Face token for the private Agent Space.
|
| 11 |
-
AGENT_HF_TOKEN=hf_read_token_for_the_private_Agent_Space
|
| 12 |
# Optional: use the same random secret in the Colab notebook to register its worker.
|
| 13 |
# COLAB_WORKER_SECRET=replace-with-a-different-random-secret-of-at-least-32-characters
|
| 14 |
SUPABASE_URL=https://your-project.supabase.co
|
|
@@ -16,7 +14,7 @@ SUPABASE_ANON_KEY=your-publishable-or-anon-key
|
|
| 16 |
SUPABASE_SERVICE_ROLE_KEY=your-service-role-or-secret-key
|
| 17 |
CORE_REPO_ID=your-account/sporalize-core
|
| 18 |
STORAGE_REPO_ID=your-account/sporalize-application-storage
|
| 19 |
-
HF_TOKEN=
|
| 20 |
# Per-video upload ceiling; raise only if the Space has enough disk and memory.
|
| 21 |
MAX_VIDEO_SIZE_MB=2048
|
| 22 |
# CORE_REVISION=optional-pinned-revision
|
|
|
|
| 7 |
# Deploy the stateless Agent service separately and use its private URL/key here.
|
| 8 |
AGENT_API_URL=https://shoraky-sporalize-agent.hf.space
|
| 9 |
AGENT_API_KEY=replace-with-the-Agent-service-secret
|
|
|
|
|
|
|
| 10 |
# Optional: use the same random secret in the Colab notebook to register its worker.
|
| 11 |
# COLAB_WORKER_SECRET=replace-with-a-different-random-secret-of-at-least-32-characters
|
| 12 |
SUPABASE_URL=https://your-project.supabase.co
|
|
|
|
| 14 |
SUPABASE_SERVICE_ROLE_KEY=your-service-role-or-secret-key
|
| 15 |
CORE_REPO_ID=your-account/sporalize-core
|
| 16 |
STORAGE_REPO_ID=your-account/sporalize-application-storage
|
| 17 |
+
HF_TOKEN=hf_token_with_access_to_private_spaces_and_storage_repositories
|
| 18 |
# Per-video upload ceiling; raise only if the Space has enough disk and memory.
|
| 19 |
MAX_VIDEO_SIZE_MB=2048
|
| 20 |
# CORE_REVISION=optional-pinned-revision
|
src/agent-session.ts
CHANGED
|
@@ -78,7 +78,7 @@ export async function generateSessionFeedback(db: SupabaseClient, sessionId: str
|
|
| 78 |
"x-api-key": env.AGENT_API_KEY,
|
| 79 |
"x-user-id": userId,
|
| 80 |
};
|
| 81 |
-
if (env.
|
| 82 |
const response = await fetch(new URL("/api/session/generate", env.AGENT_API_URL), {
|
| 83 |
method: "POST",
|
| 84 |
headers: agentHeaders,
|
|
|
|
| 78 |
"x-api-key": env.AGENT_API_KEY,
|
| 79 |
"x-user-id": userId,
|
| 80 |
};
|
| 81 |
+
if (env.HF_TOKEN) agentHeaders.authorization = `Bearer ${env.HF_TOKEN}`;
|
| 82 |
const response = await fetch(new URL("/api/session/generate", env.AGENT_API_URL), {
|
| 83 |
method: "POST",
|
| 84 |
headers: agentHeaders,
|
src/config.ts
CHANGED
|
@@ -10,7 +10,7 @@ const envSchema = z.object({
|
|
| 10 |
ANALYSIS_API_URL: z.string().url().default("http://127.0.0.1:8000"),
|
| 11 |
AGENT_API_URL: z.string().url().optional(),
|
| 12 |
AGENT_API_KEY: z.string().min(16).optional(),
|
| 13 |
-
|
| 14 |
ANALYSIS_PROXY_SECRET: z.string().min(32),
|
| 15 |
COLAB_WORKER_SECRET: z.string().optional(),
|
| 16 |
SUPABASE_URL: z.string().url(),
|
|
|
|
| 10 |
ANALYSIS_API_URL: z.string().url().default("http://127.0.0.1:8000"),
|
| 11 |
AGENT_API_URL: z.string().url().optional(),
|
| 12 |
AGENT_API_KEY: z.string().min(16).optional(),
|
| 13 |
+
HF_TOKEN: z.string().optional(),
|
| 14 |
ANALYSIS_PROXY_SECRET: z.string().min(32),
|
| 15 |
COLAB_WORKER_SECRET: z.string().optional(),
|
| 16 |
SUPABASE_URL: z.string().url(),
|
src/server.ts
CHANGED
|
@@ -791,7 +791,7 @@ app.post("/api/agent/chat", async (req, res, next) => {
|
|
| 791 |
context.player = player;
|
| 792 |
}
|
| 793 |
const agentHeaders: Record<string, string> = { "content-type": "application/json", "x-api-key": env.AGENT_API_KEY, "x-user-id": current.user.id };
|
| 794 |
-
if (env.
|
| 795 |
const upstream = await fetch(new URL("/api/chat", env.AGENT_API_URL), {
|
| 796 |
method: "POST", headers: agentHeaders,
|
| 797 |
body: JSON.stringify({ actions: [], context, message: input.message, history: input.history }),
|
|
|
|
| 791 |
context.player = player;
|
| 792 |
}
|
| 793 |
const agentHeaders: Record<string, string> = { "content-type": "application/json", "x-api-key": env.AGENT_API_KEY, "x-user-id": current.user.id };
|
| 794 |
+
if (env.HF_TOKEN) agentHeaders.authorization = `Bearer ${env.HF_TOKEN}`;
|
| 795 |
const upstream = await fetch(new URL("/api/chat", env.AGENT_API_URL), {
|
| 796 |
method: "POST", headers: agentHeaders,
|
| 797 |
body: JSON.stringify({ actions: [], context, message: input.message, history: input.history }),
|