forked from xusenlinzy/api-for-open-llm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstreamlit_app.py
67 lines (48 loc) · 2.2 KB
/
streamlit_app.py
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import os
import streamlit as st
from streamlit_gallery.utils.page import page_group
def main():
from streamlit_gallery.apps import gallery
from streamlit_gallery.components import chat, doc_chat
page = page_group("p")
with st.sidebar:
st.title("🎉 LLM Gallery")
with st.expander("✨ APPS", True):
page.item("LLM Chat Gallery", gallery, default=True)
with st.expander("🧩 COMPONENTS", True):
if os.getenv("CHAT_API_BASE", ""):
page.item("Chat", chat)
page.item("Doc Chat", doc_chat)
if os.getenv("SQL_CHAT_API_BASE", ""):
from streamlit_gallery.components import sql_chat
page.item("SQL Chat", sql_chat)
if os.getenv("SERPAPI_API_KEY", ""):
from streamlit_gallery.components import search_chat
page.item("Search Chat", search_chat)
if os.getenv("TOOL_CHAT_API_BASE", ""):
from streamlit_gallery.components import tool_chat
page.item("Tool Chat", tool_chat)
if os.getenv("INTERPRETER_CHAT_API_BASE", ""):
from streamlit_gallery.components import code_interpreter
page.item("Code Interpreter", code_interpreter)
if st.button("🗑️ 清空消息"):
st.session_state.messages = []
with st.expander("🐧 参数配置", False):
max_tokens = st.slider("回复最大token数量", 20, 4096, 1024)
temperature = st.slider("温度", 0.0, 1.0, 0.9)
chunk_size = st.slider("文档分块大小", 100, 512, 250)
chunk_overlap = st.slider("文档分块重复大小", 0, 100, 50)
top_k = st.slider("文档分块检索数量", 0, 10, 4)
st.session_state.update(
dict(
max_tokens=max_tokens,
temperature=temperature,
chunk_size=chunk_size,
chunk_overlap=chunk_overlap,
top_k=top_k,
)
)
page.show()
if __name__ == "__main__":
st.set_page_config(page_title="Streamlit LLM Gallery", page_icon="🎈", layout="wide")
main()