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

import cn.com.poc.common.utils.JsonUtils;
import cn.com.poc.thirdparty.resource.demand.ai.aggregate.MD2WordService;
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.resource.demand.ai.entity.md2word.Md2WordResponse;
import cn.com.poc.thirdparty.resource.demand.ai.entity.md2word.Md2WordResult;
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;

    @Resource
    private MD2WordService md2WordService;

    @Test
    public void test_md2Word() {
        Md2WordResponse response = new Md2WordResponse();
        response.setFilePath("https://gsst-poe-sit.gz.bcebos.com/v1/software-copyright/%E6%8A%80%E6%9C%AF%E6%9E%B6%E6%9E%84.md");
        Md2WordResult md2WordResult = md2WordService.md2Word(response);
        System.out.println(md2WordResult.getFilePath());
    }


    @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));

    }

}
