Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,22 @@
|
|
| 1 |
from bardapi import Bard
|
| 2 |
import os
|
| 3 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
bardkey = os.environ.get("BARD_API_KEY")
|
| 6 |
|
| 7 |
bard = Bard(token=bardkey)
|
| 8 |
if query := st.chat_input("Hi, how can I help you"):
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
|
|
|
| 1 |
from bardapi import Bard
|
| 2 |
import os
|
| 3 |
import streamlit as st
|
| 4 |
+
from transformers import pipeline
|
| 5 |
+
|
| 6 |
+
intent = pipeline(model="facebook/bart-large-mnli")
|
| 7 |
+
fetchvalue = pipeline(model="Jean-Baptiste/camembert-ner", aggregation_strategy="simple")
|
| 8 |
|
| 9 |
bardkey = os.environ.get("BARD_API_KEY")
|
| 10 |
|
| 11 |
bard = Bard(token=bardkey)
|
| 12 |
if query := st.chat_input("Hi, how can I help you"):
|
| 13 |
+
usrintent = intent(query, candidate_labels=["Reminder", "General Conversation"])
|
| 14 |
+
if usrintent["labels"][0] == "Reminder":
|
| 15 |
+
values = fetchvalue(query)
|
| 16 |
+
with st.chat_message("assistant"):
|
| 17 |
+
st.write(values)
|
| 18 |
+
elif usrintent["labels"][0] == "General Conversation"
|
| 19 |
+
ans = bard.get_answer(query)
|
| 20 |
+
with st.chat_message("assistant"):
|
| 21 |
+
st.write(ans['content'])
|
| 22 |
|