Skip to content

Commit a1b289a

Browse files
committed
fix: removing dead code after deleting v1 route
1 parent 76b6239 commit a1b289a

File tree

7 files changed

+12
-182
lines changed

7 files changed

+12
-182
lines changed

package-lock.json

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@
9191
"@tanstack/react-query-devtools": "^5.81.2",
9292
"axios": "^1.6.8",
9393
"bullmq": "^5.58.0",
94-
"chromadb": "^3.0.12",
9594
"cors": "^2.8.5",
9695
"date-fns": "^4.0.0",
9796
"dotenv": "^16.4.1",

src/server/routes/ai/types.ts

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,10 @@
11
import z from 'zod/v4'
22

3-
export const MessageSchema = z.object({
4-
role: z.enum(['system', 'user', 'assistant']),
5-
content: z.string().min(0).max(400_000),
6-
})
7-
8-
export const ChatMessageSchema = z.object({
3+
const ChatMessageSchema = z.object({
94
role: z.enum(['user', 'assistant']),
105
content: z.string().min(0).max(400_000),
116
})
127

13-
export type MessageType = z.infer<typeof MessageSchema>
14-
15-
export const PostStreamSchemaV2 = z.object({
16-
options: z.object({
17-
model: z.string(),
18-
assistantInstructions: z.string().optional(),
19-
messages: z.array(MessageSchema),
20-
userConsent: z.boolean().optional(),
21-
modelTemperature: z.number().min(0).max(2),
22-
saveConsent: z.boolean().optional(),
23-
prevResponseId: z.string().optional(),
24-
courseId: z.string().optional(),
25-
ragIndexId: z.number().optional().nullable(),
26-
}),
27-
courseId: z.string().optional(),
28-
})
29-
308
export const PostStreamSchemaV3 = z.object({
319
options: z.object({
3210
model: z.string(),
@@ -41,5 +19,3 @@ export const PostStreamSchemaV3 = z.object({
4119
}),
4220
courseId: z.string().optional(),
4321
})
44-
45-
export type PostStreamBody = z.infer<typeof PostStreamSchemaV2>

src/server/routes/testUtils.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { getTestUserHeaders, TEST_COURSES } from '../../shared/testData'
44
import { ChatInstanceRagIndex, Enrolment, Prompt, RagIndex, Responsibility, User, UserChatInstanceUsage } from '../db/models'
55
import { headersToUser } from '../middleware/user'
66
import { ApplicationError } from '../util/ApplicationError'
7-
import { getCompletionEvents } from '../util/oldAzureClient'
87
import logger from '../util/logger'
98
import { Op } from 'sequelize'
109

@@ -109,29 +108,4 @@ router.post('/reset-test-data', async (req, res) => {
109108
res.status(200).json({ message: 'Test data reset successfully' })
110109
})
111110

112-
router.post('/completions-api', async (req, res) => {
113-
console.log('Starting Completions API')
114-
115-
const result = await getCompletionEvents({
116-
messages: [
117-
{
118-
role: 'user',
119-
// @ts-expect-error whatever
120-
content: 'Hello!, please explain the concept of artificial intelligence.',
121-
},
122-
],
123-
model: 'gpt-5',
124-
options: {
125-
temperature: 0.9,
126-
},
127-
})
128-
129-
// @ts-expect-error whatever
130-
for await (const chunk of result) {
131-
console.log('Completions API chunk:', chunk)
132-
}
133-
134-
console.log('Completions API result:', result)
135-
})
136-
137111
export default router

src/server/routes/user.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { accessIams } from '../util/config'
1111
import { ApplicationError } from '../util/ApplicationError'
1212
import { UserPreferencesSchema } from '../../shared/user'
1313

14-
export const checkIamAccess = (iamGroups: string[]) => accessIams.some((iam) => iamGroups.includes(iam))
14+
const checkIamAccess = (iamGroups: string[]) => accessIams.some((iam) => iamGroups.includes(iam))
1515

1616
const isNowOrInFuture = ({ chatInstance }: { chatInstance: ChatInstance }) =>
1717
chatInstance.usageLimit > 0 && new Date() <= new Date(chatInstance.activityPeriod.endDate)
@@ -44,7 +44,7 @@ userRouter.get('/login', async (req, res) => {
4444
// When acual user logs in, update the users info.
4545
if (!request.hijackedBy) {
4646
user.lastLoggedInAt = new Date()
47-
;[dbUser] = await User.upsert(user)
47+
;[dbUser] = await User.upsert(user)
4848
} else {
4949
dbUser = await User.findByPk(id)
5050

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,7 @@
1-
import { Chroma } from '@langchain/community/vectorstores/chroma'
21
import { RedisVectorStore } from '@langchain/redis'
3-
import { ChromaClient, type EmbeddingFunction } from 'chromadb'
4-
import { CHROMADB_URL } from '../../util/config'
52
import { redisClient } from '../../util/redis'
63
import { getEmbedder } from './embedder'
74

8-
// We specify ChromaClient ourself here instead of letting LC do it, so we can manage collections etc without LC bugs in our way.
9-
export const chromaClient = new ChromaClient({ path: CHROMADB_URL })
10-
11-
export const ensureChromaCollection = async (name: string) => {
12-
const collection = await chromaClient.getOrCreateCollection({
13-
name,
14-
embeddingFunction: new DummyChromaEmbeddingFunction(),
15-
// Could specify configuration here if needed, see chroma docs.
16-
// configuration: {
17-
// ...
18-
// }
19-
})
20-
return collection
21-
}
22-
23-
export const getChromaVectorStore = (ragIndexId: number) => {
24-
return new Chroma(getEmbedder(), {
25-
collectionName: String(ragIndexId),
26-
index: chromaClient,
27-
url: CHROMADB_URL,
28-
})
29-
}
30-
315
export const getRedisVectorStore = (ragIndexId: number, language?: string) => {
326
return new RedisVectorStore(getEmbedder(), {
337
// @ts-expect-error something wrong with typing, but it should actually match the signature.
@@ -39,9 +13,3 @@ export const getRedisVectorStore = (ragIndexId: number, language?: string) => {
3913
},
4014
})
4115
}
42-
43-
class DummyChromaEmbeddingFunction implements EmbeddingFunction {
44-
public async generate(): Promise<number[][]> {
45-
return []
46-
}
47-
}

src/server/util/oldAzureClient.ts

Lines changed: 0 additions & 95 deletions
This file was deleted.

0 commit comments

Comments
 (0)