From e139e2124f7b42e5315e580b77041e5d0324eb58 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 9 Nov 2023 08:45:35 +0000 Subject: [PATCH 1/5] Restyled by autopep8 --- app.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/app.py b/app.py index 3c8e658..47f2659 100644 --- a/app.py +++ b/app.py @@ -14,16 +14,17 @@ st.image(logo, use_column_width="always") # Ask user to input their API Token - genta_api_key = st.text_input("Genta API key", key="chatbot_api_key", type="password") - + genta_api_key = st.text_input( + "Genta API key", key="chatbot_api_key", type="password") + # Ask user to select their model of choice model_selected = st.selectbox("Choose your LLM you would like to try:", - ("Merak", "Starstreak", "DukunLM")) - + ("Merak", "Starstreak", "DukunLM")) + # Add Clear Chat button if st.button('Clear chat'): st.session_state.messages = st.session_state.messages[0:1] - + # Add advanced option advanced = st.toggle('Advanced mode') if advanced: @@ -31,7 +32,7 @@ temperature = st.slider( ':blue[Temperature]', 0.0, 2.0, 1.0) - + # Set the model max token to be generated max_length = st.slider( ":blue[Maximum lenght]", @@ -56,7 +57,8 @@ # Initialize a new message if there isnt a message in session state if "messages" not in st.session_state: - st.session_state["messages"] = [{"role": "assistant", "content": "Halo, saya adalah asisten anda, ada yang bisa saya bantu?"}] + st.session_state["messages"] = [ + {"role": "assistant", "content": "Halo, saya adalah asisten anda, ada yang bisa saya bantu?"}] for msg in st.session_state.messages: st.chat_message(msg["role"]).write(msg["content"]) @@ -79,13 +81,11 @@ response = API.ChatCompletion(chat_history=st.session_state.messages[1:], model_name=model_selected, max_new_tokens=max_length, temperature=temperature, top_p=top_p, repetition_penalty=rep_penalty) else: - response = API.ChatCompletion(chat_history=st.session_state.messages[1:], model_name=model_selected, max_new_tokens=1024) + response = API.ChatCompletion( + chat_history=st.session_state.messages[1:], model_name=model_selected, max_new_tokens=1024) response = response[0][0]["generated_text"] # Display the response - st.session_state.messages.append({"role":"assistant", "content":response}) + st.session_state.messages.append( + {"role": "assistant", "content": response}) st.chat_message("assistant").write(response) - - - - \ No newline at end of file From 75fa8d575a64bd1acd753b7bbe681f82599a931c Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 9 Nov 2023 08:45:40 +0000 Subject: [PATCH 2/5] Restyled by black --- app.py | 55 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/app.py b/app.py index 47f2659..7b54e92 100644 --- a/app.py +++ b/app.py @@ -15,41 +15,32 @@ # Ask user to input their API Token genta_api_key = st.text_input( - "Genta API key", key="chatbot_api_key", type="password") + "Genta API key", key="chatbot_api_key", type="password" + ) # Ask user to select their model of choice - model_selected = st.selectbox("Choose your LLM you would like to try:", - ("Merak", "Starstreak", "DukunLM")) + model_selected = st.selectbox( + "Choose your LLM you would like to try:", ("Merak", "Starstreak", "DukunLM") + ) # Add Clear Chat button - if st.button('Clear chat'): + if st.button("Clear chat"): st.session_state.messages = st.session_state.messages[0:1] # Add advanced option - advanced = st.toggle('Advanced mode') + advanced = st.toggle("Advanced mode") if advanced: # Set the model temperature - temperature = st.slider( - ':blue[Temperature]', - 0.0, 2.0, 1.0) + temperature = st.slider(":blue[Temperature]", 0.0, 2.0, 1.0) # Set the model max token to be generated - max_length = st.slider( - ":blue[Maximum lenght]", - 0, 4096, 2048 - ) + max_length = st.slider(":blue[Maximum lenght]", 0, 4096, 2048) # Set the model top P value - top_p = st.slider( - ":blue[Top P]", - 0.0, 0.1, 0.95 - ) + top_p = st.slider(":blue[Top P]", 0.0, 0.1, 0.95) # Set the model repetition penalty - rep_penalty = st.slider( - ":blue[Repetition penalty]", - 0.0, 2.0, 1.03 - ) + rep_penalty = st.slider(":blue[Repetition penalty]", 0.0, 2.0, 1.03) # App title and caption st.title("GentaChat") @@ -58,7 +49,11 @@ # Initialize a new message if there isnt a message in session state if "messages" not in st.session_state: st.session_state["messages"] = [ - {"role": "assistant", "content": "Halo, saya adalah asisten anda, ada yang bisa saya bantu?"}] + { + "role": "assistant", + "content": "Halo, saya adalah asisten anda, ada yang bisa saya bantu?", + } + ] for msg in st.session_state.messages: st.chat_message(msg["role"]).write(msg["content"]) @@ -78,14 +73,22 @@ # Call the API for response # If the user use advanced feature if advanced: - response = API.ChatCompletion(chat_history=st.session_state.messages[1:], model_name=model_selected, max_new_tokens=max_length, - temperature=temperature, top_p=top_p, repetition_penalty=rep_penalty) + response = API.ChatCompletion( + chat_history=st.session_state.messages[1:], + model_name=model_selected, + max_new_tokens=max_length, + temperature=temperature, + top_p=top_p, + repetition_penalty=rep_penalty, + ) else: response = API.ChatCompletion( - chat_history=st.session_state.messages[1:], model_name=model_selected, max_new_tokens=1024) + chat_history=st.session_state.messages[1:], + model_name=model_selected, + max_new_tokens=1024, + ) response = response[0][0]["generated_text"] # Display the response - st.session_state.messages.append( - {"role": "assistant", "content": response}) + st.session_state.messages.append({"role": "assistant", "content": response}) st.chat_message("assistant").write(response) From 8cd82ae768e3e31bab2919b87064f8d7c6d7e78f Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 9 Nov 2023 08:45:42 +0000 Subject: [PATCH 3/5] Restyled by isort --- app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.py b/app.py index 7b54e92..f03dd1c 100644 --- a/app.py +++ b/app.py @@ -1,8 +1,8 @@ """ FILE is for UI """ -from genta import GentaAPI import streamlit as st +from genta import GentaAPI from PIL import Image logo = Image.open("assets\genta_logo.png") From a5188b63ddb0f2f2b44463e190c4ce3fdc1b7e95 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 9 Nov 2023 08:45:44 +0000 Subject: [PATCH 4/5] Restyled by prettier-markdown --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ac93b34..3f2b3b3 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ GentaChat is an simple and easy to use chatbot built specifically as a demonstra

