Skip to content

Commit

Permalink
Merge pull request #17 from presubmit/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
bstanga authored Nov 21, 2024
2 parents 2b2d6de + 3531ea3 commit c387824
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/presubmit-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LLM_API_KEY: ${{ secrets.LLM_API_KEY }}
with:
llm_model: "claude-3-5-sonnet-20241022"
LLM_MODEL: "claude-3-5-sonnet-20241022"
5 changes: 0 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ branding:
icon: "check-square"
color: "black"

inputs:
llm_model:
description: "The LLM model to use for code review"
required: true

runs:
using: "node20"
main: "dist/index.js"
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
18 changes: 15 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
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() {
if (process.env.DEBUG) {
console.log("[debug] skip loading inputs");
return;
}
this.llmModel = getInput("llm_model");

// TODO: handle inputs
}
}

Expand Down

0 comments on commit c387824

Please sign in to comment.