Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,42 +1,37 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
from g4f.client import Client
|
3 |
-
|
4 |
-
client = Client()
|
5 |
-
|
6 |
-
st.set_page_config(
|
7 |
-
page_title="GPT-4o Chat",
|
8 |
-
page_icon="π",
|
9 |
-
layout="centered"
|
10 |
-
)
|
11 |
-
|
12 |
-
if "chat_history" not in st.session_state:
|
13 |
-
st.session_state.chat_history = []
|
14 |
-
|
15 |
-
st.title("GPT-4o-mini Chat π€")
|
16 |
-
|
17 |
-
for message in st.session_state.chat_history:
|
18 |
-
with st.chat_message(message['role']):
|
19 |
-
st.markdown(message['content'])
|
20 |
-
|
21 |
-
user_prompt = st.chat_input("Ask GPT-4o-mini")
|
22 |
-
|
23 |
-
if user_prompt:
|
24 |
-
st.chat_message("user").markdown(user_prompt)
|
25 |
-
st.session_state.chat_history.append({"role": "user", "content": user_prompt})
|
26 |
-
|
27 |
-
response = client.chat.completions.create(
|
28 |
-
model="gpt-4o-mini",
|
29 |
-
messages=[
|
30 |
-
{"role": "system", "content": "You are a helpful assistant"},
|
31 |
-
*st.session_state.chat_history
|
32 |
-
]
|
33 |
-
)
|
34 |
-
final_response = response.choices[0].message.content
|
35 |
-
st.session_state.chat_history.append({"role": "assistant", "content": final_response})
|
36 |
-
with st.chat_message("assistant"):
|
37 |
-
st.markdown(final_response)
|
38 |
-
|
39 |
-
#gpt-4o-mini
|
40 |
-
#llama-3-70b-instruct
|
41 |
-
#llama-3-70b-instruct
|
42 |
-
#mixtral-8x7b
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from g4f.client import Client
|
3 |
+
|
4 |
+
client = Client()
|
5 |
+
|
6 |
+
st.set_page_config(
|
7 |
+
page_title="GPT-4o Chat",
|
8 |
+
page_icon="π",
|
9 |
+
layout="centered"
|
10 |
+
)
|
11 |
+
|
12 |
+
if "chat_history" not in st.session_state:
|
13 |
+
st.session_state.chat_history = []
|
14 |
+
|
15 |
+
st.title("GPT-4o-mini Chat π€")
|
16 |
+
|
17 |
+
for message in st.session_state.chat_history:
|
18 |
+
with st.chat_message(message['role']):
|
19 |
+
st.markdown(message['content'])
|
20 |
+
|
21 |
+
user_prompt = st.chat_input("Ask GPT-4o-mini")
|
22 |
+
|
23 |
+
if user_prompt:
|
24 |
+
st.chat_message("user").markdown(user_prompt)
|
25 |
+
st.session_state.chat_history.append({"role": "user", "content": user_prompt})
|
26 |
+
|
27 |
+
response = client.chat.completions.create(
|
28 |
+
model="gpt-4o-mini",
|
29 |
+
messages=[
|
30 |
+
{"role": "system", "content": "You are a helpful assistant"},
|
31 |
+
*st.session_state.chat_history
|
32 |
+
]
|
33 |
+
)
|
34 |
+
final_response = response.choices[0].message.content
|
35 |
+
st.session_state.chat_history.append({"role": "assistant", "content": final_response})
|
36 |
+
with st.chat_message("assistant"):
|
37 |
+
st.markdown(final_response)
|
|
|
|
|
|
|
|
|
|