Skip to content

Commit

Permalink
use symmetry the provider type from selection
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmacarthy committed Sep 4, 2024
1 parent fc8157b commit 9408729
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
16 changes: 1 addition & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -371,22 +371,8 @@
"default": true,
"description": "Enable twinny debug mode"
},
"twinny.symmetryProvider": {
"order": 19,
"type": "string",
"description": "The symmetry provider type.",
"enum": [
"litellm",
"llamacpp",
"lmstudio",
"ollama",
"oobabooga",
"openwebui"
],
"default": "ollama"
},
"twinny.symmetryServerKey": {
"order": 20,
"order": 19,
"type": "string",
"description": "The symmetry master server key.",
"default": "4b4a9cc325d134dee6679e9407420023531fd7e96c563f6c5d00fd5549b77435"
Expand Down
6 changes: 5 additions & 1 deletion src/extension/providers/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,11 @@ export class SidebarProvider implements vscode.WebviewViewProvider {

private connectToSymmetry = (data: ClientMessage<SymmetryModelProvider>) => {
if (this._config.symmetryServerKey) {
this.symmetryService?.connect(this._config.symmetryServerKey, data.data?.model_name)
this.symmetryService?.connect(
this._config.symmetryServerKey,
data.data?.model_name,
data.data?.provider
)
}
}

Expand Down
13 changes: 9 additions & 4 deletions src/extension/symmetry-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
SYMMETRY_DATA_MESSAGE,
WEBUI_TABS,
ACTIVE_CHAT_PROVIDER_STORAGE_KEY,
GLOBAL_STORAGE_KEY,
GLOBAL_STORAGE_KEY
} from '../common/constants'
import { SessionManager } from './session-manager'
import { EventEmitter } from 'stream'
Expand All @@ -51,7 +51,7 @@ export class SymmetryService extends EventEmitter {
private _providerTopic: Buffer | undefined
private _emitterKey = ''
private _provider: SymmetryProvider | undefined
private _symmetryProvider = this._config.symmetryProvider
private _symmetryProvider: string | undefined
private _symmetryServerKey = this._config.symmetryServerKey
private ws: SymmetryWs | undefined

Expand Down Expand Up @@ -81,8 +81,13 @@ export class SymmetryService extends EventEmitter {
this.ws.connectSymmetryWs()
}

public connect = async (key: string, model: string | undefined) => {
public connect = async (
key: string,
model: string | undefined,
provider: string | undefined
) => {
if (!model || !key) return
this._symmetryProvider = provider
this._serverSwarm = new Hyperswarm()
const serverKey = Buffer.from(key)
const discoveryKey = crypto.discoveryKey(serverKey)
Expand Down Expand Up @@ -186,6 +191,7 @@ export class SymmetryService extends EventEmitter {
this.handleInferenceEnd()

this.handleIncomingData(chunk, (response: StreamResponse) => {
if (!this._symmetryProvider) return
const data = getChatDataFromProvider(this._symmetryProvider, response)
this._completion = this._completion + data
if (!data) return
Expand Down Expand Up @@ -319,7 +325,6 @@ export class SymmetryService extends EventEmitter {

private updateConfig() {
this._config = workspace.getConfiguration('twinny')
this._symmetryProvider = this._config.symmetryProvider
this._symmetryServerKey = this._config.symmetryServerKey
}
}

0 comments on commit 9408729

Please sign in to comment.