feat(chat): support other local llm #331

This commit is contained in:
Jacky 2024-05-01 19:40:38 +08:00
parent 08631437ee
commit 3b116b3654
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
4 changed files with 356 additions and 361 deletions

View file

@ -39,17 +39,6 @@ func MakeChatCompletionRequest(c *gin.Context) {
c.Writer.Header().Set("Connection", "keep-alive")
c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
if settings.OpenAISettings.Token == "" {
c.Stream(func(w io.Writer) bool {
c.SSEvent("message", gin.H{
"type": "error",
"content": "[Error] OpenAI token is empty",
})
return false
})
return
}
config := openai.DefaultConfig(settings.OpenAISettings.Token)
if settings.OpenAISettings.Proxy != "" {

1
app/components.d.ts vendored
View file

@ -8,6 +8,7 @@ export {}
declare module 'vue' {
export interface GlobalComponents {
AAlert: typeof import('ant-design-vue/es')['Alert']
AAutoComplete: typeof import('ant-design-vue/es')['AutoComplete']
AAvatar: typeof import('ant-design-vue/es')['Avatar']
ABadge: typeof import('ant-design-vue/es')['Badge']
ABreadcrumb: typeof import('ant-design-vue/es')['Breadcrumb']

View file

@ -4,25 +4,30 @@ import type { Settings } from '@/views/preference/typedef'
const data: Settings = inject('data')!
const errors: Record<string, Record<string, string>> = inject('errors') as Record<string, Record<string, string>>
const models = shallowRef([
{
value: 'gpt-4-1106-preview',
},
{
value: 'gpt-4',
},
{
value: 'gpt-4-32k',
},
{
value: 'gpt-3.5-turbo',
},
])
</script>
<template>
<AForm layout="vertical">
<AFormItem :label="$gettext('ChatGPT Model')">
<ASelect v-model:value="data.openai.model">
<ASelectOption value="gpt-4-1106-preview">
{{ $gettext('GPT-4-Turbo') }}
</ASelectOption>
<ASelectOption value="gpt-4">
{{ $gettext('GPT-4') }}
</ASelectOption>
<ASelectOption value="gpt-4-32k">
{{ $gettext('GPT-4-32K') }}
</ASelectOption>
<ASelectOption value="gpt-3.5-turbo">
{{ $gettext('GPT-3.5-Turbo') }}
</ASelectOption>
</ASelect>
<AFormItem :label="$gettext('Model')">
<AAutoComplete
v-model:value="data.openai.model"
:options="models"
/>
</AFormItem>
<AFormItem
:label="$gettext('API Base Url')"