Skip to content

Commit

Permalink
Fix a few build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ankrgyl committed Nov 24, 2023
1 parent bb24b8a commit 5c836de
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ autoevals-*.tar.gz
autoevals-*.tgz
typedoc.json
build
.turbo
9 changes: 5 additions & 4 deletions js/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { templates } from "./templates.js";
import {
ChatCompletionCreateParams,
ChatCompletionMessage,
ChatCompletionMessageParam,
} from "openai/resources/index.mjs";
import { currentSpan } from "./util.js";

Expand Down Expand Up @@ -63,7 +64,7 @@ export function buildClassificationFunctions(useCoT: boolean) {
export type OpenAIClassifierArgs<RenderArgs> = {
name: string;
model: string;
messages: ChatCompletionMessage[];
messages: ChatCompletionMessageParam[];
choiceScores: Record<string, number>;
classificationFunctions: ChatCompletionCreateParams.Function[];
cache?: ChatCache;
Expand Down Expand Up @@ -117,9 +118,9 @@ export async function OpenAIClassifier<RenderArgs, Output>(
...remainingRenderArgs,
};

const messages: ChatCompletionMessage[] = messagesArg.map((m) => ({
const messages: ChatCompletionMessageParam[] = messagesArg.map((m) => ({
...m,
content: m.content && mustache.render(m.content, renderArgs),
content: m.content && mustache.render(m.content as string, renderArgs),
}));

let ret = null;
Expand Down Expand Up @@ -220,7 +221,7 @@ export function LLMClassifierFromTemplate<RenderArgs>({
promptTemplate + "\n" + (useCoT ? COT_SUFFIX : NO_COT_SUFFIX);

let maxTokens = 512;
const messages: ChatCompletionMessage[] = [
const messages: ChatCompletionMessageParam[] = [
{
role: "user",
content: prompt,
Expand Down
6 changes: 3 additions & 3 deletions js/oai.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
ChatCompletion,
ChatCompletionCreateParams,
ChatCompletionMessage,
ChatCompletionMessageParam,
} from "openai/resources/index.mjs";
import { OpenAI } from "openai";

Expand All @@ -10,9 +10,9 @@ import { currentSpan } from "./util.js";

export interface CachedLLMParams {
model: string;
messages: ChatCompletionMessage[];
messages: ChatCompletionMessageParam[];
functions?: ChatCompletionCreateParams.Function[];
function_call?: ChatCompletionCreateParams.FunctionCallOption;
function_call?: ChatCompletionCreateParams["function_call"];
temperature?: number;
max_tokens?: number;
}
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"declaration": true,
"outDir": "./jsdist",
"lib": ["es6"],
"module": "commonjs",
"module": "NodeNext",
"target": "es6",
"moduleResolution": "nodenext",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"skipLibCheck": true
},
"include": ["js"],
"exclude": ["node_modules/**"]
Expand Down

0 comments on commit 5c836de

Please sign in to comment.