Download createDocuments.py from TheBobBob/BioModelsRAG: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/TheBobBob/BioModelsRAG/resolve/cf460dcbf329bb3dc82968bd568bce9b67dee9dd/createDocuments.py
- Command line
-
hf download hf://TheBobBob/BioModelsRAG@cf460dcbf329bb3dc82968bd568bce9b67dee9dd/createDocuments.py
-
curl -L -o createDocuments.py https://huggingface.co/TheBobBob/BioModelsRAG/resolve/cf460dcbf329bb3dc82968bd568bce9b67dee9dd/createDocuments.py
1.45 kB
| import ollama | |
| from typing import List | |
| import chromadb | |
| def createDocuments(final_items: List[str], collection: chromadb.Collection) -> List[str]: | |
| """Generates summaries of the BioModel chunks and adds them to the Chroma database collection | |
| Args: | |
| final_items (List[str]): The segmented BioModel database. | |
| collection (chromadb.Collection): The Chroma database collection. | |
| Returns: | |
| List[str]: The documents that are passed to the Chroma database are in string form. | |
| """ | |
| documents = [] | |
| for item in final_items: | |
| print(item) #option for reporting or not | |
| prompt = f"""Please summarize this segment of Antimony: {item}. The summaries must be clear and concise. | |
| For Display Names, provide the value for each variable. Expand mathematical functions into words. | |
| Cross reference all parts of the provided context. | |
| Explain well without errors and in an easily understandable way. Write in a list format.""" | |
| documents5 = ollama.generate(model="llama3", prompt=prompt) | |
| documents2 = documents5["response"] | |
| documents.append(documents2) | |
| # Add documents to the collection | |
| collection.add( | |
| documents=documents, | |
| ids=[f"id{i}" for i in range(len(documents))] | |
| ) | |
| return documents | |
| #unit test | |
| #documents = [] | |
| #assert(isinstance(documents, list)) | |
| #print("ok!") | |