Spaces:
Build error
Build error
File size: 1,811 Bytes
dca7464 7009660 19b8811 1f84a9a 98639ab 1f84a9a 19b8811 7009660 e25050d 7009660 1f84a9a 98639ab 1f84a9a 766d56a 1f84a9a 98639ab 7009660 3ad0959 98639ab |
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# This script inits the models and adds an example collection to the Vectorstore
# %%
import os
import pathlib
from load_model import load_embedding
from utils import get_chroma_client
from load_vectors import load_from_web, create_and_add, load_and_split, metadata_generator
current_path = str( pathlib.Path(__file__).parent.resolve() )
with open(current_path+'/.openaiapikey', 'r') as reader:
os.environ['OPENAI_API_KEY']=reader.read()
import load_model
# %%
#load_model.load_gpu_model("decapoda-research/llama-7b-hf") #Download local model
#llm= load_model.load_openai_model()
# %%
#Load example Data
client = get_chroma_client()
client.reset()
ef = load_embedding("hkunlp/instructor-large")
collection_name="papers"
metadata= {"loaded_docs":[], "Subject":"Heikos Papers", "model_name": ef.model_name}
selected_collection = client.create_collection(collection_name, embedding_function=ef, metadata=metadata)
docs_tarifs= [
"https://edoc.hu-berlin.de/bitstream/handle/18452/5294/33.pdf",
"https://arxiv.org/pdf/1702.03556v3.pdf",
"https://arxiv.org/pdf/1706.03762"
]
# %%
# Load collection to get metadata
loaded_collection = client.get_collection(collection_name)
model_name = loaded_collection.metadata['model_name']
# %%
docs = load_from_web(docs_tarifs)
sub_docs = load_and_split(docs, chunk_size=1000)
create_and_add(collection_name, sub_docs, model_name, metadata)
# %%
llm= load_model.load_cpu_model()
chain = load_model.create_chain(llm, collection=collection_name, model_name=model_name, metadata=metadata)
result = chain({"query": "Ist mein Kinderwagen bei einem Leitungswasserschaden mitversichert?"})
print(result)
#llm= load_model.load_openai_model(temperature=0.1)
#llm= load_model.load_cpu_model()
#meta= metadata_generator(docs[0], llm)
# %%
#print(meta)
# %%
|