lring3223 commited on
Commit
2643656
1 Parent(s): 0a61252

Placeholder

Browse files
Files changed (1) hide show
  1. app.py +34 -28
app.py CHANGED
@@ -1,11 +1,20 @@
1
  from openai import OpenAI
2
  import streamlit as st
3
 
4
- st.title("HiddenLayer Chat")
 
 
 
5
 
6
  client = OpenAI(api_key=st.secrets["OPENAI_API_KEY"])
7
 
8
- col1, col2 = st.columns(2)
 
 
 
 
 
 
9
 
10
  if "openai_model" not in st.session_state:
11
  st.session_state["openai_model"] = "gpt-3.5-turbo"
@@ -27,38 +36,35 @@ for message in st.session_state.messages_col_2:
27
  st.markdown(message["content"])
28
 
29
 
30
- if prompt := st.chat_input("What is up?"):
31
  st.session_state.messages_col_1.append({"role": "user", "content": prompt})
32
  st.session_state.messages_col_2.append({"role": "user", "content": prompt})
33
  with col1:
34
  with st.chat_message("user"):
35
  st.markdown(prompt)
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  with col2:
38
  with st.chat_message("user"):
39
  st.markdown(prompt)
40
-
41
-
42
- with st.chat_message("assistant"):
43
- stream = client.chat.completions.create(
44
- model=st.session_state["openai_model"],
45
- messages=[
46
- {"role": m["role"], "content": m["content"]}
47
- for m in st.session_state.messages_col_1
48
- ],
49
- stream=True,
50
- )
51
- response = st.write_stream(stream)
52
- st.session_state.messages_col_1.append({"role": "assistant", "content": response})
53
-
54
- with st.chat_message("assistant"):
55
- stream = client.chat.completions.create(
56
- model=st.session_state["openai_model"],
57
- messages=[
58
- {"role": m["role"], "content": m["content"]}
59
- for m in st.session_state.messages_col_2
60
- ],
61
- stream=True,
62
- )
63
- response = st.write_stream(stream)
64
- st.session_state.messages_col_2.append({"role": "assistant", "content": response})
 
1
  from openai import OpenAI
2
  import streamlit as st
3
 
4
+ st.set_page_config(layout="wide")
5
+
6
+ st.columns(3)[1].title("HiddenLayer Chat")
7
+
8
 
9
  client = OpenAI(api_key=st.secrets["OPENAI_API_KEY"])
10
 
11
+ col1, col2 = st.columns(2, gap="large")
12
+
13
+ with col1:
14
+ st.header("GPT-3.5")
15
+
16
+ with col2:
17
+ st.header("Currently GPT-3.5, later SafeLLM")
18
 
19
  if "openai_model" not in st.session_state:
20
  st.session_state["openai_model"] = "gpt-3.5-turbo"
 
36
  st.markdown(message["content"])
37
 
38
 
39
+ if prompt := st.chat_input("Enter a prompt"):
40
  st.session_state.messages_col_1.append({"role": "user", "content": prompt})
41
  st.session_state.messages_col_2.append({"role": "user", "content": prompt})
42
  with col1:
43
  with st.chat_message("user"):
44
  st.markdown(prompt)
45
+ with st.chat_message("assistant"):
46
+ stream = client.chat.completions.create(
47
+ model=st.session_state["openai_model"],
48
+ messages=[
49
+ {"role": m["role"], "content": m["content"]}
50
+ for m in st.session_state.messages_col_1
51
+ ],
52
+ stream=True,
53
+ )
54
+ response = st.write_stream(stream)
55
+ st.session_state.messages_col_1.append({"role": "assistant", "content": response})
56
 
57
  with col2:
58
  with st.chat_message("user"):
59
  st.markdown(prompt)
60
+ with st.chat_message("assistant"):
61
+ stream = client.chat.completions.create(
62
+ model=st.session_state["openai_model"],
63
+ messages=[
64
+ {"role": m["role"], "content": m["content"]}
65
+ for m in st.session_state.messages_col_2
66
+ ],
67
+ stream=True,
68
+ )
69
+ response = st.write_stream(stream)
70
+ st.session_state.messages_col_2.append({"role": "assistant", "content": response})