feat: implement QuestionBank CRUD with pagination and template query
- Add pagination support to findAll (page, limit query params) - Add findByTemplateId method to service - Add GET /by-template/:templateId endpoint to controller - Service already includes CRUD for QuestionBank and QuestionBankItem
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
export interface RagSearchResult {
|
||||
content: string;
|
||||
fileName: string;
|
||||
score: number;
|
||||
chunkIndex: number;
|
||||
}
|
||||
|
||||
export interface RagResponse {
|
||||
searchResults: RagSearchResult[];
|
||||
sources: string[];
|
||||
ragPrompt: string;
|
||||
hasRelevantContent: boolean;
|
||||
}
|
||||
|
||||
export const ragService = {
|
||||
|
||||
async search(query: string, settings: any, authToken: string): Promise<RagResponse> {
|
||||
try {
|
||||
const response = await fetch('/api/knowledge-bases/rag-search', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${authToken}`,
|
||||
},
|
||||
body: JSON.stringify({ query, settings }),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.text();
|
||||
console.error('RAG search error:', response.status, errorData);
|
||||
throw new Error(`RAG search failed: ${response.status} - ${errorData}`);
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error('RAG service error:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user