-
Notifications
You must be signed in to change notification settings - Fork 317
Expand file tree
/
Copy path06_team.py
More file actions
36 lines (28 loc) · 1.04 KB
/
06_team.py
File metadata and controls
36 lines (28 loc) · 1.04 KB
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
from dotenv import load_dotenv
load_dotenv()
from llama_index.core import VectorStoreIndex
from llama_index.readers.web import TrafilaturaWebReader
import chromadb
def create_embedding_store(name):
chroma_client = chromadb.EphemeralClient()
return chroma_client.get_or_create_collection(name)
def query_pages(collection, urls, questions):
docs = TrafilaturaWebReader().load_data(urls)
index = VectorStoreIndex.from_documents(docs, chroma_collection=collection)
query_engine = index.as_query_engine()
for question in questions:
print(f"Question: {question} \n")
print(f"Answer: {query_engine.query(question)}")
if __name__ == "__main__":
url_list = ["https://supertype.ai", "https://supertype.ai/about-us"]
questions = [
"Who are the members of Supertype.ai",
"What problems are they trying to solve?",
"What are the important values at the company?"
]
collection = create_embedding_store("supertype")
query_pages(
collection,
url_list,
questions
)