Skip to content

Commit

Permalink
Merge main into sweep/docstring-course-card
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Dec 13, 2023
2 parents c990608 + bfe9c53 commit 2d41e88
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
21 changes: 21 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,27 @@ const config = {
experimental: {
esmExternals: false, // To make upload thing work with /pages router.
},
async headers() {
return [
{
source: '/api/:path*',
headers: [
{
key: 'Access-Control-Allow-Origin',
value: '*',
},
{
key: 'Access-Control-Allow-Methods',
value: 'GET,PUT,POST,DELETE,OPTIONS',
},
{
key: 'Access-Control-Allow-Headers',
value: 'X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept',
},
],
},
]
},
}

const withAxiomConfig = withAxiom(config)
Expand Down
4 changes: 4 additions & 0 deletions src/pages/api/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ export const config = {

const handler = async (req: Request): Promise<NextResponse> => {
try {
console.log("Top of /api/chat.ts. req: ", req)
const { model, messages, key, prompt, temperature, course_name, stream } =
(await req.json()) as ChatBody
console.log("After message parsing: ", model, messages, key, prompt, temperature, course_name, stream)

await init((imports) => WebAssembly.instantiate(wasm, imports))
const encoding = new Tiktoken(
Expand All @@ -27,7 +29,9 @@ const handler = async (req: Request): Promise<NextResponse> => {
tiktokenModel.pat_str,
)


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

let promptToSend = prompt
if (!promptToSend) {
Expand Down

0 comments on commit 2d41e88

Please sign in to comment.