(back to top)

### Built With + [![Streamlit][Streamlit]][Streamlit-url]

(back to top)

@@ -76,7 +77,6 @@ For the advanced version, you could tweak the temperature, maximum lenght, top p - ## License @@ -88,6 +88,7 @@ Distributed under the GPL-2.0 License. See `LICENSE.txt` for more information. ## Contact + - Contact Support: [support@genta.tech](mailto:support@genta.tech) - Instagram: [genta_tech](https://www.instagram.com/genta_tech/) @@ -111,4 +112,4 @@ Distributed under the GPL-2.0 License. See `LICENSE.txt` for more information. [Streamlit]: https://img.shields.io/badge/Streamlit-FF4B4B?style=for-the-badge&logo=streamlit&logoColor=white [Streamlit-url]: https://streamlit.io/ [Genta-url]: https://www.genta.tech -[Genta-youtube]: https://www.youtube.com \ No newline at end of file +[Genta-youtube]: https://www.youtube.com From 8e0ffe71bd20ee87575cff5e1fdb3480448317b4 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 9 Nov 2023 08:45:56 +0000 Subject: [PATCH 5/5] Restyled by yapf --- app.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/app.py b/app.py index f03dd1c..1179e50 100644 --- a/app.py +++ b/app.py @@ -14,14 +14,13 @@ st.image(logo, use_column_width="always") # Ask user to input their API Token - genta_api_key = st.text_input( - "Genta API key", key="chatbot_api_key", type="password" - ) + genta_api_key = st.text_input("Genta API key", + key="chatbot_api_key", + type="password") # Ask user to select their model of choice - model_selected = st.selectbox( - "Choose your LLM you would like to try:", ("Merak", "Starstreak", "DukunLM") - ) + model_selected = st.selectbox("Choose your LLM you would like to try:", + ("Merak", "Starstreak", "DukunLM")) # Add Clear Chat button if st.button("Clear chat"): @@ -48,12 +47,12 @@ # Initialize a new message if there isnt a message in session state if "messages" not in st.session_state: - st.session_state["messages"] = [ - { - "role": "assistant", - "content": "Halo, saya adalah asisten anda, ada yang bisa saya bantu?", - } - ] + st.session_state["messages"] = [{ + "role": + "assistant", + "content": + "Halo, saya adalah asisten anda, ada yang bisa saya bantu?", + }] for msg in st.session_state.messages: st.chat_message(msg["role"]).write(msg["content"]) @@ -90,5 +89,8 @@ response = response[0][0]["generated_text"] # Display the response - st.session_state.messages.append({"role": "assistant", "content": response}) + st.session_state.messages.append({ + "role": "assistant", + "content": response + }) st.chat_message("assistant").write(response)