国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Spring boot +React集成ChatGPT 智能AI

這篇具有很好參考價值的文章主要介紹了Spring boot +React集成ChatGPT 智能AI。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

在這里插入代碼片import {Button, Input, Radio,Alert,Modal  } from 'antd';
import Marquee from 'react-fast-marquee';
import {ChromeOutlined,WifiOutlined,AimOutlined } from '@ant-design/icons';
import React, {useEffect, useState, useRef} from 'react';
import chatgptPng from '../../static/icon/chatgpt.png'
import meJpg from '../../static/icon/me.jpg'
import './openai.css'
import {sendMsgApi} from "../../services/openai/openaiService";

export default function OpenAi() {

    const [isButtonDisabled, setIsButtonDisabled] = useState(false);
    const [countdown, setCountdown] = useState(20);
    const containerRef = useRef(null);
    const [inputValue, setInputValue] = useState('');
    const [value, setValue] = useState(1);
    const [imgUrl, setImgUrl] = useState("");
    // 聊天數(shù)據(jù)
    const [chatList, setChatList] = useState([
        {
            headImg: require('../../static/icon/chatgpt.png'),
            name: 'ChatGPT',
            time: new Date().toLocaleTimeString(),
            msg: ' 您好,詩繡智能AI助手為您服務(wù)。',
            chatType: 0,
            uid: '1002',
            type: 1
        }
    ])

    const [isModalOpen, setIsModalOpen] = useState(false);
    const showModal = (url) => {
        setImgUrl("")
        setImgUrl(url)
        setIsModalOpen(true);
    };
    const handleOk = () => {
        setIsModalOpen(false);
    };
    const handleCancel = () => {
        setIsModalOpen(false);
    };

    const onChange = (e) => {
        setValue(e.target.value);
    };
    useEffect(() => {
        if (isButtonDisabled) {
            const timer = setInterval(() => {
                setCountdown(prevCountdown => prevCountdown - 1);
            }, 1000);

            setTimeout(() => {
                setIsButtonDisabled(false);
                setCountdown(20);
                clearInterval(timer);
            }, 20000);

            return () => {
                clearInterval(timer);
            };
        }
    }, [isButtonDisabled]);

    const handleInputChange = (event) => {
        setInputValue(event.target.value);
    };

    const send = () => {
        if (inputValue.trim() === '') {
            alert('輸入框不能為空');
            return;
        }
        setIsButtonDisabled(true);
        const obj = {
            headImg: require('../../static/icon/chatgpt.png'),
            name: '初出茅廬',
            time: new Date().toLocaleTimeString(),
            msg: inputValue,
            chatType: 0,
            uid: '1001'
        }
        let news = chatList.concat(obj)
        setChatList(news)
        setInputValue('')
        sendMsgApi({type: value, question: inputValue}).then((res) => {
            if (res.status_code === 200) {
                const item = {
                    headImg: require('../../static/icon/chatgpt.png'),
                    name: 'ChatGPT',
                    time: new Date().toLocaleTimeString(),
                    msg: res.data,
                    chatType: 0,
                    uid: '1002',
                    type: value === 1 ? 1 : 2
                }
                let concat = news.concat(item);
                setChatList(concat)
                setTimeout(() => {
                    containerRef.current.scrollTop = containerRef.current.scrollHeight;
                }, 0);
            }
        })
        setTimeout(() => {
            containerRef.current.scrollTop = containerRef.current.scrollHeight;
        }, 0);
    }
    return (
        <div className="chatHome">
            <div className="chatLeft">
                <p className="chat-title"><ChromeOutlined   spin /> 詩繡智能AI助手</p>
                <div className="openai-type-class">
                    <p className="tool-a-title"><AimOutlined spin /> AI助手模式切換</p>
                    <Radio.Group onChange={onChange} value={value} style={{ display: 'grid', gridTemplateColumns: 'auto auto' }}>
                        <Radio value={1} style={{ color: 'cornflowerblue' }}>聊天模式</Radio>
                        <Radio value={2} style={{ color: 'cornflowerblue' }}>圖片模式</Radio>
                    </Radio.Group>
                </div>
                <p className="tool-a-title"><AimOutlined spin /> 詩繡工具推薦</p>
                <div className="div-tools">
                    <Button className="tools-button" type="primary" onClick={()=>showModal("https://file.tlzcf.vip/img.png")}>
                        詩繡IMG庫
                    </Button>
                    <Button className="tools-button" type="primary" onClick={()=>showModal("https://file.tlzcf.vip/gjx.png")}>
                        詩繡工具箱
                    </Button>
                    <Button className="tools-button" type="primary" onClick={()=>showModal("https://file.tlzcf.vip/zl.png")}>
                        王者戰(zhàn)力助手
                    </Button>
                    <Button className="tools-button" type="primary" onClick={()=>showModal("https://file.tlzcf.vip/wk.png")}>
                        網(wǎng)課答案助手
                    </Button>
                    <Button className="tools-button" type="primary" onClick={()=>showModal("https://file.tlzcf.vip/ssssss.png")}>
                        詩繡壁紙公眾號
                    </Button>
                       <a className="tools-a" target="_blank" > 詩繡壁紙網(wǎng)入口 </a>
                </div>
                <div className="chat-auth">
                    <p>今日訪問次數(shù)為:無限</p>
                    <p>當(dāng)前有效時間為:長期</p>
                    <div className="chat-kami">
                        <Input className="chat-kami-left" placeholder="請輸入授權(quán)卡密"/>
                        <Button className="chat-kami-right">驗證</Button>
                    </div>
                </div>
            </div>
            <div className="chatRight">
                <p className="chatgpt-title"><img className="chatgpt-png" src={chatgptPng}/> <span
                    className="chatgpt-title-span">Welcome ChatGPT</span></p>
                <div className="chatRight-conent">
                    <div className="chat-conent-text" ref={containerRef}>
                        {chatList && chatList.map(item => (
                                <div className="chat-conent-item">
                                    {item.uid === '1001' &&
                                    <div className="chat-item-right">
                                        <div className="chat-title-item-conent-right">
                                            <div className="chat-title-name-right">
                                                <span>{item.name}</span>
                                                &nbsp;
                                                <span className="chat-title-time">{item.time}</span>
                                            </div>
                                            <img className="chat-title-item-img-right" src={meJpg}/>
                                        </div>
                                        <div className="chat-item-conent-txt-right">
                                            {item.msg}
                                        </div>
                                    </div>
                                    }
                                    {item.uid === '1002' &&
                                    <div className="chat-item-left">
                                        <div className="chat-title-item-conent-left">
                                            <img className="chat-title-item-img-left" src={chatgptPng}/>
                                            <div className="chat-title-name-left">
                                                <span>{item.name}</span>
                                                &nbsp;
                                                <span className="chat-title-time">{item.time}</span>
                                            </div>
                                        </div>
                                        <div className="chat-item-conent-txt-left">
                                            {item.type === 1 && <span dangerouslySetInnerHTML={{__html:item.msg}}></span>}
                                            {item.type === 2 && <img className="item-chatImg" src={item.msg}/>}
                                        </div>
                                    </div>
                                    }
                                </div>
                            )
                        )
                        }
                    </div>
                    <div className="chat-div-button">
                        <Input className="chat-input" value={inputValue} onChange={handleInputChange}/>
                        <Button onClick={() => send()} disabled={isButtonDisabled}
                                className="chat-button">{isButtonDisabled ? `請等待${countdown}秒` : '點擊按鈕'}</Button>
                    </div>
                    <Alert
                        className="item-alert"
                        banner
                        type="info"
                        icon={<WifiOutlined/>}
                        message={
                            <Marquee speed={60} pauseOnHover gradient={false}>
                                離開家鄉(xiāng)以前我以為我想要的是雄心壯志和鵬程萬里,后來才發(fā)現(xiàn),我們不斷追逐的也不過是飽餐一頓和一個不被鬧鐘吵醒的清晨。
                            </Marquee>
                        }
                    />
                </div>
            </div>
            <Modal title="工具詳情" open={isModalOpen} onOk={handleOk} onCancel={handleCancel}  footer={null}>
                <img className="img-tools" src={imgUrl}/>
            </Modal>
        </div>

    )
}

