Skip to content

Commit

Permalink
Merge main into sweep/unit-tests-chat
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Dec 14, 2023
2 parents a94a33a + 548cf1f commit 95f0f8d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/pages/api/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,15 @@ const handler = async (req: Request): Promise<NextResponse> => {
tiktokenModel.pat_str,
)

let modelObj;
if (typeof model === 'string') {
modelObj = OpenAIModels[model as OpenAIModelID];
} else {
modelObj = model;
}


const token_limit = OpenAIModels[model.id as OpenAIModelID].tokenLimit
const token_limit = OpenAIModels[modelObj.id as OpenAIModelID].tokenLimit
console.log("Model's token limit", token_limit)

let promptToSend = prompt
Expand Down Expand Up @@ -177,7 +184,7 @@ if (temperatureToUse == null) {
promptToSend + "Only answer if it's related to the course materials."

const apiStream = await OpenAIStream(
model,
modelObj,
systemPrompt,
temperatureToUse,
key,
Expand Down

0 comments on commit 95f0f8d

Please sign in to comment.