package cn.com.poc.thirdparty.resource.demand.ai.service;

import cn.com.poc.common.utils.JsonUtils;
import cn.com.poc.thirdparty.resource.demand.ai.entity.csvchain.CSVChainResponse;
import cn.com.poc.thirdparty.resource.demand.ai.entity.csvchain.CSVChainResult;
import cn.com.poc.thirdparty.resource.demand.ai.entity.dbchain.DBChainResponse;
import cn.com.poc.thirdparty.resource.demand.ai.entity.dbchain.DBChainResult;
import cn.com.poc.thirdparty.service.ChainService;
import cn.com.yict.framemax.core.spring.SingleContextInitializer;
import com.alibaba.fastjson.JSONObject;
import org.junit.runner.RunWith;
import org.junit.Test;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;

import javax.annotation.Resource;

/**
 * @author alex.yao
 * @date 2025/4/28
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(initializers = SingleContextInitializer.class)
@WebAppConfiguration
public class ChainServiceTest {

    @Resource
    private ChainService chainService;


    @Test
    public void test_dbChain() {

        DBChainResponse response = new DBChainResponse();
        response.setQuestion("查询百度插件详情");
//        response.setPrompt();
//        response.setTableFilters();
        response.setMysqlUser("dmgm_ai_root");
        response.setMysqlPassword("8253f3862ab6");
        response.setMysqlHost("192.168.21.31");
        response.setMysqlPort(3306);
        response.setMysqlDatabase("dgmg_ai_sit");
        DBChainResult dbChainResult = chainService.dbChain(response);
        System.out.println(JSONObject.toJSONString(dbChainResult));

    }

    @Test
    public void test_csvChain() {
        CSVChainResponse csvChainResponse = new CSVChainResponse();
        csvChainResponse.setQuestion("张家市口的所有地区经纬度");
        csvChainResponse.setContext("");
        csvChainResponse.setFilePath("https://gsst-poe-sit.gz.bcebos.com/v1/weather_district_id.csv");
        csvChainResponse.setApiKey("sk-bNzgFwFtw3k4jR7CE3575a19C3304a53Bb803cCeDeC154F2");

        CSVChainResult csvChainResult = chainService.csvChain(csvChainResponse);
        System.out.println(JsonUtils.serialize(csvChainResult));

    }

}
