Implement dual-model filing pipeline with Ollama extraction
This commit is contained in:
52
lib/server/api/filing-redaction.test.ts
Normal file
52
lib/server/api/filing-redaction.test.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { describe, expect, it } from 'bun:test';
|
||||
import type { Filing } from '@/lib/types';
|
||||
import { redactInternalFilingAnalysisFields } from './filing-redaction';
|
||||
|
||||
function filingWithExtraction(): Filing {
|
||||
return {
|
||||
id: 7,
|
||||
ticker: 'MSFT',
|
||||
filing_type: '10-K',
|
||||
filing_date: '2026-02-01',
|
||||
accession_number: '0000789019-26-000001',
|
||||
cik: '0000789019',
|
||||
company_name: 'Microsoft Corporation',
|
||||
filing_url: 'https://www.sec.gov/Archives/edgar/data/789019/000078901926000001/a10k.htm',
|
||||
submission_url: null,
|
||||
primary_document: 'a10k.htm',
|
||||
metrics: null,
|
||||
analysis: {
|
||||
provider: 'zhipu',
|
||||
model: 'glm-4.7-flashx',
|
||||
text: 'Report text',
|
||||
extraction: {
|
||||
summary: 'Internal extraction summary',
|
||||
keyPoints: ['a'],
|
||||
redFlags: ['b'],
|
||||
followUpQuestions: ['c'],
|
||||
portfolioSignals: ['d'],
|
||||
confidence: 0.4
|
||||
},
|
||||
extractionMeta: {
|
||||
provider: 'ollama',
|
||||
model: 'qwen3:8b',
|
||||
source: 'primary_document',
|
||||
generatedAt: '2026-02-01T00:00:00.000Z'
|
||||
}
|
||||
},
|
||||
created_at: '2026-02-01T00:00:00.000Z',
|
||||
updated_at: '2026-02-01T00:00:00.000Z'
|
||||
};
|
||||
}
|
||||
|
||||
describe('filing response redaction', () => {
|
||||
it('removes internal extraction fields while preserving public analysis fields', () => {
|
||||
const redacted = redactInternalFilingAnalysisFields(filingWithExtraction());
|
||||
|
||||
expect(redacted.analysis?.provider).toBe('zhipu');
|
||||
expect(redacted.analysis?.model).toBe('glm-4.7-flashx');
|
||||
expect(redacted.analysis?.text).toBe('Report text');
|
||||
expect(redacted.analysis?.extraction).toBeUndefined();
|
||||
expect(redacted.analysis?.extractionMeta).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user