|
1 | | -import { basicContractTemplate } from './templates/contractTemplate'; |
2 | | -import { cairoCoderPrompts } from './prompts'; |
3 | | -import { basicTestTemplate } from './templates/testTemplate'; |
4 | 1 | import { VectorStore } from '../db/postgresVectorStore'; |
5 | | -import { DocumentSource, RagSearchConfig } from '../types'; |
| 2 | +import { RagSearchConfig } from '../types'; |
| 3 | +import { getAgent, getDefaultAgent } from './agents'; |
6 | 4 |
|
| 5 | +// Legacy function for backward compatibility |
7 | 6 | export const getAgentConfig = (vectorStore: VectorStore): RagSearchConfig => { |
| 7 | + const agent = getDefaultAgent(); |
8 | 8 | return { |
9 | | - name: 'Cairo Coder', |
10 | | - prompts: cairoCoderPrompts, |
| 9 | + name: agent.name, |
| 10 | + prompts: agent.prompts, |
11 | 11 | vectorStore, |
12 | | - contractTemplate: basicContractTemplate, |
13 | | - testTemplate: basicTestTemplate, |
14 | | - maxSourceCount: 15, |
15 | | - similarityThreshold: 0.4, |
16 | | - sources: [ |
17 | | - DocumentSource.CAIRO_BOOK, |
18 | | - DocumentSource.CAIRO_BY_EXAMPLE, |
19 | | - DocumentSource.STARKNET_FOUNDRY, |
20 | | - DocumentSource.CORELIB_DOCS, |
21 | | - DocumentSource.OPENZEPPELIN_DOCS, |
22 | | - DocumentSource.SCARB_DOCS, |
23 | | - ], |
| 12 | + contractTemplate: agent.templates?.contract, |
| 13 | + testTemplate: agent.templates?.test, |
| 14 | + maxSourceCount: agent.parameters.maxSourceCount, |
| 15 | + similarityThreshold: agent.parameters.similarityThreshold, |
| 16 | + sources: agent.sources, |
| 17 | + }; |
| 18 | +}; |
| 19 | + |
| 20 | +// Get agent configuration by ID |
| 21 | +export const getAgentConfigById = async ( |
| 22 | + agentId: string, |
| 23 | + vectorStore: VectorStore, |
| 24 | +): Promise<RagSearchConfig> => { |
| 25 | + const agentConfig = getAgent(agentId); |
| 26 | + |
| 27 | + if (!agentConfig) { |
| 28 | + throw new Error(`Agent configuration not found: ${agentId}`); |
| 29 | + } |
| 30 | + |
| 31 | + return { |
| 32 | + name: agentConfig.name, |
| 33 | + prompts: agentConfig.prompts, |
| 34 | + vectorStore, |
| 35 | + contractTemplate: agentConfig.templates?.contract, |
| 36 | + testTemplate: agentConfig.templates?.test, |
| 37 | + maxSourceCount: agentConfig.parameters.maxSourceCount, |
| 38 | + similarityThreshold: agentConfig.parameters.similarityThreshold, |
| 39 | + sources: agentConfig.sources, |
24 | 40 | }; |
25 | 41 | }; |
0 commit comments