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(ai-help): switch to text-embedding-3-small model #459

Merged
merged 2 commits into from
Apr 5, 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
2 changes: 1 addition & 1 deletion src/ai/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub const AI_HELP_GPT4_FULL_DOC_NEW_PROMPT: AIHelpConfig = AIHelpConfig {
};

pub const MODEL: &str = "gpt-3.5-turbo";
pub const EMBEDDING_MODEL: &str = "text-embedding-ada-002";
pub const EMBEDDING_MODEL: &str = "text-embedding-3-small";

pub const AI_HELP_SYSTEM_MESSAGE: &str = "You are a very enthusiastic MDN AI who loves \
to help people! Given the following information from MDN, answer the user's question \
Expand Down
6 changes: 3 additions & 3 deletions src/ai/embeddings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ const MACRO_DOCS_QUERY: &str = "SELECT
doc.title,
parent.title_short AS title_parent,
doc.markdown AS content,
doc.embedding <=> $1 AS similarity
doc.embedding_next <=> $1 AS similarity
FROM mdn_doc_macro doc
LEFT JOIN mdn_doc_macro parent ON parent.mdn_url = SUBSTRING(doc.mdn_url, 1, LENGTH(doc.mdn_url) - STRPOS(REVERSE(doc.mdn_url), '/'))
WHERE LENGTH(doc.markdown) >= $4
AND (doc.embedding <=> $1) < $2
AND (doc.embedding_next <=> $1) < $2
AND doc.mdn_url NOT LIKE '/en-US/docs/MDN%'
ORDER BY doc.embedding <=> $1
ORDER BY doc.embedding_next <=> $1
LIMIT $3;";

#[derive(sqlx::FromRow, Debug)]
Expand Down
Loading