Elffuss BraidHub

kikocis/continue public

3ff29c567dd0 · 1.0 KiBRawPermalink
1import { Continue, ContinueClient } from "@continuedev/sdk";
2import chalk from "chalk";
3
4import { env } from "./env.js";
5
6/**
7 * Initialize the Continue SDK with the given parameters
8 * @param apiKey - API key to use for authentication
9 * @param assistantSlug - Slug of the assistant to use
10 * @param organizationId - Optional organization ID
11 * @returns Promise resolving to the Continue SDK instance
12 */
13export async function initializeContinueSDK(
14 apiKey: string | undefined,
15 assistantSlug: string,
16 organizationId?: string,
17): Promise<ContinueClient> {
18 if (!apiKey) {
19 console.error(chalk.red("Error: No API key provided for Continue SDK"));
20 throw new Error("No API key provided for Continue SDK");
21 }
22
23 try {
24 return await Continue.from({
25 apiKey,
26 assistant: assistantSlug,
27 organizationId,
28 baseURL: env.apiBase,
29 });
30 } catch (error) {
31 console.error(
32 chalk.red("Error initializing Continue SDK:"),
33 error instanceof Error ? error.message : String(error),
34 );
35 throw error;
36 }
37}