添加获取 model list 的 API 接口
This commit is contained in:
parent
f5302c4c4b
commit
2fe4bf6363
@ -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 []
|
||||
|
||||
@ -179,3 +179,9 @@ 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')
|
||||
|
||||
@chat.get("/models")
|
||||
async def get_chat_models(model_provider: str):
|
||||
"""获取指定模型提供商的模型列表"""
|
||||
model = select_model(model_provider=model_provider)
|
||||
return {"models": model.get_models()}
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user