mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-28 11:54:42 +00:00
Merge pull request #129 from shumaiOne/fix/project-updated-at-asset-hook
fix(db): automatically update project updatedAt on asset modification
This commit is contained in:
@@ -12,11 +12,11 @@ Traditional search relies on matching exact characters (e.g., searching "dog" wi
|
||||
Semantic search translates text queries and file contents into conceptual profiles. Similar ideas and visuals are mapped near each other.
|
||||
|
||||
1. **Index Generation**: When you upload an asset, Shumai's background agent scans the file's visual elements, text contents, or descriptions, translating them into a concept profile.
|
||||
- **Video Processing**: Shumai uses **gemini-embedding-2** for video indexing.
|
||||
- **Chunking**: For long videos, Shumai breaks them into chunks to ensure high-quality indexing. By default, chunks are **60 seconds** long with a **5-second overlap** to ensure no context is lost at the boundaries.
|
||||
- **Sampling**: The model processes a maximum of 32 frames per chunk: short chunks (≤32s) are sampled at 1 fps, while longer chunks are uniformly sampled to 32 frames.
|
||||
- **Optimization**: To optimize processing, Shumai automatically transcodes each chunk to **1 FPS** and **removes the audio track** before sending it to the embedding agent.
|
||||
- **Configuration**: Administrators can customize these settings using the `EMBEDDING_CHUNK_DURATION` and `EMBEDDING_CHUNK_OVERLAP` environment variables.
|
||||
- **Video Processing**: Shumai uses **gemini-embedding-2** for video indexing.
|
||||
- **Chunking**: For long videos, Shumai breaks them into chunks to ensure high-quality indexing. By default, chunks are **60 seconds** long with a **5-second overlap** to ensure no context is lost at the boundaries.
|
||||
- **Sampling**: The model processes a maximum of 32 frames per chunk: short chunks (≤32s) are sampled at 1 fps, while longer chunks are uniformly sampled to 32 frames.
|
||||
- **Optimization**: To optimize processing, Shumai automatically transcodes each chunk to **1 FPS** and **removes the audio track** before sending it to the embedding agent.
|
||||
- **Configuration**: Administrators can customize these settings using the `EMBEDDING_CHUNK_DURATION` and `EMBEDDING_CHUNK_OVERLAP` environment variables.
|
||||
2. **Concept Matching**: When you search with the "Semantic" toggle enabled, Shumai matches the conceptual meaning of your query against your assets.
|
||||
3. **Result**: Searching "sunset at the beach" will successfully find a video file of ocean waves at dusk, even if the filename is `IMG_4029.mp4`.
|
||||
|
||||
|
||||
@@ -316,8 +316,7 @@ export async function getEmbeddingContextActivity(params: { teamId: string; asse
|
||||
Number.isFinite(parsedDuration) && parsedDuration > 0 ? parsedDuration : 60.0
|
||||
|
||||
const parsedOverlap = parseFloat(process.env.EMBEDDING_CHUNK_OVERLAP || '')
|
||||
const chunkOverlap =
|
||||
Number.isFinite(parsedOverlap) && parsedOverlap >= 0 ? parsedOverlap : 5.0
|
||||
const chunkOverlap = Number.isFinite(parsedOverlap) && parsedOverlap >= 0 ? parsedOverlap : 5.0
|
||||
|
||||
return {
|
||||
agent,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { PrismaClient, WorkflowTask } from './generated/prisma/client'
|
||||
import { PrismaTestingHelper } from './prisma-testing-helper'
|
||||
import { PrismaPg } from '@prisma/adapter-pg'
|
||||
import { Pool } from 'pg'
|
||||
import { PrismaClient, WorkflowTask } from './generated/prisma/client'
|
||||
import { PrismaTestingHelper } from './prisma-testing-helper'
|
||||
import { generateNgrams } from './utils/ngram'
|
||||
|
||||
// Global callback for workflow task creation (decouples db package from workflow engine)
|
||||
@@ -26,6 +26,7 @@ function createPrismaClient() {
|
||||
const pool = new Pool({ connectionString })
|
||||
const adapter = new PrismaPg(pool)
|
||||
const client = new PrismaClient({ adapter, log: ['error'] })
|
||||
|
||||
return client.$extends({
|
||||
query: {
|
||||
workflowTask: {
|
||||
@@ -48,7 +49,14 @@ function createPrismaClient() {
|
||||
if (typeof args.data.name === 'string') {
|
||||
args.data.nameNgram = generateNgrams(args.data.name)
|
||||
}
|
||||
return query(args)
|
||||
const result = await query(args)
|
||||
if (args.where) {
|
||||
await client.project.updateMany({
|
||||
where: { assets: { some: args.where } },
|
||||
data: { updatedAt: new Date() },
|
||||
})
|
||||
}
|
||||
return result
|
||||
},
|
||||
async upsert({ args, query }) {
|
||||
if (typeof args.create.name === 'string') {
|
||||
@@ -95,5 +103,5 @@ export function getPrismaTestingHelper() {
|
||||
return prismaTestingHelper
|
||||
}
|
||||
|
||||
export * from './utils/ngram'
|
||||
export * from './generated/prisma/client'
|
||||
export * from './utils/ngram'
|
||||
|
||||
Reference in New Issue
Block a user