Skip to content

Commit

Permalink
fix embedding model call
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmacarthy committed Dec 16, 2024
1 parent 8b8181c commit ce7ffc8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
22 changes: 18 additions & 4 deletions src/extension/base.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import * as vscode from "vscode"

import { ACTIVE_CHAT_PROVIDER_STORAGE_KEY, EVENT_NAME, EXTENSION_CONTEXT_NAME } from "../common/constants"
import {
ACTIVE_CHAT_PROVIDER_STORAGE_KEY,
ACTIVE_EMBEDDINGS_PROVIDER_STORAGE_KEY,
EVENT_NAME,
EXTENSION_CONTEXT_NAME
} from "../common/constants"
import { tools } from "../common/tool-definitions"
import { Message,StreamRequestOptions as LlmRequestOptions } from "../common/types"
import {
Message,
StreamRequestOptions as LlmRequestOptions
} from "../common/types"

import { TwinnyProvider } from "./provider-manager"
import { createStreamRequestBody } from "./provider-options"
Expand All @@ -11,7 +19,7 @@ export class Base {
public config = vscode.workspace.getConfiguration("twinny")
public context?: vscode.ExtensionContext

constructor (context: vscode.ExtensionContext) {
constructor(context: vscode.ExtensionContext) {
this.context = context
vscode.workspace.onDidChangeConfiguration((event) => {
if (!event.affectsConfiguration("twinny")) {
Expand All @@ -28,6 +36,13 @@ export class Base {
return provider
}

public getEmbeddingProvider = () => {
const provider = this.context?.globalState.get<TwinnyProvider>(
ACTIVE_EMBEDDINGS_PROVIDER_STORAGE_KEY
)
return provider
}

public buildStreamRequest(messages?: Message[] | Message[]) {
const provider = this.getProvider()

Expand Down Expand Up @@ -64,7 +79,6 @@ export class Base {
return { requestOptions, requestBody }
}


public updateConfig() {
this.config = vscode.workspace.getConfiguration("twinny")
}
Expand Down
2 changes: 1 addition & 1 deletion src/extension/embeddings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class EmbeddingDatabase extends Base {
}

public async fetchModelEmbedding(content: string) {
const provider = this.getProvider()
const provider = this.getEmbeddingProvider()

if (!provider) return

Expand Down

0 comments on commit ce7ffc8

Please sign in to comment.