MCPcopy Create free account
hub / github.com/BlueBash/BlogIQ / create_collection

Function create_collection

app.py:56–72  ·  view source on GitHub ↗
(collection_name, question, urls)

Source from the content-addressed store, hash-verified

54 keys: Dict[str, any]
55
56def create_collection(collection_name, question, urls):
57 print("---Got Results---")
58 docs = [WebBaseLoader(url).load() for url in urls]
59 docs_list = [item for sublist in docs for item in sublist]
60 text_splitter = RecursiveCharacterTextSplitter.from_tiktoken_encoder(
61 chunk_size=1000, chunk_overlap=0
62 )
63 doc_splits = text_splitter.split_documents(docs_list)
64 print("---CREATING NEW DOCUMENTS---")
65 vectorstore = Chroma.from_documents(
66 documents=doc_splits,
67 collection_name=collection_name,
68 embedding=OpenAIEmbeddings(),
69 )
70 create_record(collection_name, urls)
71 print(f"Collection '{collection_name}' created successfully.")
72 return vectorstore.as_retriever()
73
74def retrieve_documents(collection_name, question):
75 print("---RETRIEVING OLD DOCUMENTS---")

Callers 1

retrieveFunction · 0.85

Calls 1

create_recordFunction · 0.90

Tested by

no test coverage detected