Spaces:
Sleeping
Sleeping
Commit
·
a759fbd
1
Parent(s):
40f42c0
fix(billing): default to token owner; optional BILL_TO_ORG; fix Tooltip import to avoid React runtime mix; normalize start.sh via ENTRYPOINT
Browse files- Dockerfile +3 -3
- app/api/ask-ai/route.ts +11 -6
- components/editor/ask-ai/index.tsx +1 -2
Dockerfile
CHANGED
|
@@ -11,9 +11,9 @@ RUN npm ci
|
|
| 11 |
# Copy the rest of the application
|
| 12 |
COPY --chown=1000 . .
|
| 13 |
|
| 14 |
-
#
|
| 15 |
USER root
|
| 16 |
-
RUN chmod +x /usr/src/app/start.sh
|
| 17 |
USER 1000
|
| 18 |
|
| 19 |
# Build the app
|
|
@@ -29,4 +29,4 @@ ENV PORT=7860
|
|
| 29 |
ENV NEXT_TELEMETRY_DISABLED=1
|
| 30 |
ENV NODE_ENV=production
|
| 31 |
# Start via script that logs and honors $PORT
|
| 32 |
-
|
|
|
|
| 11 |
# Copy the rest of the application
|
| 12 |
COPY --chown=1000 . .
|
| 13 |
|
| 14 |
+
# Normalize and ensure start script is executable
|
| 15 |
USER root
|
| 16 |
+
RUN sed -i 's/\r$//' /usr/src/app/start.sh && chmod +x /usr/src/app/start.sh
|
| 17 |
USER 1000
|
| 18 |
|
| 19 |
# Build the app
|
|
|
|
| 29 |
ENV NEXT_TELEMETRY_DISABLED=1
|
| 30 |
ENV NODE_ENV=production
|
| 31 |
# Start via script that logs and honors $PORT
|
| 32 |
+
ENTRYPOINT ["/usr/src/app/start.sh"]
|
app/api/ask-ai/route.ts
CHANGED
|
@@ -68,7 +68,10 @@ export async function POST(request: NextRequest) {
|
|
| 68 |
}
|
| 69 |
|
| 70 |
let token = userToken;
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
/**
|
| 74 |
* Handle local usage token, this bypass the need for a user token
|
|
@@ -99,8 +102,9 @@ export async function POST(request: NextRequest) {
|
|
| 99 |
);
|
| 100 |
}
|
| 101 |
|
| 102 |
-
|
| 103 |
-
|
|
|
|
| 104 |
}
|
| 105 |
|
| 106 |
const DEFAULT_PROVIDER = PROVIDERS.novita;
|
|
@@ -249,7 +253,8 @@ export async function PUT(request: NextRequest) {
|
|
| 249 |
}
|
| 250 |
|
| 251 |
let token = userToken;
|
| 252 |
-
|
|
|
|
| 253 |
|
| 254 |
/**
|
| 255 |
* Handle local usage token, this bypass the need for a user token
|
|
@@ -280,8 +285,8 @@ export async function PUT(request: NextRequest) {
|
|
| 280 |
);
|
| 281 |
}
|
| 282 |
|
| 283 |
-
|
| 284 |
-
|
| 285 |
}
|
| 286 |
|
| 287 |
const client = new InferenceClient(token);
|
|
|
|
| 68 |
}
|
| 69 |
|
| 70 |
let token = userToken;
|
| 71 |
+
// Optional: allow billing to a specific org if the token has permissions.
|
| 72 |
+
// If not set, we bill to the token owner (recommended for demo tokens).
|
| 73 |
+
const BILL_TO_ORG = process.env.BILL_TO_ORG;
|
| 74 |
+
let billTo: string | null = BILL_TO_ORG ?? null;
|
| 75 |
|
| 76 |
/**
|
| 77 |
* Handle local usage token, this bypass the need for a user token
|
|
|
|
| 102 |
);
|
| 103 |
}
|
| 104 |
|
| 105 |
+
token = process.env.DEFAULT_HF_TOKEN as string;
|
| 106 |
+
// Do NOT force billTo to an org unless configured; this avoids permission errors.
|
| 107 |
+
// billTo remains BILL_TO_ORG or null.
|
| 108 |
}
|
| 109 |
|
| 110 |
const DEFAULT_PROVIDER = PROVIDERS.novita;
|
|
|
|
| 253 |
}
|
| 254 |
|
| 255 |
let token = userToken;
|
| 256 |
+
const BILL_TO_ORG = process.env.BILL_TO_ORG;
|
| 257 |
+
let billTo: string | null = BILL_TO_ORG ?? null;
|
| 258 |
|
| 259 |
/**
|
| 260 |
* Handle local usage token, this bypass the need for a user token
|
|
|
|
| 285 |
);
|
| 286 |
}
|
| 287 |
|
| 288 |
+
token = process.env.DEFAULT_HF_TOKEN as string;
|
| 289 |
+
// Do NOT force billTo; keep optional BILL_TO_ORG or null.
|
| 290 |
}
|
| 291 |
|
| 292 |
const client = new InferenceClient(token);
|
components/editor/ask-ai/index.tsx
CHANGED
|
@@ -17,8 +17,7 @@ import { LoginModal } from "@/components/login-modal";
|
|
| 17 |
import { ReImagine } from "@/components/editor/ask-ai/re-imagine";
|
| 18 |
import Loading from "@/components/loading";
|
| 19 |
import { Checkbox } from "@/components/ui/checkbox";
|
| 20 |
-
import { Tooltip, TooltipTrigger } from "@/components/ui/tooltip";
|
| 21 |
-
import { TooltipContent } from "@radix-ui/react-tooltip";
|
| 22 |
import { SelectedHtmlElement } from "./selected-html-element";
|
| 23 |
import { FollowUpTooltip } from "./follow-up-tooltip";
|
| 24 |
import { isTheSameHtml } from "@/lib/compare-html-diff";
|
|
|
|
| 17 |
import { ReImagine } from "@/components/editor/ask-ai/re-imagine";
|
| 18 |
import Loading from "@/components/loading";
|
| 19 |
import { Checkbox } from "@/components/ui/checkbox";
|
| 20 |
+
import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip";
|
|
|
|
| 21 |
import { SelectedHtmlElement } from "./selected-html-element";
|
| 22 |
import { FollowUpTooltip } from "./follow-up-tooltip";
|
| 23 |
import { isTheSameHtml } from "@/lib/compare-html-diff";
|