Merge remote-tracking branch 'origin' into agent-update

This commit is contained in:
Wenjie Zhang 2025-04-01 00:50:25 +08:00
commit 05986a562f
4 changed files with 51 additions and 9 deletions

View File

@ -44,7 +44,11 @@ class OpenAIBase():
def get_models(self):
try:
return self.client.models.list()
return self.client.models.list(
extra_query={
"type": "text"
}
)
except Exception as e:
logger.error(f"Error getting models: {e}")
return []

View File

@ -183,4 +183,10 @@ def chat_agent(agent_name: str,
yield make_chunk(status="finished", history=history_manager.update_ai(content))
return StreamingResponse(stream_messages(), media_type='application/json')
return StreamingResponse(stream_messages(), media_type='application/json')
@chat.get("/models")
async def get_chat_models(model_provider: str):
"""获取指定模型提供商的模型列表"""
model = select_model(model_provider=model_provider)
return {"models": model.get_models()}

View File

@ -1,5 +1,5 @@
<script setup>
import { ref, reactive, KeepAlive, onMounted } from 'vue'
import { ref, reactive, KeepAlive, onMounted, computed } from 'vue'
import { RouterLink, RouterView, useRoute } from 'vue-router'
import {
MessageOutlined,
@ -23,6 +23,7 @@ import {
ExclamationCircleOutlined,
RobotOutlined,
RobotFilled,
ApiOutlined,
} from '@ant-design/icons-vue'
import { themeConfig } from '@/assets/theme'
import { useConfigStore } from '@/stores/config'
@ -76,6 +77,12 @@ onMounted(() => {
const route = useRoute()
console.log(route)
const apiDocsUrl = computed(() => {
// return `${import.meta.env.VITE_API_URL || `http://${window.location.hostname}:${window.location.port}`}/docs`
return `http://localhost:5050/docs`
})
//
const mainList = [{
name: '对话',
@ -157,15 +164,29 @@ const mainList = [{
</div>
<div class="fill" style="flex-grow: 1;"></div>
<div class="github nav-item">
<a href="https://github.com/xerrors/Yuxi-Know" target="_blank" class="github-link">
<GithubOutlined class="icon" style="color: #222;"/>
<span v-if="githubStars > 0" class="github-stars">
<a-tooltip placement="right">
<template #title>GitHub</template>
<a href="https://github.com/xerrors/Yuxi-Know" target="_blank" class="github-link">
<GithubOutlined class="icon" style="color: #222;"/>
<span v-if="githubStars > 0" class="github-stars">
<span class="star-count">{{ githubStars }}</span>
</span>
</a>
</span>
</a>
</a-tooltip>
</div>
<div class="nav-item api-docs">
<a-tooltip placement="right">
<template #title>接口文档 {{ apiDocsUrl }}</template>
<a :href="apiDocsUrl" target="_blank" class="github-link">
<ApiOutlined class="icon" style="color: #222;"/>
</a>
</a-tooltip>
</div>
<RouterLink class="nav-item setting" to="/setting" active-class="active">
<component class="icon" :is="route.path === '/setting' ? SettingFilled : SettingOutlined" />
<a-tooltip placement="right">
<template #title>设置</template>
<component class="icon" :is="route.path === '/setting' ? SettingFilled : SettingOutlined" />
</a-tooltip>
</RouterLink>
</div>
<div class="header-mobile">
@ -303,6 +324,10 @@ div.header, #app-router-view {
}
}
&.api-docs {
padding: 10px 12px;
}
&.setting {
padding: 16px 12px;
width: 56px;

View File

@ -142,9 +142,11 @@
<p>添加的模型是兼容 OpenAI 的模型比如 vllmOllama</p>
<a-form :model="customModel" layout="vertical" >
<a-form-item label="模型名称" name="name" :rules="[{ required: true, message: '请输入模型名称' }]">
<p class="form-item-description">调用的模型的名称</p>
<a-input v-model:value="customModel.name" :disabled="customModel.edit_type == 'edit'"/>
</a-form-item>
<a-form-item label="API Base" name="api_base" :rules="[{ required: true, message: '请输入API Base' }]">
<p class="form-item-description">比如 <code>http://localhost:11434/v1</code></p>
<a-input v-model:value="customModel.api_base" />
</a-form-item>
<a-form-item label="API KEY" name="api_key">
@ -738,6 +740,11 @@ const sendRestart = () => {
.custom-model-modal {
.ant-form-item {
margin-bottom: 10px;
.form-item-description {
font-size: 12px;
color: var(--gray-600);
margin-bottom: 10px;
}
}
}
}