Update app.py
Browse files
app.py
CHANGED
|
@@ -22,32 +22,9 @@ client = OpenAI(
|
|
| 22 |
|
| 23 |
# Create supported models
|
| 24 |
model_links = {
|
| 25 |
-
"
|
| 26 |
-
"
|
| 27 |
-
"
|
| 28 |
-
"Meta-Llama-3.1-8B-Instruct": "meta-llama/Meta-Llama-3.1-8B-Instruct",
|
| 29 |
-
"Meta-Llama-3-70B-Instruct": "meta-llama/Meta-Llama-3-70B-Instruct",
|
| 30 |
-
"Meta-Llama-3-8B-Instruct": "meta-llama/Meta-Llama-3-8B-Instruct",
|
| 31 |
-
"C4ai-command-r-plus": "CohereForAI/c4ai-command-r-plus",
|
| 32 |
-
"Aya-23-35B": "CohereForAI/aya-23-35B",
|
| 33 |
-
"Zephyr-orpo-141b-A35b-v0.1": "HuggingFaceH4/zephyr-orpo-141b-A35b-v0.1",
|
| 34 |
-
"Mixtral-8x7B-Instruct-v0.1": "mistralai/Mixtral-8x7B-Instruct-v0.1",
|
| 35 |
-
"Codestral-22B-v0.1": "mistralai/Codestral-22B-v0.1",
|
| 36 |
-
"Nous-Hermes-2-Mixtral-8x7B-DPO": "NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO",
|
| 37 |
-
"Yi-1.5-34B-Chat": "01-ai/Yi-1.5-34B-Chat",
|
| 38 |
-
"Gemma-2-27b-it": "google/gemma-2-27b-it",
|
| 39 |
-
"Meta-Llama-2-70B-Chat-HF": "meta-llama/Llama-2-70b-chat-hf",
|
| 40 |
-
"Meta-Llama-2-7B-Chat-HF": "meta-llama/Llama-2-7b-chat-hf",
|
| 41 |
-
"Meta-Llama-2-13B-Chat-HF": "meta-llama/Llama-2-13b-chat-hf",
|
| 42 |
-
"Mistral-7B-Instruct-v0.1": "mistralai/Mistral-7B-Instruct-v0.1",
|
| 43 |
-
"Mistral-7B-Instruct-v0.2": "mistralai/Mistral-7B-Instruct-v0.2",
|
| 44 |
-
"Mistral-7B-Instruct-v0.3": "mistralai/Mistral-7B-Instruct-v0.3",
|
| 45 |
-
"Gemma-1.1-7b-it": "google/gemma-1.1-7b-it",
|
| 46 |
-
"Gemma-1.1-2b-it": "google/gemma-1.1-2b-it",
|
| 47 |
-
"Zephyr-7B-Beta": "HuggingFaceH4/zephyr-7b-beta",
|
| 48 |
-
"Zephyr-7B-Alpha": "HuggingFaceH4/zephyr-7b-alpha",
|
| 49 |
-
"Phi-3-mini-128k-instruct": "microsoft/Phi-3-mini-128k-instruct",
|
| 50 |
-
"Phi-3-mini-4k-instruct": "microsoft/Phi-3-mini-4k-instruct",
|
| 51 |
}
|
| 52 |
|
| 53 |
#Random dog images for error message
|
|
@@ -82,22 +59,22 @@ def reset_conversation():
|
|
| 82 |
models =[key for key in model_links.keys()]
|
| 83 |
|
| 84 |
# Create the sidebar with the dropdown for model selection
|
| 85 |
-
selected_model = st.sidebar.selectbox("
|
| 86 |
|
| 87 |
# Create a temperature slider
|
| 88 |
-
temp_values = st.sidebar.slider('
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
|
| 91 |
#Add reset button to clear conversation
|
| 92 |
-
st.sidebar.button('
|
| 93 |
|
| 94 |
|
| 95 |
# Create model description
|
| 96 |
-
st.sidebar.
|
| 97 |
-
st.sidebar.markdown("
|
| 98 |
-
st.sidebar.markdown("\n[TypeGPT](https://typegpt.net).")
|
| 99 |
-
|
| 100 |
-
|
| 101 |
|
| 102 |
|
| 103 |
if "prev_option" not in st.session_state:
|
|
@@ -115,8 +92,8 @@ if st.session_state.prev_option != selected_model:
|
|
| 115 |
repo_id = model_links[selected_model]
|
| 116 |
|
| 117 |
|
| 118 |
-
st.subheader(f'
|
| 119 |
-
# st.title(f'ChatBot
|
| 120 |
|
| 121 |
# Set a default model
|
| 122 |
if selected_model not in st.session_state:
|
|
@@ -135,7 +112,7 @@ for message in st.session_state.messages:
|
|
| 135 |
|
| 136 |
|
| 137 |
# Accept user input
|
| 138 |
-
if prompt := st.chat_input(f"
|
| 139 |
# Display user message in chat message container
|
| 140 |
with st.chat_message("user"):
|
| 141 |
st.markdown(prompt)
|
|
@@ -161,12 +138,9 @@ if prompt := st.chat_input(f"Hi I'm {selected_model}, ask me a question"):
|
|
| 161 |
|
| 162 |
except Exception as e:
|
| 163 |
# st.empty()
|
| 164 |
-
response = "
|
| 165 |
-
\n
|
| 166 |
-
\n
|
| 167 |
-
\n Try again later. \
|
| 168 |
-
\n\
|
| 169 |
-
\n Here's a random pic of a 🐶:"
|
| 170 |
st.write(response)
|
| 171 |
random_dog_pick = 'https://random.dog/'+ random_dog[np.random.randint(len(random_dog))]
|
| 172 |
st.image(random_dog_pick)
|
|
|
|
| 22 |
|
| 23 |
# Create supported models
|
| 24 |
model_links = {
|
| 25 |
+
"GPT-4o": "meta-llama/Meta-Llama-3.1-405B-Instruct-FP8",
|
| 26 |
+
"GPT-4": "meta-llama/Meta-Llama-3.1-405B-Instruct",
|
| 27 |
+
"GPT-3,5": "meta-llama/Meta-Llama-3.1-70B-Instruct",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
}
|
| 29 |
|
| 30 |
#Random dog images for error message
|
|
|
|
| 59 |
models =[key for key in model_links.keys()]
|
| 60 |
|
| 61 |
# Create the sidebar with the dropdown for model selection
|
| 62 |
+
selected_model = st.sidebar.selectbox("Выбрать модель GPT", models)
|
| 63 |
|
| 64 |
# Create a temperature slider
|
| 65 |
+
temp_values = st.sidebar.slider('Температура ChatGPT', 0.0, 1.0, (0.5))
|
| 66 |
+
st.sidebar.markdown("Температура в ChatGPT влияет на качество и связность генерируемого текста.")
|
| 67 |
+
st.sidebar.markdown("**Для оптимального результата рекомендуем выбирать температуру в диапазоне от 0,5 до 0,7**.")
|
| 68 |
+
st.sidebar.markdown("Этот диапазон обеспечивает хороший баланс между креативностью и связностью.")
|
| 69 |
|
| 70 |
|
| 71 |
#Add reset button to clear conversation
|
| 72 |
+
st.sidebar.button('Новый чат', on_click=reset_conversation) #Reset button
|
| 73 |
|
| 74 |
|
| 75 |
# Create model description
|
| 76 |
+
st.sidebar.markdown("*Созданный контент может быть неточным.*")
|
| 77 |
+
st.sidebar.markdown("\n Наш сайт: [GPT-ChatBot.ru](https://gpt-chatbot.ru/).")
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
|
| 80 |
if "prev_option" not in st.session_state:
|
|
|
|
| 92 |
repo_id = model_links[selected_model]
|
| 93 |
|
| 94 |
|
| 95 |
+
st.subheader(f'GPT-ChatBot с моделью {selected_model}')
|
| 96 |
+
# st.title(f'GPT-ChatBot сейчас использует {selected_model}')
|
| 97 |
|
| 98 |
# Set a default model
|
| 99 |
if selected_model not in st.session_state:
|
|
|
|
| 112 |
|
| 113 |
|
| 114 |
# Accept user input
|
| 115 |
+
if prompt := st.chat_input(f"Привет. Я {selected_model}. Как я могу вам помочь сегодня?"):
|
| 116 |
# Display user message in chat message container
|
| 117 |
with st.chat_message("user"):
|
| 118 |
st.markdown(prompt)
|
|
|
|
| 138 |
|
| 139 |
except Exception as e:
|
| 140 |
# st.empty()
|
| 141 |
+
response = "Похоже, кто-то что-то отключил!\
|
| 142 |
+
\n Либо пространство модели обновляется, либо что-то не работает.\
|
| 143 |
+
\n Повторите попытку позже :( "
|
|
|
|
|
|
|
|
|
|
| 144 |
st.write(response)
|
| 145 |
random_dog_pick = 'https://random.dog/'+ random_dog[np.random.randint(len(random_dog))]
|
| 146 |
st.image(random_dog_pick)
|