feat: wire TradingGraph to use settings for model, temperature, and risk config
This commit is contained in:
+6
-8
@@ -2,8 +2,7 @@ import pkg from "bullmq";
|
||||
const { Queue, Worker } = pkg as any;
|
||||
import IORedis from "ioredis";
|
||||
import { fetchAccount, fetchRecentCloses } from "./alpacaClient";
|
||||
import { OpenRouterClient } from "./openrouter";
|
||||
import { TradingGraph } from "../agents/tradingGraph";
|
||||
import { buildTradingGraph, getTradingConfig } from "./tradingConfig.server";
|
||||
import { db } from "./db.server";
|
||||
|
||||
const REDIS_URL = process.env.REDIS_URL;
|
||||
@@ -41,8 +40,8 @@ if (REDIS_URL) {
|
||||
return mockDecision;
|
||||
}
|
||||
|
||||
const client = new OpenRouterClient(apiKey);
|
||||
const graph = new TradingGraph(client);
|
||||
const { graph, config } = await buildTradingGraph(apiKey);
|
||||
console.log("[queue] Trading config:", config);
|
||||
// Fetch latest Alpaca account and prices; abort job if unavailable so work runs on fresh data
|
||||
try {
|
||||
const account = await fetchAccount();
|
||||
@@ -64,7 +63,7 @@ if (REDIS_URL) {
|
||||
decision = enrichExecutionPlan(decision, input);
|
||||
if (process.env.OPENROUTER_API_KEY) {
|
||||
try {
|
||||
decision = await verifyExecutionPlanWithLLM(decision, input);
|
||||
decision = await verifyExecutionPlanWithLLM(decision, input, config.model);
|
||||
} catch (e) {
|
||||
console.warn("[queue] LLM verification failed:", e);
|
||||
}
|
||||
@@ -191,8 +190,7 @@ if (REDIS_URL) {
|
||||
});
|
||||
continue;
|
||||
}
|
||||
const client = new OpenRouterClient(process.env.OPENROUTER_API_KEY as string);
|
||||
const graph = new TradingGraph(client);
|
||||
const { graph, config } = await buildTradingGraph(process.env.OPENROUTER_API_KEY as string);
|
||||
// Fetch latest Alpaca account and prices; abort job if unavailable so work runs on fresh data
|
||||
try {
|
||||
const account = await fetchAccount();
|
||||
@@ -215,7 +213,7 @@ if (REDIS_URL) {
|
||||
decision = enrichExecutionPlan(decision, job.input);
|
||||
if (process.env.OPENROUTER_API_KEY) {
|
||||
try {
|
||||
decision = await verifyExecutionPlanWithLLM(decision, job.input);
|
||||
decision = await verifyExecutionPlanWithLLM(decision, job.input, config.model);
|
||||
} catch (e) {
|
||||
console.warn("[inproc queue] LLM verification failed:", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user