Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

created a secondary UI with streamlint to toggle between the standard and newly build UI #126

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ marvin.toml
.marvin-history
marvin.egg-info

.streamlit
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
11 changes: 8 additions & 3 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
## Scope
`[Add context about what this feature is about and explain why of the feature and your technical decisions.]`
Added a new ui for the application, you can use different ui for the same application the default ui can be used by running the command poetry run python textbase/textbase_cli.py test

you can use the streamlit run examples\streamlit\streamlit_vicky-chatbot.py command to run the ui built with stream lit


- [ ] `[Sub task]`

there were not enough modification made other then stroing the api key in a sperate file called secrets.toml the file will not be stroed in the repo when you clone the repo please create a .streamlit folder in the main path and add a secrets.toml file in there add your api key here
# .streamlit/secrets.toml
OPENAI_API_KEY = "YOUR_API_KEY"

### Screenshots
---
Expand All @@ -15,6 +20,6 @@


### Developer checklist
- [ ] I’ve manually tested that code works locally on desktop and mobile browsers.
- [ ] I’ve reviewed my code.
- [ ] I’ve removed all my personal credentials (API keys etc.) from the code.
- [] I’ve manually tested that code works locally on desktop and mobile browsers.
- [] I’ve reviewed my code.
- [] I’ve removed all my personal credentials (API keys etc.) from the code.
47 changes: 47 additions & 0 deletions examples/streamlit/streamlit_vicky-chatbot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import streamlit as st
import openai
import random
import time

st.title("textbase_Vicky-chatbot 😎")

openai.api_key=st.secrets["OPENAI_API_KEY"]

if "openai_model" not in st.session_state:
st.session_state["openai_model"] = "gpt-3.5-turbo"

# Initialize chat history
if "messages" not in st.session_state:
st.session_state.messages = []

# Display chat messages from history on app rerun
for message in st.session_state.messages:
with st.chat_message(message["role"]):
st.markdown(message["content"])

# Accept user input
prompt = st.chat_input("what is up")
if prompt :

with st.chat_message("user"):
st.markdown(prompt)
# Add user message to chat history
st.session_state.messages.append({"role": "user", "content": prompt})


# Display assistant response in chat message container
with st.chat_message("assistant"):
message_placeholder = st.empty()
full_response = ""
for response in openai.ChatCompletion.create(
model=st.session_state["openai_model"],
messages=[
{"role": m["role"], "content":m["content"]}
for m in st.session_state.messages
],
stream=True
):
full_response += response.choices[0].delta.get("content", "")
message_placeholder.markdown(full_response + "")
message_placeholder.markdown(full_response)
st.session_state.messages.append({"role":"assistant", "content": full_response})