File size: 1,176 Bytes
b966bc9
 
 
 
 
 
 
 
6b57b99
 
 
 
b966bc9
6b57b99
b966bc9
dcf1188
b966bc9
 
 
6b57b99
b966bc9
 
 
 
6b57b99
 
 
 
 
 
 
 
b966bc9
 
 
6b57b99
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Project      : Python.
# @File         : 991_streamlit_apex_charts
# @Time         : 2022/10/17 上午10:48
# @Author       : yuanjie
# @WeChat       : meutils
# @Software     : PyCharm
# @Description  :
import time
import types

import streamlit as st
from meutils.pipe import *

from appzoo.streamlit_app.utils import reply4input

if __name__ == '__main__':

    previous_messages = ["你好!我是你的电影小助手,很高兴为您服务。", "你可以向我提问。"]

    container = st.container()  # 占位符
    text = st.text_area(label="用户输入", height=100, placeholder="请在这儿输入您的问题")


    def reply_func(query):
        for i in range(10):
            time.sleep(0.5)
            yield query
            query += str(i)


    if st.button("发送", key="predict"):
        with st.spinner("AI正在思考,请稍等........"):
            history = st.session_state.get('state')
            st.session_state["state"] = reply4input(text, history, container=container, reply_func=reply_func,
                                                    previous_messages=previous_messages)