Skip to content

Commit b1230b9

Browse files
committed
add query website with gpt example
1 parent 2f0db9f commit b1230b9

File tree

2 files changed

+34
-24
lines changed

2 files changed

+34
-24
lines changed

6_team.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
from dotenv import load_dotenv
3+
from llama_index import GPTChromaIndex, TrafilaturaWebReader
4+
import chromadb
5+
6+
load_dotenv()
7+
8+
def create_embedding_store(name):
9+
chroma_client = chromadb.Client()
10+
return chroma_client.create_collection("newspieces")
11+
12+
def query_pages(collection, urls, questions):
13+
docs = TrafilaturaWebReader().load_data(urls)
14+
index = GPTChromaIndex.from_documents(docs, chroma_collection=collection)
15+
for question in questions:
16+
print(f"Question: {question} \n")
17+
print(f"Answer: {index.query(question)}")
18+
19+
if __name__ == "__main__":
20+
url_list = ["https://supertype.ai", "https://supertype.ai/about-us"]
21+
questions = [
22+
"Who are the members of Supertype.ai",
23+
"What problems are they trying to solve?",
24+
"What are the important values at the company?"
25+
]
26+
27+
collection = create_embedding_store("supertype")
28+
29+
query_pages(
30+
collection,
31+
url_list,
32+
questions
33+
)

newspieces.json

+1-24
Original file line numberDiff line numberDiff line change
@@ -1,24 +1 @@
1-
{
2-
"index_struct": {
3-
"__type__": "chroma",
4-
"__data__": {
5-
"index_id": "6c885f2c-9b0d-44b6-ad81-ce34ad3ccc87",
6-
"summary": null,
7-
"nodes_dict": {},
8-
"doc_id_dict": {},
9-
"embeddings_dict": {}
10-
}
11-
},
12-
"docstore": {
13-
"docs": {},
14-
"ref_doc_info": {
15-
"eba4909c-2870-445c-90a2-8f07c29c31ff": {
16-
"doc_hash": "1abedf1e096b34455d8e4cd5b65b87329a34b30e8ce3c6fabd000241522e5081"
17-
},
18-
"9b7ab721-a18f-4c48-b103-242c790390f6": {
19-
"doc_hash": "e55b12ed31aceb1a6b09488c2686b3290405c6d682d19a0c3719f1502681f416"
20-
}
21-
}
22-
},
23-
"vector_store": {}
24-
}
1+
{"index_struct": {"__type__": "chroma", "__data__": {"index_id": "90246c0b-4d00-4e43-888b-a02dff903054", "summary": null, "nodes_dict": {}, "doc_id_dict": {}, "embeddings_dict": {}}}, "docstore": {"docs": {}, "ref_doc_info": {"2554d06a-ae2c-4b05-920b-d6bddeaab2e7": {"doc_hash": "1abedf1e096b34455d8e4cd5b65b87329a34b30e8ce3c6fabd000241522e5081"}, "3e5dbe9f-843c-494c-a027-d3984c1a6eb5": {"doc_hash": "e55b12ed31aceb1a6b09488c2686b3290405c6d682d19a0c3719f1502681f416"}}}, "vector_store": {}}

0 commit comments

Comments
 (0)