Ankush05 commited on
Commit
d7e046c
·
verified ·
1 Parent(s): 5b2bf60

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -47
app.py CHANGED
@@ -1,47 +1,18 @@
1
- import streamlit as st
2
- import os
3
- from bardapi import Bard
4
- from pymongo import MongoClient
5
-
6
- #Mongo connection
7
- url = os.environ["MONGO_CONNECTION_STRING"]
8
- client = MongoClient(url,tlsCertificateKeyFile ="cert.pem")
9
-
10
- #Fetch database
11
- db = client["myapp"]
12
-
13
- #Fetch collections
14
- remcol = db["Reminders"]
15
- usrcol = db["Users"]
16
- notecol = db["Notes"]
17
-
18
- #Connect with Bard
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)