Skip to content

Commit

Permalink
refactor config file
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdan Stanga committed Nov 21, 2024
1 parent 33ada0b commit f4d1a04
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export async function runPrompt({
throw new Error(`Unknown LLM model: ${config.llmModel}`);
}

const llm = model.createAi({ apiKey: process.env.LLM_API_KEY });
const llm = model.createAi({ apiKey: config.llmApiKey });
const { object, usage } = await generateObject({
model: llm(model.name),
prompt,
Expand Down
13 changes: 13 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
import { getInput } from "@actions/core";

export class Config {
public llmApiKey: string | undefined;
public llmModel: string | undefined;
public githubToken: string | undefined;

constructor() {
this.githubToken = process.env.GITHUB_TOKEN;
if (!this.githubToken) {
throw new Error("GITHUB_TOKEN is not set");
}

this.llmApiKey = process.env.LLM_API_KEY;
if (!this.llmApiKey) {
throw new Error("LLM_API_KEY is not set");
}

this.llmModel = process.env.LLM_MODEL;
if (!this.llmModel) {
throw new Error("LLM_MODEL is not set");
}
}

public loadInputs() {
Expand Down

0 comments on commit f4d1a04

Please sign in to comment.