Commit
·
944d166
1
Parent(s):
83ab0eb
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Created on Sun Oct 01 10:49:43 2023
|
| 3 |
+
@author: Loges
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import streamlit as st
|
| 7 |
+
# import sentencepiece
|
| 8 |
+
# from transformers import pipeline, T5Tokenizer, T5ForConditionalGeneration
|
| 9 |
+
|
| 10 |
+
# model=T5ForConditionalGeneration.from_pretrained("Logeswaransr/AI_Chaperone").to("cpu")
|
| 11 |
+
# tokenizer=T5Tokenizer.from_pretrained("Logeswaransr/AI_Chaperone")
|
| 12 |
+
|
| 13 |
+
# pipe=pipeline('text2text-generation', model=model, tokenizer=tokenizer)
|
| 14 |
+
|
| 15 |
+
greetings=["Hello!","I am AI Chaperone. Your special virtual assistant for your needs.", "Feel free to ask me anything. I will do what I can."]
|
| 16 |
+
|
| 17 |
+
st.set_page_config(page_title='AI Chaperone', layout='wide')
|
| 18 |
+
|
| 19 |
+
if 'messages' not in st.session_state:
|
| 20 |
+
st.session_state.messages=[]
|
| 21 |
+
|
| 22 |
+
for gr in greetings:
|
| 23 |
+
st.session_state.messages.append({
|
| 24 |
+
'role':'assistant',
|
| 25 |
+
'content': gr})
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
st.subheader("AI Chaperone")
|
| 29 |
+
|
| 30 |
+
for message in st.session_state.messages:
|
| 31 |
+
with st.chat_message(message['role']):
|
| 32 |
+
st.markdown(message['content'])
|
| 33 |
+
|
| 34 |
+
if prompt:=st.chat_input("Enter your query"):
|
| 35 |
+
with st.chat_message("user"):
|
| 36 |
+
st.markdown(prompt)
|
| 37 |
+
|
| 38 |
+
st.session_state.messages.append({
|
| 39 |
+
'role':'user',
|
| 40 |
+
'content': prompt})
|
| 41 |
+
|
| 42 |
+
# out=pipe(prompt)
|
| 43 |
+
# response=out[0]['generated_text']
|
| 44 |
+
|
| 45 |
+
# response = f"Analysis: {response}"
|
| 46 |
+
|
| 47 |
+
with st.chat_message("assistant"):
|
| 48 |
+
st.markdown(prompt)
|
| 49 |
+
|
| 50 |
+
st.session_state.messages.append({
|
| 51 |
+
'role':'assistant',
|
| 52 |
+
'content': prompt})
|