Spaces:
Sleeping
Sleeping
dowtya1729
commited on
Commit
•
c73750f
1
Parent(s):
a0cb78f
Upload 5 files
Browse files- README.md +3 -3
- app.py +55 -0
- env-sample.txt +1 -0
- gitattributes.txt +34 -0
- requirements.txt +5 -0
README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
---
|
2 |
title: ChatModelApp
|
3 |
-
emoji:
|
4 |
colorFrom: gray
|
5 |
-
colorTo:
|
6 |
sdk: streamlit
|
7 |
-
sdk_version: 1.
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
|
|
1 |
---
|
2 |
title: ChatModelApp
|
3 |
+
emoji: ⚡
|
4 |
colorFrom: gray
|
5 |
+
colorTo: red
|
6 |
sdk: streamlit
|
7 |
+
sdk_version: 1.21.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
app.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import streamlit as st
|
3 |
+
|
4 |
+
|
5 |
+
from langchain.chat_models import ChatOpenAI
|
6 |
+
from langchain.schema import (
|
7 |
+
AIMessage,
|
8 |
+
HumanMessage,
|
9 |
+
SystemMessage
|
10 |
+
)
|
11 |
+
|
12 |
+
# From here down is all the StreamLit UI.
|
13 |
+
st.set_page_config(page_title="LangChain Demo", page_icon=":robot:")
|
14 |
+
st.header("Hey, I'm your Chat GPT")
|
15 |
+
|
16 |
+
|
17 |
+
|
18 |
+
if "sessionMessages" not in st.session_state:
|
19 |
+
st.session_state.sessionMessages = [
|
20 |
+
SystemMessage(content="You are a helpful assistant.")
|
21 |
+
]
|
22 |
+
|
23 |
+
|
24 |
+
|
25 |
+
def load_answer(question):
|
26 |
+
|
27 |
+
st.session_state.sessionMessages.append(HumanMessage(content=question))
|
28 |
+
|
29 |
+
assistant_answer = chat(st.session_state.sessionMessages )
|
30 |
+
|
31 |
+
st.session_state.sessionMessages.append(AIMessage(content=assistant_answer.content))
|
32 |
+
|
33 |
+
return assistant_answer.content
|
34 |
+
|
35 |
+
|
36 |
+
def get_text():
|
37 |
+
input_text = st.text_input("You: ", key= input)
|
38 |
+
return input_text
|
39 |
+
|
40 |
+
|
41 |
+
chat = ChatOpenAI(temperature=0)
|
42 |
+
|
43 |
+
|
44 |
+
|
45 |
+
|
46 |
+
user_input=get_text()
|
47 |
+
submit = st.button('Generate')
|
48 |
+
|
49 |
+
if submit:
|
50 |
+
|
51 |
+
response = load_answer(user_input)
|
52 |
+
st.subheader("Answer:")
|
53 |
+
|
54 |
+
st.write(response,key= 1)
|
55 |
+
|
env-sample.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
OPENAI_API_KEY=""
|
gitattributes.txt
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
langchain
|
3 |
+
openai
|
4 |
+
streamlit-chat
|
5 |
+
python-dotenv
|