mirror of
https://github.com/sortedcord/omnia.git
synced 2026-07-22 20:12:48 +05:30
minor: Make GOOGLE_API_KEY optional
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const LLMConfigSchema = z.object({
|
||||
GOOGLE_API_KEY: z.string().min(1, "GOOGLE_API_KEY is required"),
|
||||
GOOGLE_API_KEY: z.string().optional(),
|
||||
});
|
||||
|
||||
export const llmConfig = LLMConfigSchema.parse(process.env);
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
import { z } from "zod";
|
||||
import { ChatGoogleGenerativeAI } from "@langchain/google-genai";
|
||||
import { ILLMProvider, LLMRequest, LLMResponse } from "../llm.js";
|
||||
import { llmConfig } from "../config.js";
|
||||
|
||||
export class GeminiProvider implements ILLMProvider {
|
||||
providerName = "Gemini";
|
||||
private model: ChatGoogleGenerativeAI;
|
||||
|
||||
constructor(apiKey: string) {
|
||||
constructor(apiKey?: string) {
|
||||
const key = apiKey || llmConfig.GOOGLE_API_KEY;
|
||||
if (!key) {
|
||||
throw new Error("GOOGLE_API_KEY is required to initialize GeminiProvider");
|
||||
}
|
||||
this.model = new ChatGoogleGenerativeAI({
|
||||
apiKey,
|
||||
apiKey: key,
|
||||
model: "gemini-2.5-flash",
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user