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 diff --git a/app.py b/app.py index 3c8e658..1179e50 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") @@ -14,41 +14,32 @@ 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'): + 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") @@ -56,7 +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"]) @@ -76,16 +72,25 @@ # 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) + 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