-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ feat: 允许用户自行定义 Embedding 模型 #5177
base: main
Are you sure you want to change the base?
Conversation
@cookieY is attempting to deploy a commit to the LobeHub Team on Vercel. A member of the Team first needs to authorize it. |
👍 @cookieY Thank you for raising your pull request and contributing to our Community |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5177 +/- ##
==========================================
- Coverage 92.20% 92.02% -0.18%
==========================================
Files 568 571 +3
Lines 43395 43596 +201
Branches 2706 2707 +1
==========================================
+ Hits 40012 40120 +108
- Misses 3383 3476 +93
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
支不支持本地部署的embedding模型?例如 api 地址是 http://127.0.0.1/v1 的类 openai 接口? |
Does it support locally deployed embedding models? For example, the api address is an openai-like interface at http://127.0.0.1/v1? |
基于现有的框架设计无法实现这样的自定义需求,本地部署可以使用 ollama |
Such custom requirements cannot be achieved based on the existing framework design. For local deployment, ollama can be used. |
@@ -4,10 +4,14 @@ import { z } from 'zod'; | |||
export const getKnowledgeConfig = () => { | |||
return createEnv({ | |||
runtimeEnv: { | |||
DEFAULT_FILES_CONFIG: !!process.env.DEFAULT_FILES_CONFIG | |||
? process.env.DEFAULT_FILES_CONFIG | |||
: 'embedding_model=openai/embedding-text-3-small,reranker_model=cohere/rerank-english-v3.0,query_mode=full_text', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里不应该给默认值
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
默认的 embedding model 、 query model 以及reranker model 不应该用 DEFAULT_SYSTEM_AGENT_ITEM 吧?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里不能用任何服务端方法。因为 schema 既会在 server 端跑,也会在 client端执行
如果要改默认向量化模型,这里就不需要加 $defaultFn(() => DEFAULT_EMBEDDING_MODEL),
了
@@ -4,6 +4,7 @@ export interface EmbeddingsPayload { | |||
* supported in `text-embedding-3` and later models. | |||
*/ | |||
dimensions?: number; | |||
index?: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为啥这里还需要index?
@@ -275,22 +275,46 @@ export const LobeOpenAICompatibleFactory = <T extends Record<string, any> = any> | |||
.filter(Boolean) as ChatModelCard[]; | |||
} | |||
|
|||
/** | |||
* Due to the limitation of a maximum of 8k tokens per request in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8k 不是 request 的要求,而是 openai embedding 模型的上下文大小,因此这里不应该改变。要改也是上层调用 embedding 的地方做 8k 的分块
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的实现逻辑并不合理。system agent 和 embedding 是两个不同的业务功能模块,不应该混在一起。单独写一个 parseFileConfig
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个模块感觉没有太大必要,而且未来提供 ui 配置还没法合并,不应该这么写。
💻 变更类型 | Change Type
🔀 变更说明 | Description of Change
由于之前代码commit差距过大 重新提交,提交说明参考 #4370
📝 补充信息 | Additional Information