codebase-index.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { z } from "zod"
  2. /**
  3. * Codebase Index Constants
  4. */
  5. export const CODEBASE_INDEX_DEFAULTS = {
  6. MIN_SEARCH_RESULTS: 10,
  7. MAX_SEARCH_RESULTS: 200,
  8. DEFAULT_SEARCH_RESULTS: 50,
  9. SEARCH_RESULTS_STEP: 10,
  10. MIN_SEARCH_SCORE: 0,
  11. MAX_SEARCH_SCORE: 1,
  12. DEFAULT_SEARCH_MIN_SCORE: 0.4,
  13. SEARCH_SCORE_STEP: 0.05,
  14. } as const
  15. /**
  16. * CodebaseIndexConfig
  17. */
  18. export const codebaseIndexConfigSchema = z.object({
  19. codebaseIndexEnabled: z.boolean().optional(),
  20. codebaseIndexQdrantUrl: z.string().optional(),
  21. codebaseIndexEmbedderProvider: z.enum(["openai", "ollama", "openai-compatible", "gemini"]).optional(),
  22. codebaseIndexEmbedderBaseUrl: z.string().optional(),
  23. codebaseIndexEmbedderModelId: z.string().optional(),
  24. codebaseIndexSearchMinScore: z.number().min(0).max(1).optional(),
  25. codebaseIndexSearchMaxResults: z
  26. .number()
  27. .min(CODEBASE_INDEX_DEFAULTS.MIN_SEARCH_RESULTS)
  28. .max(CODEBASE_INDEX_DEFAULTS.MAX_SEARCH_RESULTS)
  29. .optional(),
  30. })
  31. export type CodebaseIndexConfig = z.infer<typeof codebaseIndexConfigSchema>
  32. /**
  33. * CodebaseIndexModels
  34. */
  35. export const codebaseIndexModelsSchema = z.object({
  36. openai: z.record(z.string(), z.object({ dimension: z.number() })).optional(),
  37. ollama: z.record(z.string(), z.object({ dimension: z.number() })).optional(),
  38. "openai-compatible": z.record(z.string(), z.object({ dimension: z.number() })).optional(),
  39. gemini: z.record(z.string(), z.object({ dimension: z.number() })).optional(),
  40. })
  41. export type CodebaseIndexModels = z.infer<typeof codebaseIndexModelsSchema>
  42. /**
  43. * CdebaseIndexProvider
  44. */
  45. export const codebaseIndexProviderSchema = z.object({
  46. codeIndexOpenAiKey: z.string().optional(),
  47. codeIndexQdrantApiKey: z.string().optional(),
  48. codebaseIndexOpenAiCompatibleBaseUrl: z.string().optional(),
  49. codebaseIndexOpenAiCompatibleApiKey: z.string().optional(),
  50. codebaseIndexOpenAiCompatibleModelDimension: z.number().optional(),
  51. codebaseIndexGeminiApiKey: z.string().optional(),
  52. })
  53. export type CodebaseIndexProvider = z.infer<typeof codebaseIndexProviderSchema>