Spaces:
Running
Running
feature(cohere): add clientName param to cohere endpoint
Browse files
src/lib/server/endpoints/cohere/endpointCohere.ts
CHANGED
@@ -13,19 +13,21 @@ export const endpointCohereParametersSchema = z.object({
|
|
13 |
model: z.any(),
|
14 |
type: z.literal("cohere"),
|
15 |
apiKey: z.string().default(env.COHERE_API_TOKEN),
|
|
|
16 |
raw: z.boolean().default(false),
|
17 |
});
|
18 |
|
19 |
export async function endpointCohere(
|
20 |
input: z.input<typeof endpointCohereParametersSchema>
|
21 |
): Promise<Endpoint> {
|
22 |
-
const { apiKey, model, raw } = endpointCohereParametersSchema.parse(input);
|
23 |
|
24 |
let cohere: CohereClient;
|
25 |
|
26 |
try {
|
27 |
cohere = new (await import("cohere-ai")).CohereClient({
|
28 |
token: apiKey,
|
|
|
29 |
});
|
30 |
} catch (e) {
|
31 |
throw new Error("Failed to import cohere-ai", { cause: e });
|
|
|
13 |
model: z.any(),
|
14 |
type: z.literal("cohere"),
|
15 |
apiKey: z.string().default(env.COHERE_API_TOKEN),
|
16 |
+
clientName: z.string().optional(),
|
17 |
raw: z.boolean().default(false),
|
18 |
});
|
19 |
|
20 |
export async function endpointCohere(
|
21 |
input: z.input<typeof endpointCohereParametersSchema>
|
22 |
): Promise<Endpoint> {
|
23 |
+
const { apiKey, clientName, model, raw } = endpointCohereParametersSchema.parse(input);
|
24 |
|
25 |
let cohere: CohereClient;
|
26 |
|
27 |
try {
|
28 |
cohere = new (await import("cohere-ai")).CohereClient({
|
29 |
token: apiKey,
|
30 |
+
clientName,
|
31 |
});
|
32 |
} catch (e) {
|
33 |
throw new Error("Failed to import cohere-ai", { cause: e });
|