Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ GentaChat is an simple and easy to use chatbot built specifically as a demonstra
<p align="right">(<a href="#readme-top">back to top</a>)</p>

### Built With

[![Streamlit][Streamlit]][Streamlit-url]

<p align="right">(<a href="#readme-top">back to top</a>)</p>
Expand Down Expand Up @@ -76,7 +77,6 @@ For the advanced version, you could tweak the temperature, maximum lenght, top p

<!-- ROADMAP -->


<!-- LICENSE -->

## License
Expand All @@ -88,6 +88,7 @@ Distributed under the GPL-2.0 License. See `LICENSE.txt` for more information.
<!-- CONTACT -->

## Contact

- Contact Support: [support@genta.tech](mailto:support@genta.tech)

- Instagram: [genta_tech](https://www.instagram.com/genta_tech/)
Expand All @@ -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
[Genta-youtube]: https://www.youtube.com
71 changes: 38 additions & 33 deletions app.py
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -14,49 +14,45 @@
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")
st.caption("A simple demonstration of GentaAPI for chat purposes")

# 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"])
Expand All @@ -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)