添加获取 model list 的 API 接口
This commit is contained in:
parent
f5302c4c4b
commit
2fe4bf6363
@ -44,7 +44,11 @@ class OpenAIBase():
|
|||||||
|
|
||||||
def get_models(self):
|
def get_models(self):
|
||||||
try:
|
try:
|
||||||
return self.client.models.list()
|
return self.client.models.list(
|
||||||
|
extra_query={
|
||||||
|
"type": "text"
|
||||||
|
}
|
||||||
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error getting models: {e}")
|
logger.error(f"Error getting models: {e}")
|
||||||
return []
|
return []
|
||||||
|
|||||||
@ -179,3 +179,9 @@ def chat_agent(agent_name: str,
|
|||||||
yield make_chunk(status="finished", history=history_manager.update_ai(content))
|
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()}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<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 { RouterLink, RouterView, useRoute } from 'vue-router'
|
||||||
import {
|
import {
|
||||||
MessageOutlined,
|
MessageOutlined,
|
||||||
@ -23,6 +23,7 @@ import {
|
|||||||
ExclamationCircleOutlined,
|
ExclamationCircleOutlined,
|
||||||
RobotOutlined,
|
RobotOutlined,
|
||||||
RobotFilled,
|
RobotFilled,
|
||||||
|
ApiOutlined,
|
||||||
} from '@ant-design/icons-vue'
|
} from '@ant-design/icons-vue'
|
||||||
import { themeConfig } from '@/assets/theme'
|
import { themeConfig } from '@/assets/theme'
|
||||||
import { useConfigStore } from '@/stores/config'
|
import { useConfigStore } from '@/stores/config'
|
||||||
@ -76,6 +77,12 @@ onMounted(() => {
|
|||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
console.log(route)
|
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 = [{
|
const mainList = [{
|
||||||
name: '对话',
|
name: '对话',
|
||||||
@ -157,15 +164,29 @@ const mainList = [{
|
|||||||
</div>
|
</div>
|
||||||
<div class="fill" style="flex-grow: 1;"></div>
|
<div class="fill" style="flex-grow: 1;"></div>
|
||||||
<div class="github nav-item">
|
<div class="github nav-item">
|
||||||
<a href="https://github.com/xerrors/Yuxi-Know" target="_blank" class="github-link">
|
<a-tooltip placement="right">
|
||||||
<GithubOutlined class="icon" style="color: #222;"/>
|
<template #title>GitHub</template>
|
||||||
<span v-if="githubStars > 0" class="github-stars">
|
<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 class="star-count">{{ githubStars }}</span>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</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>
|
</div>
|
||||||
<RouterLink class="nav-item setting" to="/setting" active-class="active">
|
<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>
|
</RouterLink>
|
||||||
</div>
|
</div>
|
||||||
<div class="header-mobile">
|
<div class="header-mobile">
|
||||||
@ -303,6 +324,10 @@ div.header, #app-router-view {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.api-docs {
|
||||||
|
padding: 10px 12px;
|
||||||
|
}
|
||||||
|
|
||||||
&.setting {
|
&.setting {
|
||||||
padding: 16px 12px;
|
padding: 16px 12px;
|
||||||
width: 56px;
|
width: 56px;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user