yangyin
2024-06-30 84b354e6c60464d3c9e71b1e386fbd2deb70e970
fix: 联调主场景
已修改2个文件
179 ■■■■■ 文件已修改
src/api/ai/chat.ts 103 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/project/ch/home/component/waterRight/bottom.vue 76 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/ai/chat.ts
@@ -2,44 +2,43 @@
import { toFormData } from '/@/utils/util';
//#region ====================== knowledge ======================
export interface KnowledgeRes {
    json_ok:     boolean;
    question:    string;
    answer_type: string;
    knowledge:   KnowledgeData[];
    json_ok: boolean;
    question: string;
    answer_type: string;
    knowledge: KnowledgeData[];
}
export interface KnowledgeData {
    answer:   string;
    contexts: Context[];
    answer: string;
    contexts: Context[];
}
export interface Context {
    page_content: string;
    metadata:     Metadata;
    page_content: string;
    metadata: Metadata;
}
export interface Metadata {
    Title?: string;
    Title?: string;
}
//#endregion
//#region ====================== RecordSet ======================
export interface RecordSetRes {
    json_ok:     boolean;
    question:    string;
    answer_type: string;
    values:      RecordSetValues;
    json_ok: boolean;
    question: string;
    answer_type: string;
    values: RecordSetValues;
}
export interface RecordSetValues {
    names:  string[];
    values: Array<Array<any>>;
    type:   string;
    title:  string;
    names: string[];
    values: Array<Array<any>>;
    type: string;
    title: string;
}
//#endregion
@@ -104,46 +103,48 @@
    });
};
/**
 * @summary  获取主场景
 */
export const getSectionList = async (req: any = request) => {
    return req({
        url: '/section/get_section_a_list',
        method: 'POST',
    });
};
/**
 * @summary description
 */
export const CreateHistoryGroup = async (params, req:any = request) => {
  return req({
    url: "/history/create_history_group",
    method: "POST",
    data: params,
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
    },
  });
export const CreateHistoryGroup = async (params, req: any = request) => {
    return req({
        url: '/history/create_history_group',
        method: 'POST',
        data: params,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
        },
    });
};
export const GetHistoryGroups = async (params, req:any = request) => {
export const GetHistoryGroups = async (params, req: any = request) => {
    return req({
      url: "/history/get_history_groups",
      method: "POST",
      data: params,
      headers: {
          'Content-Type': 'application/x-www-form-urlencoded',
      },
        url: '/history/get_history_groups',
        method: 'POST',
        data: params,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
        },
    });
  };
};
export const QueryHistoryGroup = async (params, req:any = request) => {
export const QueryHistoryGroup = async (params, req: any = request) => {
    return req({
      url: "/history/query_history_detail",
      method: "POST",
      data: params,
      headers: {
          'Content-Type': 'application/x-www-form-urlencoded',
      },
        url: '/history/query_history_detail',
        method: 'POST',
        data: params,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
        },
    });
  };
};
src/views/project/ch/home/component/waterRight/bottom.vue
@@ -18,15 +18,15 @@
            <div
                class="main_item flex cursor-pointer"
                v-for="(item, index) in state.applicationScenarios"
                :key="item.ID"
                :class="{ main_item_active: item.ID === state.scenariosIndex }"
                :key="item.section_id"
                :class="{ main_item_active: item.section_id === state.scenariosIndex }"
                @click="changeScenarios(item)"
            >
                <div :class="['iconfont icon-' + item.Icon]"></div>
                <div class="right">
                    <h4>{{ item.Title }}</h4>
                    <p>{{ item.Content }}</p>
                    <h4>{{ item.section_name }}</h4>
                    <p>{{ item.section_title }}</p>
                </div>
            </div>
        </div>
@@ -34,46 +34,64 @@
</template>
<script setup lang="ts">
import { reactive } from 'vue';
import { onMounted, reactive } from 'vue';
import { getSectionList } from '/@/api/ai/chat';
import router from '/@/router';
let state = reactive({
    applicationScenarios: [
        {
            ID: 1,
            Icon: 'biaodan',
            Title: '行业知识库',
            Content: '张三打了李四一巴掌,李四对张三说:"你是不是没吃饭",李四说这句话含义是?',
        },
        {
            ID: 2,
            Icon: 'putong',
            Title: '生产调度',
            Content: '怎么解释努力和内卷的区别?',
        },
        {
            ID: 3,
            Icon: 'zhongduancanshuchaxun',
            Title: '水产生产',
            Content: '请搜索你想知道的问题',
        },
        {
            ID: 4,
            Icon: 'tuichuquanping',
            Title: '管网运行',
            Content: '请以诗经中的典故给男宝宝取名,姓顾,名字要求3个字,给5个名字供我选择。',
        },
        // {
        //     ID: 1,
        //     Icon: 'biaodan',
        //     Title: '行业知识库',
        //     Content: '张三打了李四一巴掌,李四对张三说:"你是不是没吃饭",李四说这句话含义是?',
        // },
        // {
        //     ID: 2,
        //     Icon: 'putong',
        //     Title: '生产调度',
        //     Content: '怎么解释努力和内卷的区别?',
        // },
        // {
        //     ID: 3,
        //     Icon: 'zhongduancanshuchaxun',
        //     Title: '水产生产',
        //     Content: '请搜索你想知道的问题',
        // },
        // {
        //     ID: 4,
        //     Icon: 'tuichuquanping',
        //     Title: '管网运行',
        //     Content: '请以诗经中的典故给男宝宝取名,姓顾,名字要求3个字,给5个名字供我选择。',
        // },
    ],
    scenariosIds: [],
    scenariosIndex: 0,
});
const changeScenarios = (item) => {
    state.scenariosIndex = item.ID;
};
const getMainSectionList = async () => {
    const res = await getSectionList();
    let result = res.sections;
    const iconList = ['biaodan', 'putong', 'zhongduancanshuchaxun', 'shidu'];
    res.sections.forEach((sectionItem, index) => {
        sectionItem.Icon = iconList[index];
    });
    state.applicationScenarios = res.sections;
    console.log('🚀 ~ state.applicationScenarios:', state.applicationScenarios);
    state.scenariosIds = result.map((item) => item.ID);
};
// 查看更多
const lookMore = () => {
    router.push({
        name: 'Scenario',
    });
};
onMounted(() => {
    getMainSectionList();
});
</script>
<style scoped lang="scss">
.pc-scenes {