Skip to content

Commit

Permalink
fix: can't read the setting at first time (#2677)
Browse files Browse the repository at this point in the history
Signed-off-by: James <[email protected]>
Co-authored-by: James <[email protected]>
  • Loading branch information
namchuai and James authored Apr 11, 2024
1 parent b19234e commit ddb73d8
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/src/browser/extensions/engines/OAIEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ export abstract class OAIEngine extends AIEngine {
events.emit(MessageEvent.OnMessageUpdate, message)
},
error: async (err: any) => {
console.debug('inference url: ', this.inferenceUrl)
console.debug('header: ', header)
console.error(`Inference error:`, JSON.stringify(err))
if (this.isCancelled || message.content.length) {
message.status = MessageStatus.Stopped
Expand Down
8 changes: 8 additions & 0 deletions extensions/inference-groq-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ export default class JanInferenceGroqExtension extends RemoteOAIEngine {
Settings.chatCompletionsEndPoint,
''
)

if (this.inferenceUrl.length === 0) {
SETTINGS.forEach((setting) => {
if (setting.key === Settings.chatCompletionsEndPoint) {
this.inferenceUrl = setting.controllerProps.value as string
}
})
}
}

onSettingUpdate<T>(key: string, value: T): void {
Expand Down
8 changes: 8 additions & 0 deletions extensions/inference-mistral-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ export default class JanInferenceMistralExtension extends RemoteOAIEngine {
Settings.chatCompletionsEndPoint,
''
)

if (this.inferenceUrl.length === 0) {
SETTINGS.forEach((setting) => {
if (setting.key === Settings.chatCompletionsEndPoint) {
this.inferenceUrl = setting.controllerProps.value as string
}
})
}
}

onSettingUpdate<T>(key: string, value: T): void {
Expand Down
7 changes: 7 additions & 0 deletions extensions/inference-openai-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ export default class JanInferenceOpenAIExtension extends RemoteOAIEngine {
Settings.chatCompletionsEndPoint,
''
)
if (this.inferenceUrl.length === 0) {
SETTINGS.forEach((setting) => {
if (setting.key === Settings.chatCompletionsEndPoint) {
this.inferenceUrl = setting.controllerProps.value as string
}
})
}
}

onSettingUpdate<T>(key: string, value: T): void {
Expand Down
8 changes: 8 additions & 0 deletions extensions/inference-triton-trtllm-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ export default class JanInferenceTritonTrtLLMExtension extends RemoteOAIEngine {
Settings.chatCompletionsEndPoint,
''
)

if (this.inferenceUrl.length === 0) {
SETTINGS.forEach((setting) => {
if (setting.key === Settings.chatCompletionsEndPoint) {
this.inferenceUrl = setting.controllerProps.value as string
}
})
}
}

onSettingUpdate<T>(key: string, value: T): void {
Expand Down

0 comments on commit ddb73d8

Please sign in to comment.