Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
parzival418 committed Jun 8, 2024
2 parents c9558e6 + c51a0b4 commit a6669ea
Show file tree
Hide file tree
Showing 49 changed files with 3,207 additions and 2,498 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20
18.18
31 changes: 31 additions & 0 deletions apps/embedder/src/server/api/jobs/[id].get.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { JobSchema } from '@magickml/embedder/schema'
import { embedderDb } from 'embedder-db-pg'

export default defineEventHandler(async event => {
const id = getRouterParam(event, 'id')

if (!id) {
throw createError({
statusCode: 400,
message: 'Missing id',
})
}

const job = await embedderDb.query.Job.findFirst({
where: (job, { eq }) => eq(job.id, id),
})

if (!job) {
throw createError({
statusCode: 404,
message: 'Job not found',
})
}

// Do something with id

console.log('Job:', job)

// return job
return JobSchema.parse(job)
})
6 changes: 5 additions & 1 deletion apps/embedder/src/server/api/packs/[id]/loaders.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,9 @@ export default defineEventHandler(async event => {
const queue = useBullMQ('embedJobs')
await queue.add('processJob', { jobId: job.id })

return AddLoaderResponseSchema.parse({ status: loader.status, id: loader.id })
return AddLoaderResponseSchema.parse({
status: loader.status,
id: loader.id,
jobId: job.id,
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { z } from 'zod'
import { embedderDb, Loader } from 'embedder-db-pg'
import { and, eq } from 'drizzle-orm'
import { createLoader } from '@magickml/embedder/loaders/core'
import { LoaderWithChunks } from '@magickml/embedder/schema'

export default defineEventHandler(async event => {
const packId = z.string().parse(event.context.params?.id)
Expand Down Expand Up @@ -29,5 +30,10 @@ export default defineEventHandler(async event => {
chunksArray.push(chunk.pageContent)
}

return { chunks: chunksArray }
const response = {
...loader,
chunks: chunksArray,
}

return LoaderWithChunks.parse(response)
})
2 changes: 1 addition & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
}
},
"defaultProject": "@magickml/server",
"useInferencePlugins": false,
"useInferencePlugins": true,
"defaultBase": "main",
"release": {
"projects": [
Expand Down
Loading

0 comments on commit a6669ea

Please sign in to comment.