-
Notifications
You must be signed in to change notification settings - Fork 3
/
harinbot.py
70 lines (53 loc) · 1.75 KB
/
harinbot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from dotenv import load_dotenv
load_dotenv()
## For Adding Context
# import os
# import time
# from chromadb.utils import embedding_functions
from embedchain.config import QueryConfig
from string import Template
from embedchain import App
bot_name = "Harin Wu"
speaking_to = "Anna"
harin_bot = App()
query_config = QueryConfig(template=Template(f"""
Use the following pieces of context to continue the conversation. Use slangs from the context.
$context
{speaking_to}: $query
{bot_name}:
"""
))
# Embed Online Resources
# harin_bot.add("youtube_video", "https://www.youtube.com/watch?v=3qHkcs3kG44")
# harin_bot.add("pdf_file", "https://navalmanack.s3.amazonaws.com/Eric-Jorgenson_The-Almanack-of-Naval-Ravikant_Final.pdf")
# harin_bot.add("web_page", "https://nav.al/feedback")
# harin_bot.add("web_page", "https://nav.al/agi")
# Embed Local Resources
# harin_bot.add_local("qna_pair", ("Who is Naval Ravikant?", "Naval Ravikant is an Indian-American entrepreneur and investor."))
# f = open("chatData/FullChat.txt", "r")
# whatsapp = f.read()
# f.close()
# harin_bot.add_local("text", whatsapp)
# def get_txt_files():
# txt_files = []
# for root, _, files in os.walk("chatData/FB"):
# for file in files:
# if file.endswith(".txt"):
# txt_files.append(os.path.join(root, file))
# return txt_files
# fbFiles = get_txt_files()
# for file in fbFiles:
# fb = open(file, "r")
# facebook = fb.read()
# harin_bot.add_local("text", facebook)
# fb.close()
# time.sleep(10)
query = None
while (query == None):
query = input("Enter your query: ")
if (query == "exit"):
print("Thanks for using Harin Bot!")
break
answer = harin_bot.query(query, query_config)
print(answer)
query = None