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

remove items #150

Open
wants to merge 4 commits into
base: master
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
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Welcome to Streamlit!
Install requirements:

Edit `/streamlit_app.py` to customize this app to your heart's desire. :heart:
pip install -r requirements.txt

on VS Code:
py -m pip install -r requirements.txt



Run app :
streamlit run main.py

on VS Code:
py -m streamlit run main.py

If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
forums](https://discuss.streamlit.io).
56 changes: 56 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import streamlit as st
from streamlit_chat import message

from langchain.chat_models import ChatOpenAI
from langchain.schema import (
SystemMessage,
HumanMessage,
AIMessage
)


def init():

# setup streamlit page
st.set_page_config(
page_title="Your own ChatGPT",
page_icon="🤖"
)


def main():
init()

OPENAI_API_KEY = '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'
llm = ChatOpenAI(temperature=0, model="gpt-3.5-turbo", openai_api_key=OPENAI_API_KEY)
# initialize message history
if "messages" not in st.session_state:
st.session_state.messages = [
SystemMessage(content="You are a helpful assistant.")
]

st.header("Your own ChatGPT 🤖")

# sidebar with user input
with st.sidebar:
user_input = st.text_input("Your message: ", key="user_input")

# handle user input
if user_input:
st.session_state.messages.append(HumanMessage(content=user_input))
with st.spinner("Thinking..."):
response = chat(st.session_state.messages)
st.session_state.messages.append(
AIMessage(content=response.content))

# display message history
messages = st.session_state.get('messages', [])
for i, msg in enumerate(messages[1:]):
if i % 2 == 0:
message(msg.content, is_user=True, key=str(i) + '_user')
else:
message(msg.content, is_user=False, key=str(i) + '_ai')


if __name__ == '__main__':
main()
6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
altair
pandas
streamlit
streamlit_chat
aiohttp==3.8.2
yarl==1.8.1
frozenlist==1.3.1
openai ==1.1.1
langchain
40 changes: 0 additions & 40 deletions streamlit_app.py

This file was deleted.