Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expand context discussions bot has for answers by including discussion answers #3778

Merged
merged 2 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/paste-website/src/pages/api/ai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ export default async function handler(req: NextRequest): Promise<void | Response
const { embedding } = embeddingResponse.data[0];

// eslint-disable-next-line no-console
console.log(`${LOG_PREFIX} Request Page sections based on embeddings`);
console.log(`${LOG_PREFIX} Request Page and Discussions sections based on embeddings`);

const { error: matchError, data: pageSections } = await supabaseClient.rpc("match_page_sections_for_ai", {
const { error: matchError, data: pageSections } = await supabaseClient.rpc("match_page_sections_v3", {
embedding,
/* eslint-disable camelcase */
match_threshold: 0.78,
Expand All @@ -158,15 +158,15 @@ export default async function handler(req: NextRequest): Promise<void | Response
const encoded = tokenizer.encode(content);
tokenCount += encoded.text.length;

if (tokenCount >= 1500) {
if (tokenCount >= 2500) {
break;
}

contextText += `${content.trim()}\n---\n`;
}

// eslint-disable-next-line no-console
console.log(`${LOG_PREFIX} Context text: ${contextText}`);
console.log(`${LOG_PREFIX} Context ${tokenCount} tokens and text: ${contextText}`);

const prompt = codeBlock`
${oneLine`
Expand Down Expand Up @@ -199,7 +199,7 @@ export default async function handler(req: NextRequest): Promise<void | Response
console.log(`${LOG_PREFIX} Request chat completion`);

const response = await openai.chat.completions.create({
model: "gpt-4-1106-preview",
model: "gpt-4-turbo-preview",
messages: [chatMessage],
// eslint-disable-next-line camelcase
max_tokens: 2000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const LOG_PREFIX = "[/api/paste-assistant-simple-completion]:";

async function getCompletion(prompt: OpenAI.Chat.ChatCompletionMessageParam): Promise<OpenAI.Chat.ChatCompletion> {
return openai.chat.completions.create({
model: "gpt-4-1106-preview",
model: "gpt-4-turbo-preview",
messages: [prompt],
// eslint-disable-next-line camelcase
max_tokens: 2000,
Expand Down
Loading