Skip to content

Commit

Permalink
Refactor: API Key + some typos
Browse files Browse the repository at this point in the history
  • Loading branch information
zya committed Dec 21, 2023
1 parent 69409ee commit ff46d28
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/handlers/ai21.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,14 @@ export async function AI21Handler(
params: HandlerParams,
): Promise<ResultNotStreaming | ResultStreaming> {
const baseUrl = params.baseUrl ?? 'https://api.ai21.com';
const apiKey = params. apiKey ?? process.env.AI21_API_KEY!;
const apiKey = params.apiKey ?? process.env.AI21_API_KEY!;
const model = params.model;
const prompt = combinePrompts(params.messages);

const res = await getAI21Response(model, prompt, baseUrl, apiKey);

if (!res.ok) {
throw new Error(`Recieved an error with code ${res.status} from AI21 API.`);
throw new Error(`Received an error with code ${res.status} from AI21 API.`);
}

const body = (await res.json()) as AI21Response;
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/anthropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export async function AnthropicHandler(
export async function AnthropicHandler(
params: HandlerParams,
): Promise<ResultNotStreaming | ResultStreaming> {
const apiKey = params. apiKey ?? process.env.ANTHROPIC_API_KEY;
const apiKey = params.apiKey ?? process.env.ANTHROPIC_API_KEY;

const anthropic = new Anthropic({
apiKey: apiKey,
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/cohere.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export async function CohereHandler(
export async function CohereHandler(
params: HandlerParams,
): Promise<ResultNotStreaming | ResultStreaming> {
const apiKey = params. apiKey ?? process.env.COHERE_API_KEY!;
const apiKey = params.apiKey ?? process.env.COHERE_API_KEY!;

cohere.init(apiKey);
const textsCombined = combinePrompts(params.messages);
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/deepinfra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export async function DeepInfraHandler(
params: HandlerParams,
): Promise<ResultNotStreaming | ResultStreaming> {
const baseUrl = params.baseUrl ?? 'https://api.deepinfra.com';
const apiKey = params. apiKey ?? process.env.DEEPINFRA_API_KEY!;
const apiKey = params.apiKey ?? process.env.DEEPINFRA_API_KEY!;
const model = params.model.split('deepinfra/')[1];

const res = await getDeepInfraResponse(
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/mistral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export async function MistralHandler(
params: HandlerParams,
): Promise<ResultNotStreaming | ResultStreaming> {
const baseUrl = params.baseUrl ?? 'https://api.mistral.ai';
const apiKey = params. apiKey ?? process.env.MISTRAL_API_KEY!;
const apiKey = params.apiKey ?? process.env.MISTRAL_API_KEY!;
const model = params.model.split('mistral/')[1];

const res = await getMistralResponse(
Expand Down
4 changes: 2 additions & 2 deletions src/handlers/mistralEmbedding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function MistralEmbeddingHandler(
): Promise<EmbeddingResponse> {
const model = params.model.split('mistral/')[1];
const baseUrl = params.baseUrl ?? 'https://api.mistral.ai';
const apiKey = params. apiKey ?? process.env.MISTRAL_API_KEY!;
const apiKey = params.apiKey ?? process.env.MISTRAL_API_KEY!;
const response = await getMistralResponse(
model,
params.input,
Expand All @@ -35,7 +35,7 @@ export async function MistralEmbeddingHandler(

if (!response.ok) {
throw new Error(
`Recieved an error with code ${response.status} from Mistral API.`,
`Received an error with code ${response.status} from Mistral API.`,
);
}
const body = (await response.json()) as CreateEmbeddingResponse;
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/ollama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export async function OllamaHandler(

if (!res.ok) {
throw new Error(
`Recieved an error with code ${res.status} from Ollama API.`,
`Received an error with code ${res.status} from Ollama API.`,
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/handlers/ollamaEmbedding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function OllamaEmbeddingHandler(

if (!response.ok) {
throw new Error(
`Recieved an error with code ${response.status} from Ollama API.`,
`Received an error with code ${response.status} from Ollama API.`,
);
}
const body = (await response.json()) as OllamaEmbeddingsResponseChunk;
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export async function OpenAIHandler(
export async function OpenAIHandler(
params: HandlerParams,
): Promise<ResultNotStreaming | ResultStreaming> {
const apiKey = params. apiKey ?? process.env.OPENAI_API_KEY;
const apiKey = params.apiKey ?? process.env.OPENAI_API_KEY;

const openai = new OpenAI({
apiKey: apiKey,
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/replicate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export async function ReplicateHandler(
export async function ReplicateHandler(
params: HandlerParams,
): Promise<ResultNotStreaming | ResultStreaming> {
const apiKey = params. apiKey ?? process.env.REPLICATE_API_KEY;
const apiKey = params.apiKey ?? process.env.REPLICATE_API_KEY;
const replicate = new Replicate({
auth: apiKey,
});
Expand Down

0 comments on commit ff46d28

Please sign in to comment.