File size: 1,140 Bytes
2a4a811
 
 
 
c9543aa
2a4a811
 
 
 
c9543aa
2a4a811
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cec08c7
c9543aa
a32f065
cec08c7
2a4a811
 
cec08c7
 
2a4a811
 
 
c9543aa
2a4a811
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
39
40
41
42
43
44
45
import logging
import sys

import streamlit as st
from dotenv import load_dotenv

from xpipe_wiki.manager_factory import XPipeRobotManagerFactory, XPipeRobotRevision

logging.basicConfig(
    stream=sys.stdout, level=logging.INFO
)  # logging.DEBUG for more verbose output
logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))

# Sidebar contents
with st.sidebar:
    st.title("🤗💬 LLM Chat App")
    st.markdown(
        """
    ## About
    This app is an LLM-powered chatbot built using:
    - [Streamlit](https://streamlit.io/)
    - [LangChain](https://python.langchain.com/)
    - [X-Pipe](https://github.com/ctripcorp/x-pipe)
    """
    )
    # add_vertical_space(5)
    st.write("Made by Nick")


def main() -> None:
    st.header("X-Pipe Wiki 机器人 💬")
    robot_manager = XPipeRobotManagerFactory.get_or_create(
        XPipeRobotRevision.HUGGINGFACE_VERSION_0
    )
    robot = robot_manager.get_robot()
    query = st.text_input("X-Pipe Wiki 问题:")
    if query:
        response = robot.ask(question=query)
        st.write(response)


if __name__ == "__main__":
    load_dotenv()
    main()