fix: can't read the setting at first time (#2677)

Signed-off-by: James <james@jan.ai>
Co-authored-by: James <james@jan.ai>
This commit is contained in:
NamH 2024-04-11 10:56:47 +07:00 committed by GitHub
parent b19234ed71
commit ddb73d8131
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 33 additions and 0 deletions

View File

@ -102,6 +102,8 @@ export abstract class OAIEngine extends AIEngine {
events.emit(MessageEvent.OnMessageUpdate, message) events.emit(MessageEvent.OnMessageUpdate, message)
}, },
error: async (err: any) => { error: async (err: any) => {
console.debug('inference url: ', this.inferenceUrl)
console.debug('header: ', header)
console.error(`Inference error:`, JSON.stringify(err)) console.error(`Inference error:`, JSON.stringify(err))
if (this.isCancelled || message.content.length) { if (this.isCancelled || message.content.length) {
message.status = MessageStatus.Stopped message.status = MessageStatus.Stopped

View File

@ -37,6 +37,14 @@ export default class JanInferenceGroqExtension extends RemoteOAIEngine {
Settings.chatCompletionsEndPoint, 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 { onSettingUpdate<T>(key: string, value: T): void {

View File

@ -36,6 +36,14 @@ export default class JanInferenceMistralExtension extends RemoteOAIEngine {
Settings.chatCompletionsEndPoint, 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 { onSettingUpdate<T>(key: string, value: T): void {

View File

@ -37,6 +37,13 @@ export default class JanInferenceOpenAIExtension extends RemoteOAIEngine {
Settings.chatCompletionsEndPoint, 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 { onSettingUpdate<T>(key: string, value: T): void {

View File

@ -37,6 +37,14 @@ export default class JanInferenceTritonTrtLLMExtension extends RemoteOAIEngine {
Settings.chatCompletionsEndPoint, 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 { onSettingUpdate<T>(key: string, value: T): void {