線上體驗地址:http://tlzcf.vip:8679/

Spring boot +React集成ChatGPT 智能AI,spring boot,react.js,chatgpt文章來源地址http://www.zghlxwxcb.cn/news/detail-522403.html

到了這里,關(guān)于Spring boot +React集成ChatGPT 智能AI的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • Spring boot 集成單元測試

    Spring boot 集成單元測試

    1.引入依賴 2. ?3.編寫測試類

    2024年02月11日
    瀏覽(22)
  • Spring Boot 集成Minio

    Spring Boot 集成Minio

    1、docker創(chuàng)建minio容器 (1)Dockerfile文件? (2) 創(chuàng)建鏡像 (3)創(chuàng)建容器 ?訪問minio管理后臺?http://192.168.81.200:8341/login ?賬號密碼? masterminio /? mastermminio 2、Spring Boot 集成minio (1) pom加入minio依賴 (2)yml文件加入配置 (3) 后端代碼編寫 ? ?鏈接配置 ?上傳文件工具類 ?上傳接口開發(fā)

    2024年02月12日
    瀏覽(37)
  • Spring Boot集成ES

    POM依賴 配置文件 示例代碼

    2024年02月11日
    瀏覽(18)
  • Spring boot集成RabbitMq

    Spring boot集成RabbitMq

    RabbitMQ教程 輸入erl,可以看到輸出 cmd 打開 C:Program FilesRabbitMQ Serverrabbitmq_server-3.8.0sbin, 輸入:rabbitmq-plugins enable rabbitmq_management 出現(xiàn): 瀏覽器輸入:localhost:15672 賬號和密碼都是guest 配置文件中的端口號不能是15672 配置文件: 查看當(dāng)前的遠程庫 將xxx遠程庫簡單命名origin,并且

    2024年02月10日
    瀏覽(12)
  • Spring Boot 集成Seata

    Spring Boot 集成Seata

    Seata的集成方式有: 1. Seata-All 2. Seata-Spring-Boot-Starter 3. Spring-Cloud-Starter-Seata 本案例使用Seata-Spring-Boot-Starter演示: 第一步:下載Seata 第二步:為了更好看到效果,我們將Seata的數(shù)據(jù)存儲改為db 將seatascriptserverdbmysql.sql語句在mysql中執(zhí)行,創(chuàng)建相關(guān)表 ? 然后修改seata配置文件,

    2024年02月14日
    瀏覽(14)
  • Spring Boot 集成 ElasticSearch

    Spring Boot 集成 ElasticSearch

    首先創(chuàng)建一個項目,在項目中加入 ES 相關(guān)依賴,具體依賴如下所示: 在配置文件 application.properties 中配置 ES 的相關(guān)參數(shù),具體內(nèi)容如下: 其中指定了 ES 的 host 和端口以及超時時間的設(shè)置,另外我們的 ES 沒有添加任何的安全認(rèn)證,因此 username 和 password 就沒有設(shè)置。 然后在

    2024年02月03日
    瀏覽(24)
  • Spring Boot集成etcd

    etcd是一個分布式鍵值存儲數(shù)據(jù)庫,用于共享配置和服務(wù)發(fā)現(xiàn)。 它是由CoreOS團隊開發(fā)并開源的,具備以下特點:簡單、安全、高性能、一致可靠等 。etcd采用Go語言編寫,具有出色的跨平臺支持,很小的二進制文件和強大的社區(qū)。etcd機器之間的通信通過Raft算法處理。 Spring Bo

    2024年02月11日
    瀏覽(10)
  • spring boot 集成rocketmq

    在現(xiàn)代的微服務(wù)架構(gòu)中,消息隊列已經(jīng)成為一種常見的異步處理模式,它能解決服務(wù)間的同步調(diào)用、耦合度高、流量高峰等問題。RocketMQ是阿里巴巴開源的一款消息中間件,性能優(yōu)秀,功能齊全,被廣泛應(yīng)用在各種業(yè)務(wù)場景。 本文將詳細(xì)介紹如何在Spring Boot項目中集成RocketM

    2024年02月14日
    瀏覽(17)
  • Spring Boot集成ElasticsearchRepository

    在上文springboot操作elasticsearch(簡易版)中,我們使用了elasticsearchRestTemplate操作索引及數(shù)據(jù),本文主要是介紹elasic媲美數(shù)據(jù)庫連接框架hibernate的數(shù)倉ElasticsearchRepository 在本文中,我們將介紹如何使用Spring Boot集成ElasticsearchRepository,并對ElasticsearchRepository類進行深度剖析。首先,

    2024年02月16日
    瀏覽(26)
  • Spring Boot進階(67):高性能緩存!使用Spring Boot輕松集成Memcached。

    Spring Boot進階(67):高性能緩存!使用Spring Boot輕松集成Memcached。

    ????????Memcached是一款高性能的分布式內(nèi)存對象緩存系統(tǒng),主要用于動態(tài)Web應(yīng)用中減輕數(shù)據(jù)庫負(fù)載。Spring Boot是一款基于Spring框架的快速開發(fā)框架,集成了大量的常用技術(shù)和組件,方便開發(fā)者快速搭建項目。將兩者結(jié)合起來,可以提高Web應(yīng)用的性能,并減少數(shù)據(jù)庫的壓力。

    2024年02月07日
    瀏覽(30)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包