feat(agent): support gemma-embedding-2-openai provider (#475)

* feat(agent): support gemma-embedding-2-openai provider

Add support for local LiteRT-LM Gemma Embedding 2 provider with 768-dimensional vector embeddings, environment-configured read-only embedding agents, 16-frame uniform sampling for video chunks, and automatic WebP-to-JPEG conversion.

* refactor(agent): remove unused legacy generateEmbeddingActivity

* chore(agent): align sharp version to 0.35.4

* refactor(agent): rename embedding server env to GEMMA_EMBEDDING_OPENAI_BASE_URL

* refactor(agent,transcode): use native Bun.Archive for video chunk frames

* fix(transcode,agent): populate buffer entries in Bun.Archive and validate frame sizes
This commit is contained in:
Yiling-J
2026-10-15 15:49:24 +08:00
committed by GitHub
parent c302c162a0
commit b7271777e0
28 changed files with 1270 additions and 238 deletions
+49 -3
View File
@@ -43,8 +43,8 @@ interface AgentInfoSource {
config: unknown
soul: string | null
user: { name: string; image: string | null }
skills: Array<{ id: string; skillId: string; skill: { id: string; name: string } }>
mcpServers: Array<{ mcpServerId: string }>
skills?: Array<{ id: string; skillId: string; skill: { id: string; name: string } }>
mcpServers?: Array<{ mcpServerId: string }>
}
function extractS3Key(urlOrKey?: string | null): string | null | undefined {
@@ -462,6 +462,8 @@ export class AgentService {
*/
async toAgentInfo(agent: AgentInfoSource): Promise<AgentInfo> {
const config = agent.config as unknown as PrismaJson.AgentConfig
const isReadOnly = agent.type === 'embedding' && process.env.ENABLE_EMBEDDING_AGENT === 'true'
return {
id: agent.id,
name: agent.user.name,
@@ -475,13 +477,14 @@ export class AgentService {
thinkingLevel: config.thinkingLevel || 'off',
systemPrompt: config.systemPrompt,
soul: agent.soul || undefined,
skills: agent.skills.map((s) => ({
skills: (agent.skills || []).map((s) => ({
id: s.id,
skillId: s.skillId,
skill: s.skill,
})),
mcpServerIds: (agent.mcpServers || []).map((m) => m.mcpServerId),
deniedTools: config.deniedTools || [],
readOnly: isReadOnly,
}
}
@@ -718,6 +721,49 @@ export class AgentService {
params,
)
}
async ensureSystemEmbeddingAgents(): Promise<void> {
if (process.env.ENABLE_EMBEDDING_AGENT !== 'true') {
return
}
const teams = await this.prismaClient.team.findMany({
select: { id: true },
})
for (const team of teams) {
await this.ensureEmbeddingAgentForTeam(team.id)
}
}
async ensureEmbeddingAgentForTeam(teamId: string): Promise<void> {
if (process.env.ENABLE_EMBEDDING_AGENT !== 'true') {
return
}
const existing = await this.prismaClient.agent.findFirst({
where: {
teamId,
type: 'embedding',
},
})
if (!existing) {
await this.createAgent({
teamId,
name: 'embedding-agent',
type: 'embedding',
avatar: 'avatar-1',
thinkingLevel: 'off',
enabled: true,
})
} else if (!existing.enabled) {
await this.prismaClient.agent.update({
where: { id: existing.id },
data: { enabled: true },
})
}
}
}
export const agentService = new AgentService()