-
Notifications
You must be signed in to change notification settings - Fork 134
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
Resolve model connection info and add embeddings model candidates #624
Conversation
@@ -98,7 +98,7 @@ export async function startServer(options: { port: string }) { | |||
): Promise<ChatCompletionResponse> => { | |||
const { messages, model } = req | |||
const { partialCb } = options | |||
if (!wss.clients.size) throw new Error("no llm clients connected") | |||
if (!wss.clients?.size) throw new Error("no llm clients connected") |
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.
Optional chaining is used on wss.clients?.size
. If wss.clients
is undefined, it will not throw an error and may lead to unexpected behavior. Please ensure wss.clients
is always defined.
generated by pr-review-commit
optional_chaining
...DEFAULT_MODEL_CANDIDATES, | ||
]) | ||
for (const candidate of candidates) { | ||
for (const candidate of new Set(candidates || [])) { |
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.
Creating a new Set from candidates
array is unnecessary if the array does not contain duplicate values. This can lead to unnecessary memory usage and performance degradation.
generated by pr-review-commit
unnecessary_set
...DEFAULT_EMBEDDINGS_MODEL_CANDIDATES, | ||
], | ||
} | ||
) |
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 object passed to resolveModelConnectionInfo
function is complex and hard to read. Consider creating this object separately and then pass it to the function for better readability and maintainability.
generated by pr-review-commit
complex_object_creation
The changes in this pull request can be summarized as follows:
Overall, the changes provide better error handling, more customization options and extended functionality. The code seems well-structured and no functional issues are observed. However, in With these observations, I can say that overall the changes look good to me. So, it's LGTM 🚀.
|
This pull request includes changes to resolve the model connection info, allowing for the selection of different models. It also adds a list of default embeddings model candidates to choose from. These changes improve the flexibility and customization options for the software.
A possibility for clients to be
undefined
instartServer
function inserver.ts
is now handled by using optional chaining.if (!wss.clients.size) throw new Error("no llm clients connected")
if (!wss.clients?.size) throw new Error("no llm clients connected")
The list of
DEFAULT_MODEL_CANDIDATES
is expanded with"openai:gpt-4o"
inconstants.ts
.New array
DEFAULT_EMBEDDINGS_MODEL_CANDIDATES
is created inconstants.ts
. The array consists of four models named after tech companies and suffixed with"text-embedding-3-small"
.Modifications in
resolveModelConnectionInfo
function inmodels.ts
:model
andtoken
,candidates
is also added inoptions
.candidates
parameter is initialized with a default value that contains the default model and a spread operator forDEFAULT_MODEL_CANDIDATES
.candidates
parameter.Changes in
vectorSearch
function invectorSearch.ts
:resolveModelConnectionInfo
with additional parameters, wheretoken
value istrue
andcandidates
is a set of default settings for embedding model options.Addition of a new file
vectorstore.genai.mts
in thesample
directory. This file contains functions for initializing, creating a document, and searching in a vector store.The
sample
package'spackage.json
file is updated with a new devDependencyvectorstore
.