package com.ch.jedge.jbot.knbase;

import com.alibaba.fastjson.JSONArray;
import com.ch.jedge.jbot.agent.JedgeGdeSession;
import com.ch.jedge.jbot.knbase.intent.JedgeGdeQuery;
import com.ch.jedge.jbot.knbase.query.JedgeGptQueryIntent;
import com.ch.jedge.jbot.session.JedgeServiceSession;
import com.changhong.qlib.util.StringUtils;

public class JedgeLlmIntent {
    protected final String intentKey;
    protected final JedgeGptApp mGdeApp;
    protected final JedgeServiceSession gptSession;

    public JedgeLlmIntent(JedgeGptApp app, JedgeServiceSession s, String key) {
        this.mGdeApp = app;
        this.gptSession = s;
        this.intentKey = key;
    }

    public static JedgeLlmIntent makeQueryIntent(JedgeGptApp app, JedgeServiceSession s) {
        return new JedgeGptQueryIntent(app, s, "query");
    }

    public boolean isValid() {
        return StringUtils.isValidStr(intentKey);
    }

    public String getIntentKey() {
        return intentKey;
    }

    public boolean isQueryIntent() {
        return "query".equals(intentKey);
    }

    public JSONArray getGptHistory() {
        return gptSession.history_;
    }

    protected String getQueryPrompt(JedgeGdeQuery gs) {
        return gs.query_;
    }

    public boolean call(JedgeGdeSession gs, JedgeGdeQuery gdeQuery) {
        if(JedgeGptApp.isDebugMode())
            mGdeApp.getMgModule().exMarkLog(String.format("GdeQuery >> %s", gdeQuery.query_));
        return true;
    }

}
