Skip to content

Commit 629f21b

Browse files
Veikkosuhonensutigit
authored andcommitted
cleanup
1 parent 4ecdaaa commit 629f21b

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

src/client/components/Rag/RagIndex.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ const useUploadMutation = (index: RagIndexAttributes | null) => {
6060

6161
const RagFile: React.FC<{ file: RagFileAttributes }> = ({ file }) => {
6262
const inProgress = file.pipelineStage !== 'completed' && file.pipelineStage !== 'pending'
63-
const progressIdx = IngestionPipelineStageKeys.findIndex((stage) => stage === file.pipelineStage)
63+
const progressIdx = IngestionPipelineStageKeys.findIndex((stage) => stage === file.pipelineStage) - 1
6464
const progressNextIdx = inProgress ? progressIdx + 1 : progressIdx
65+
const numSteps = IngestionPipelineStageKeys.length - 2
6566

6667
return (
6768
<Paper sx={{ padding: 2, marginBottom: 2 }} elevation={3}>
@@ -85,16 +86,12 @@ const RagFile: React.FC<{ file: RagFileAttributes }> = ({ file }) => {
8586
<TableCell>{file.fileType}</TableCell>
8687
<TableCell>{file.fileSize}</TableCell>
8788
<TableCell>{file.numChunks}</TableCell>
88-
<TableCell>{file.pipelineStage}</TableCell>
89+
<TableCell>{IngestionPipelineStages[file.pipelineStage].name}</TableCell>
8990
</TableRow>
9091
</TableBody>
9192
</Table>
9293
{file.pipelineStage !== 'completed' && file.pipelineStage !== 'pending' && (
93-
<LinearProgress
94-
variant="buffer"
95-
value={(progressIdx * 100) / (IngestionPipelineStageKeys.length - 1)}
96-
valueBuffer={(progressNextIdx * 100) / (IngestionPipelineStageKeys.length - 1)}
97-
/>
94+
<LinearProgress variant="buffer" value={(progressIdx * 100) / numSteps} valueBuffer={(progressNextIdx * 100) / numSteps} />
9895
)}
9996
{file.error && (
10097
<Typography variant="body2" color="error">
@@ -132,8 +129,8 @@ export const RagIndex: React.FC = () => {
132129

133130
return (
134131
<>
135-
<Typography variant='body1'>RAG index</Typography>
136-
<Typography variant='h3'>{ragDetails?.metadata?.name}</Typography>
132+
<Typography variant="body1">RAG index</Typography>
133+
<Typography variant="h3">{ragDetails?.metadata?.name}</Typography>
137134
<Box py={2}>
138135
<Box sx={{ display: 'flex', gap: 2 }}>
139136
<Button component="label" role={undefined} variant="contained" tabIndex={-1} startIcon={<CloudUpload />} disabled={uploadMutation.isPending}>

src/server/routes/rag.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { ingestionPipeline } from '../services/rag/ingestion/pipeline'
99
import multer from 'multer'
1010
import { mkdir, rm, stat } from 'fs/promises'
1111
import { getOllamaOpenAIClient } from '../util/ollama'
12-
import { Sequelize } from 'sequelize'
1312

1413
const router = Router()
1514

src/server/services/rag/query.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { EMBED_MODEL } from '../../../config'
22
import { RagIndex } from '../../db/models'
33
import { getAzureOpenAIClient } from '../../util/azure'
4+
import { getOllamaOpenAIClient } from '../../util/ollama'
45
import { fullTextSearchChunks, vectorSearchKChunks } from './chunkDb'
56
import { getEmbeddingVector } from './embed'
67

78
const vectorSearch = async (ragIndex: RagIndex, query: string, topK: number) => {
8-
const client = getAzureOpenAIClient(EMBED_MODEL)
9+
const client = getOllamaOpenAIClient()
910
console.time('getEmbedding')
1011
const queryEmbedding = await getEmbeddingVector(client, query)
1112
console.timeEnd('getEmbedding')
@@ -32,7 +33,7 @@ export const queryRagIndex = async (ragIndex: RagIndex, query: string, topK: num
3233
fullTextSearchResult.forEach((doc) => {
3334
const existingDoc = combinedResults.find((d) => d.id === doc.id)
3435
if (!existingDoc) {
35-
const newDoc = doc as (typeof vectorSearchResult)[0]
36+
const newDoc = doc as (typeof vectorSearchResult)[number]
3637
newDoc.value.score = 1.0
3738
combinedResults.push(newDoc)
3839
} else {

0 commit comments

Comments
 (0)