Delete createDocuments.py
Browse files- createDocuments.py +0 -42
createDocuments.py
DELETED
@@ -1,42 +0,0 @@
|
|
1 |
-
import ollama
|
2 |
-
from typing import List
|
3 |
-
import chromadb
|
4 |
-
|
5 |
-
def createDocuments(final_items: List[str], collection: chromadb.Collection) -> List[str]:
|
6 |
-
"""Generates summaries of the BioModel chunks and adds them to the Chroma database collection
|
7 |
-
|
8 |
-
Args:
|
9 |
-
final_items (List[str]): The segmented BioModel database.
|
10 |
-
collection (chromadb.Collection): The Chroma database collection.
|
11 |
-
|
12 |
-
Returns:
|
13 |
-
List[str]: The documents that are passed to the Chroma database are in string form.
|
14 |
-
"""
|
15 |
-
|
16 |
-
documents = []
|
17 |
-
for item in final_items:
|
18 |
-
print(item) #option for reporting or not
|
19 |
-
prompt = f"""Please summarize this segment of Antimony: {item}. The summaries must be clear and concise.
|
20 |
-
For Display Names, provide the value for each variable. Expand mathematical functions into words.
|
21 |
-
Cross reference all parts of the provided context.
|
22 |
-
Explain well without errors and in an easily understandable way. Write in a list format."""
|
23 |
-
documents5 = ollama.generate(model="llama3", prompt=prompt)
|
24 |
-
documents2 = documents5["response"]
|
25 |
-
documents.append(documents2)
|
26 |
-
|
27 |
-
# Add documents to the collection
|
28 |
-
collection.add(
|
29 |
-
documents=documents,
|
30 |
-
ids=[f"id{i}" for i in range(len(documents))]
|
31 |
-
)
|
32 |
-
|
33 |
-
return documents
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
#unit test
|
38 |
-
#documents = []
|
39 |
-
#assert(isinstance(documents, list))
|
40 |
-
#print("ok!")
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|