Skip to content

Commit

Permalink
feature(cohere): add clientName param to cohere endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
nsarrazin committed Aug 6, 2024
1 parent 01f4f3a commit 28351df
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lib/server/endpoints/cohere/endpointCohere.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@ export const endpointCohereParametersSchema = z.object({
model: z.any(),
type: z.literal("cohere"),
apiKey: z.string().default(env.COHERE_API_TOKEN),
clientName: z.string().optional(),
raw: z.boolean().default(false),
});

export async function endpointCohere(
input: z.input<typeof endpointCohereParametersSchema>
): Promise<Endpoint> {
const { apiKey, model, raw } = endpointCohereParametersSchema.parse(input);
const { apiKey, clientName, model, raw } = endpointCohereParametersSchema.parse(input);

let cohere: CohereClient;

try {
cohere = new (await import("cohere-ai")).CohereClient({
token: apiKey,
clientName,
});
} catch (e) {
throw new Error("Failed to import cohere-ai", { cause: e });
Expand Down

0 comments on commit 28351df

Please sign in to comment.