Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,47 +1,18 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
uri = os.environ["BARD_API_KEY"]
|
20 |
-
bard = Bard(token = uri )
|
21 |
-
|
22 |
-
#Store user bot chat messages
|
23 |
-
def chat_message(ques, ans):
|
24 |
-
chat = {
|
25 |
-
"user": ques,
|
26 |
-
"bot": ans
|
27 |
-
}
|
28 |
-
usrcol.insert_one(chat)
|
29 |
-
|
30 |
-
#Creating reminders from the described goal
|
31 |
-
def create_rem(ans):
|
32 |
-
remlist = bard.get_answer(f"Create a daily routine to achieve this goal below and make a list of reminders with values for reminder_message, time, repetition, days\n\nGoal = {ans}")
|
33 |
-
|
34 |
-
def Chatbot():
|
35 |
-
st.title("chatbot")
|
36 |
-
if query:= st.chat_input("Describe your goal"):
|
37 |
-
answer = bard.get_answer(query)
|
38 |
-
chat_message(query, answer)
|
39 |
-
create_rem(answer["content"])
|
40 |
-
|
41 |
-
with st.chat_message("assistant"):
|
42 |
-
st.write(answer["content"])
|
43 |
-
|
44 |
-
|
45 |
-
Chatbot()
|
46 |
-
|
47 |
-
|
|
|
1 |
+
rom transformers import GPT2LMHeadModel, GPT2Tokenizer
|
2 |
+
model_id = "gpt2"
|
3 |
+
|
4 |
+
model = GPT2LMHeadModel.from_pretrained(model_id)
|
5 |
+
|
6 |
+
tokenizer = GPT2Tokenizer.from_pretrained(model_id)
|
7 |
+
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
text = "Hello"
|
12 |
+
|
13 |
+
encoded_text = tokenizer(text, return_tensors="pt")
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
+
|
18 |
+
outputs = model(**encoded_text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|