Skip to content

Commit

Permalink
Merge pull request #494 from sugarforever/improve/modelsList
Browse files Browse the repository at this point in the history
简单的区分文本嵌入模型
  • Loading branch information
satrong authored May 29, 2024
2 parents eb6d82c + 703b93c commit dabba7a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 1 addition & 5 deletions components/KnowledgeBaseForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ const tabs = computed(() => {
]
})
watch(embeddingList, (list) => {
showEmbeddingDropdown.value = list.flat().length > 0
})
async function onSubmit() {
loading.value = true
const formData = new FormData()
Expand Down Expand Up @@ -157,7 +153,7 @@ function generateEmbeddingData(groupName: string, list: string[], slotName: stri
<div class="flex">
<UDropdown v-model:open="showEmbeddingDropdown"
:items="embeddingList"
:ui="{ item: { disabled: 'pointer-events-none' } }"
:ui="{ item: { disabled: 'pointer-events-none' }, width: 'w-auto' }"
:popper="{ placement: 'bottom-start' }">
<div></div>
<template #group="{ item }">
Expand Down
5 changes: 3 additions & 2 deletions composables/useModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ export function useModels(options?: Options) {
const opts = Object.assign({ immediate: true, forceReload: false }, options)
const loading = ref(false)
const OLLAMA_EMBEDDING_FAMILY_LIST = ['nomic-bert']
const embeddingRegExp = /(\b|_)embed(d?ed|d?ings?)?(\b|_)/i

const chatModels = computed(() => {
return models.value
.filter(el => !OLLAMA_EMBEDDING_FAMILY_LIST.includes(el?.details?.family))
.filter(el => !OLLAMA_EMBEDDING_FAMILY_LIST.includes(el?.details?.family) || !embeddingRegExp.test(el.name!))
.map(el => ({
label: `${el?.details?.family === "Azure OpenAI" ? `Azure ${el.name}` : el.name}`,
name: el.name!,
Expand All @@ -39,7 +40,7 @@ export function useModels(options?: Options) {

const ollamaEmbeddingModels = computed(() => {
return models.value
.filter(el => OLLAMA_EMBEDDING_FAMILY_LIST.includes(el?.details?.family))
.filter(el => OLLAMA_EMBEDDING_FAMILY_LIST.includes(el?.details?.family) || embeddingRegExp.test(el.name!))
.map(el => ({ label: el.name!, value: el.name!, family: el?.details?.family }))
})

Expand Down

0 comments on commit dabba7a

Please sign in to comment.