fix bruno collection
This commit is contained in:
@@ -4,15 +4,10 @@ import { CatalystCache, CatalystAnalyst } from '../../domains/shared';
|
||||
import { analyzeSchema } from '../../domains/shared/types/schemas';
|
||||
|
||||
export class AnalyzeController {
|
||||
private readonly catalystAnalyst: CatalystAnalyst;
|
||||
|
||||
constructor(
|
||||
private readonly catalystCache: CatalystCache,
|
||||
private readonly llm: LLMAnalyst,
|
||||
) {
|
||||
// Create a fresh instance for per-ticker story fetching (not cached)
|
||||
this.catalystAnalyst = new CatalystAnalyst();
|
||||
}
|
||||
) {}
|
||||
|
||||
register(app: FastifyInstance): void {
|
||||
app.post(
|
||||
@@ -27,13 +22,22 @@ export class AnalyzeController {
|
||||
return reply.code(400).send({ error: 'ANTHROPIC_API_KEY is not set in .env' });
|
||||
}
|
||||
|
||||
const tickers = (req.body as { tickers: string[] }).tickers.map((t) => t.toUpperCase());
|
||||
const requestedTickers = (req.body as { tickers: string[] }).tickers.map((t) =>
|
||||
t.toUpperCase(),
|
||||
);
|
||||
|
||||
// Use cached catalyst data (refreshed every 15 minutes)
|
||||
const { stories: allStories } = await this.catalystCache.get();
|
||||
|
||||
// Filter stories to only those matching requested tickers
|
||||
const stories = allStories.filter((story) =>
|
||||
story.tickers.some((t) => requestedTickers.includes(t)),
|
||||
);
|
||||
|
||||
const stories = await this.catalystAnalyst.fetchStoriesForTickers(tickers);
|
||||
if (!stories.length) return reply.code(200).send({ analysis: null, reason: 'no_stories' });
|
||||
|
||||
const { tickerFrequency } = CatalystAnalyst.rankTickers(stories);
|
||||
const analysis = await this.llm.analyze(stories, tickers, tickerFrequency);
|
||||
const analysis = await this.llm.analyze(stories, requestedTickers, tickerFrequency);
|
||||
return { analysis };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user