-
Notifications
You must be signed in to change notification settings - Fork 126
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
move rag tests to ollama #623
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
"markdownify", | ||
"memorystream", | ||
"millis", | ||
"nomic", | ||
"ollama", | ||
"openai", | ||
"promptdom", | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -710,6 +710,8 @@ | |
"Function to do a search using embeddings vector similarity distance.", | ||
}) | ||
|
||
const embeddingsModel = env.var.embeddingsModel || undefined | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable
|
||
|
||
defTool( | ||
"retrieval_vector_search", | ||
"Search files using embeddings and similarity distance.", | ||
|
@@ -737,7 +739,7 @@ | |
const res = await retrieval.vectorSearch( | ||
q, | ||
files.map((filename) => ({ filename })) | ||
) | ||
, { embeddingsModel }) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The argument label for
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing comma after the closing parenthesis of the
|
||
return YAML.stringify(res.map(({ filename }) => filename)) | ||
} | ||
) | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,7 +101,7 @@ | |
const configuration = await host.getLanguageModelConfiguration( | ||
model, | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The token variable name has been changed from 'askToken' to 'withToken'. Please ensure that 'withToken' is defined and holds the correct value. 🕵️♀️
|
||
token: askToken, | ||
token: withToken, | ||
signal, | ||
trace, | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -187,7 +187,14 @@ | |
/** | ||
* LLM model to use for embeddings. | ||
*/ | ||
embeddingsModel?: "openai:text-embedding-ada-002" | string | ||
embeddingsModel?: OptionsOrString< | ||
"openai:text-embedding-3-small", | ||
"openai:text-embedding-3-large", | ||
"openai:text-embedding-ada-002", | ||
"github:text-embedding-3-small", | ||
"github:text-embedding-3-large", | ||
"ollama:nomic-embed-text" | ||
> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The 'embeddingsModel' type has been changed and new options have been added. Please ensure that these new options are supported and handled correctly in the code. 🧐
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
|
||
} | ||
|
||
interface EmbeddingsModelOptions extends EmbeddingsModelConnectionOptions {} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
import { EmbeddingCreateParams, EmbeddingCreateResponse } from "./chattypes" | ||
import { LanguageModelConfiguration } from "./host" | ||
import { getConfigHeaders } from "./openai" | ||
import { trimTrailingSlash } from "./util" | ||
import { logVerbose, trimTrailingSlash } from "./util" | ||
import { TraceOptions } from "./trace" | ||
|
||
export interface EmbeddingsCacheKey { | ||
|
@@ -72,10 +72,11 @@ | |
url = `${trimTrailingSlash(base)}/${model.replace(/\./g, "")}/embeddings?api-version=${AZURE_OPENAI_API_VERSION}` | ||
delete body.model | ||
} else { | ||
url = `${base}/v1/embeddings` | ||
url = `${base}/embeddings` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The URL endpoint for embeddings has been changed from '/v1/embeddings' to '/embeddings'. Please ensure that the new endpoint is correct and functional. 🌐
|
||
} | ||
const fetch = await createFetch({ retryOn: [429] }) | ||
if (trace) traceFetchPost(trace, url, headers, body) | ||
logVerbose(`embedding ${model}`) | ||
const resp = await fetch(url, { | ||
method: "POST", | ||
headers, | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,44 @@ | ||
script({ | ||
title: "rag", | ||
model: "openai:gpt-3.5-turbo", | ||
model: "ollama:phi3", | ||
files: "src/rag/*", | ||
tests: { | ||
files: "src/rag/*", | ||
keywords: ["lorem", "markdown", "word"], | ||
}, | ||
}) | ||
|
||
$`You are a helpful assistant. Summarize the files in MARKDOWN, PDF, WORD and ALL.` | ||
$`Summarize MARKDOWN, PDF, WORD and ALL. Use one short sentence.` | ||
|
||
const embeddingsModel = env.vars.embeddingsModel || "ollama:nomic-embed-text" | ||
|
||
def( | ||
"MARKDOWN", | ||
await retrieval.vectorSearch( | ||
"markdown", | ||
env.files.filter((f) => f.filename.endsWith(".md")) | ||
env.files.filter((f) => f.filename.endsWith(".md")), | ||
{ embeddingsModel } | ||
) | ||
) | ||
def( | ||
"PDF", | ||
await retrieval.vectorSearch( | ||
"lorem", | ||
env.files.filter((f) => f.filename.endsWith(".pdf")) | ||
env.files.filter((f) => f.filename.endsWith(".pdf")), | ||
{ embeddingsModel } | ||
) | ||
) | ||
def( | ||
"WORD", | ||
await retrieval.vectorSearch( | ||
"word", | ||
env.files.filter((f) => f.filename.endsWith(".docx")) | ||
env.files.filter((f) => f.filename.endsWith(".docx")), | ||
{ embeddingsModel } | ||
) | ||
) | ||
def("ALL", await retrieval.vectorSearch("lorem", env.files)) | ||
def( | ||
"ALL", | ||
await retrieval.vectorSearch("lorem", env.files, { | ||
embeddingsModel, | ||
}) | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable
embeddingsModel
is declared but its value is never read.