Spaces:
Sleeping
Sleeping
Added temp and reset buttons.
Browse files
app.py
CHANGED
@@ -24,7 +24,7 @@ model_links ={
|
|
24 |
"Mistral":"mistralai/Mistral-7B-Instruct-v0.2",
|
25 |
"Gemma-7B":"google/gemma-7b-it",
|
26 |
"Gemma-2B":"google/gemma-2b-it",
|
27 |
-
"Gemma-Zephyr":"HuggingFaceH4/zephyr-7b-gemma-v0.1",
|
28 |
# "Llama-2":"meta-llama/Llama-2-7b-chat-hf"
|
29 |
|
30 |
}
|
@@ -52,6 +52,23 @@ model_info ={
|
|
52 |
|
53 |
}
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
# Define the available models
|
57 |
models =[key for key in model_links.keys()]
|
@@ -59,11 +76,19 @@ models =[key for key in model_links.keys()]
|
|
59 |
# Create the sidebar with the dropdown for model selection
|
60 |
selected_model = st.sidebar.selectbox("Select Model", models)
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
# Create model description
|
63 |
st.sidebar.write(f"You're now chatting with **{selected_model}**")
|
64 |
st.sidebar.markdown(model_info[selected_model]['description'])
|
65 |
st.sidebar.image(model_info[selected_model]['logo'])
|
66 |
-
|
67 |
|
68 |
#Pull in the model we want to use
|
69 |
repo_id = model_links[selected_model]
|
@@ -108,7 +133,7 @@ if prompt := st.chat_input(f"Hi I'm {selected_model}, ask me a question"):
|
|
108 |
{"role": m["role"], "content": m["content"]}
|
109 |
for m in st.session_state.messages
|
110 |
],
|
111 |
-
temperature=0.5,
|
112 |
stream=True,
|
113 |
max_tokens=3000,
|
114 |
)
|
|
|
24 |
"Mistral":"mistralai/Mistral-7B-Instruct-v0.2",
|
25 |
"Gemma-7B":"google/gemma-7b-it",
|
26 |
"Gemma-2B":"google/gemma-2b-it",
|
27 |
+
# "Gemma-Zephyr":"HuggingFaceH4/zephyr-7b-gemma-v0.1",
|
28 |
# "Llama-2":"meta-llama/Llama-2-7b-chat-hf"
|
29 |
|
30 |
}
|
|
|
52 |
|
53 |
}
|
54 |
|
55 |
+
def reset_conversation():
|
56 |
+
'''
|
57 |
+
Resets Conversation
|
58 |
+
'''
|
59 |
+
st.session_state.conversation = []
|
60 |
+
st.session_state.messages = []
|
61 |
+
return None
|
62 |
+
|
63 |
+
if "prev_option" not in st.session_state:
|
64 |
+
st.session_state.prev_option = selected_model
|
65 |
+
|
66 |
+
if st.session_state.prev_option != selected_model:
|
67 |
+
st.session_state.messages = []
|
68 |
+
st.write(f"Changed to {selected_model}")
|
69 |
+
st.session_state.prev_option = selected_model
|
70 |
+
reset_conversation()
|
71 |
+
|
72 |
|
73 |
# Define the available models
|
74 |
models =[key for key in model_links.keys()]
|
|
|
76 |
# Create the sidebar with the dropdown for model selection
|
77 |
selected_model = st.sidebar.selectbox("Select Model", models)
|
78 |
|
79 |
+
#Create a temperature slider
|
80 |
+
temp_values = st.sidebar.slider('Select a temperature value', 0.0, 1.0, (0.5))
|
81 |
+
|
82 |
+
|
83 |
+
#Add reset button to clear conversation
|
84 |
+
st.sidebar.button('Reset Chat', on_click=reset_conversation) #Reset button
|
85 |
+
|
86 |
+
|
87 |
# Create model description
|
88 |
st.sidebar.write(f"You're now chatting with **{selected_model}**")
|
89 |
st.sidebar.markdown(model_info[selected_model]['description'])
|
90 |
st.sidebar.image(model_info[selected_model]['logo'])
|
91 |
+
st.sidebar.markdown("*Generated content may be inaccurate or false.*")
|
92 |
|
93 |
#Pull in the model we want to use
|
94 |
repo_id = model_links[selected_model]
|
|
|
133 |
{"role": m["role"], "content": m["content"]}
|
134 |
for m in st.session_state.messages
|
135 |
],
|
136 |
+
temperature=temp_values,#0.5,
|
137 |
stream=True,
|
138 |
max_tokens=3000,
|
139 |
)
|