#include "unified_agent.h"
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
using namespace unified;
int main() {
UnifiedAgent agent;
std::cout << "=== Unified Agent ===\n";
std::cout << "直接输入内容,自动识别模式: trade / chat / code\n";
std::cout << "输入 'quit' 退出, 'save' 保存\n\n";
std::string line;
while (true) {
std::cout << "> ";
if (!std::getline(std::cin, line)) break;
if (line == "quit" || line == "exit") break;
if (line == "save") {
agent.save();
std::cout << "[saved]\n";
continue;
}
std::vector<double> market(20, 0);
for (int i = 0; i < 20; i++) market[i] = 100.0 + 0.5 * i;
auto action = agent.act(line, market);
switch (action.type) {
case Action::TRADE:
std::cout << "[TRADE] signal=" << action.trade_signal
<< " size=" << action.position_size << "\n";
break;
case Action::CHAT:
std::cout << "[CHAT] " << action.chat_text << "\n";
break;
case Action::CODE:
std::cout << "[CODE] language=" << action.code_language << "\n";
std::cout << action.code_text << "\n";
break;
case Action::WAIT:
std::cout << "[WAIT]\n";
break;
}
std::cout << "反馈 (-1/0/1, 回车跳过): ";
std::string fb;
std::getline(std::cin, fb);
if (fb == "1" || fb == "-1" || fb == "0") {
agent.feedback(std::stod(fb));
std::cout << "[learned]\n";
}
}
agent.save();
std::cout << "bye\n";
return 0;
}