35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { settingsService } from "./settings.server";
|
|
import { OpenRouterClient } from "./openrouter";
|
|
import { TradingGraph } from "../agents/tradingGraph";
|
|
|
|
export interface TradingConfig {
|
|
model: string;
|
|
temperature: number;
|
|
maxDebateRounds: number;
|
|
}
|
|
|
|
const DEFAULT_CONFIG: TradingConfig = {
|
|
model: "openai/gpt-oss-120b:free",
|
|
temperature: 0.7,
|
|
maxDebateRounds: 3,
|
|
};
|
|
|
|
export async function getTradingConfig(): Promise<TradingConfig> {
|
|
try {
|
|
await settingsService.init();
|
|
const model = (await settingsService.get("llm.model")) ?? DEFAULT_CONFIG.model;
|
|
const temperature = (await settingsService.get("llm.temperature")) ?? DEFAULT_CONFIG.temperature;
|
|
const maxDebateRounds = (await settingsService.get("llm.maxDebateRounds")) ?? DEFAULT_CONFIG.maxDebateRounds;
|
|
return { model, temperature, maxDebateRounds };
|
|
} catch {
|
|
return DEFAULT_CONFIG;
|
|
}
|
|
}
|
|
|
|
export async function buildTradingGraph(apiKey: string): Promise<{ graph: TradingGraph; client: OpenRouterClient; config: TradingConfig }> {
|
|
const config = await getTradingConfig();
|
|
const client = new OpenRouterClient(apiKey, { defaultModel: config.model });
|
|
const graph = new TradingGraph(client, config.model);
|
|
return { graph, client, config };
|
|
}
|