mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-12 20:15:26 +00:00
feat(docs): use the docs agent key by default
The widget now ships with the docs agent's embed token, so the site works without any environment configuration. NEXT_PUBLIC_DOCSGPT_API_KEY still overrides it for staging. The key is public either way. NEXT_PUBLIC_* is inlined at build time, so it lands in the client bundle whichever way it is supplied, and every documented DocsGPT embed carries its key in the page. Abuse is bounded by the agent's daily request and token limits, enforced by check_usage on the answer and stream routes.
This commit is contained in:
1 parent
3711426c83
commit
2b77d1994e
1 file changed
+12
-4
@@ -13,7 +13,15 @@ const DocsGPTWidget = dynamic(
|
||||
|
||||
const apiHost =
|
||||
process.env.NEXT_PUBLIC_DOCSGPT_API_HOST || 'https://gptcloud.arc53.com';
|
||||
const apiKey = process.env.NEXT_PUBLIC_DOCSGPT_API_KEY;
|
||||
|
||||
// Public embed token for the docs agent, the same way every documented
|
||||
// DocsGPT embed carries one. It reaches the browser either way, since
|
||||
// NEXT_PUBLIC_* is inlined at build time. Abuse is capped by the agent's
|
||||
// daily request and token limits, so rotate the agent key if it needs
|
||||
// revoking. NEXT_PUBLIC_DOCSGPT_API_KEY overrides it for staging.
|
||||
const apiKey =
|
||||
process.env.NEXT_PUBLIC_DOCSGPT_API_KEY ||
|
||||
'0e714713-1bc6-4aae-a595-aa0b3bf317b3';
|
||||
|
||||
export function DocsGPTChatWidget() {
|
||||
const { resolvedTheme } = useTheme();
|
||||
@@ -21,9 +29,9 @@ export function DocsGPTChatWidget() {
|
||||
|
||||
useEffect(() => setMounted(true), []);
|
||||
|
||||
// No key means no widget. Falling through would silently use the demo key
|
||||
// baked into the package default.
|
||||
if (!apiKey || !mounted) return null;
|
||||
// Hold off until next-themes has resolved, so the widget does not flash
|
||||
// the wrong theme on first paint.
|
||||
if (!mounted) return null;
|
||||
|
||||
return (
|
||||
<DocsGPTWidget
|
||||
|
||||
Reference in new issue
Block a user