├── 1-ollama-langchain ├── requirements.txt └── main.py ├── 2-ollama-privateGPT-chat-with-docs ├── requirements.txt ├── constants.py ├── pyproject.toml ├── README.md ├── privateGPT.py ├── ingest.py └── LICENSE ├── README.md └── LICENSE /1-ollama-langchain/requirements.txt: -------------------------------------------------------------------------------- 1 | langchain -------------------------------------------------------------------------------- /2-ollama-privateGPT-chat-with-docs/requirements.txt: -------------------------------------------------------------------------------- 1 | langchain==0.0.274 2 | gpt4all==1.0.8 3 | chromadb==0.4.7 4 | llama-cpp-python==0.1.81 5 | urllib3==2.0.4 6 | PyMuPDF==1.23.5 7 | python-dotenv==1.0.0 8 | unstructured==0.10.8 9 | extract-msg==0.45.0 10 | tabulate==0.9.0 11 | pandoc==2.3 12 | pypandoc==1.11 13 | tqdm==4.66.1 14 | sentence_transformers==2.2.2 -------------------------------------------------------------------------------- /1-ollama-langchain/main.py: -------------------------------------------------------------------------------- 1 | from langchain.callbacks.manager import CallbackManager 2 | from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler 3 | from langchain.llms import Ollama 4 | 5 | llm = Ollama( 6 | model="mistral", callback_manager=CallbackManager([StreamingStdOutCallbackHandler()]) 7 | ) 8 | 9 | print(llm("Tell me about the history of AI")) -------------------------------------------------------------------------------- /2-ollama-privateGPT-chat-with-docs/constants.py: -------------------------------------------------------------------------------- 1 | import os 2 | from chromadb.config import Settings 3 | 4 | # Define the folder for storing database 5 | PERSIST_DIRECTORY = os.environ.get('PERSIST_DIRECTORY', 'db') 6 | 7 | # Define the Chroma settings 8 | CHROMA_SETTINGS = Settings( 9 | persist_directory=PERSIST_DIRECTORY, 10 | anonymized_telemetry=False 11 | ) 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ollama 2 | This repo brings numerous use cases from the Open Source Ollama 3 | 4 | # Step 1 5 | Go Ahead to https://ollama.ai/ and download the set up file 6 | 7 | # Step 2 8 | Install and Start the Software 9 | 10 | # Step 3 11 | Clone my Entire Repo on your local device using the command 12 | git clone https://github.com/PromptEngineer48/Ollama.git 13 | 14 | # Step 4 15 | The Repo has numerous working case as separate Folders. You can work on any folder for testing various use cases 16 | 17 | # Step 5 18 | Join me on my Journey on my youtube channel 19 | https://www.youtube.com/@PromptEngineer48/ 20 | -------------------------------------------------------------------------------- /2-ollama-privateGPT-chat-with-docs/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "privategpt" 3 | version = "0.1.0" 4 | description = "" 5 | authors = ["Ivan Martinez "] 6 | license = "Apache Version 2.0" 7 | readme = "README.md" 8 | 9 | [tool.poetry.dependencies] 10 | python = "^3.10" 11 | langchain = "0.0.261" 12 | gpt4all = "^1.0.3" 13 | chromadb = "^0.3.26" 14 | PyMuPDF = "^1.22.5" 15 | python-dotenv = "^1.0.0" 16 | unstructured = "^0.8.0" 17 | extract-msg = "^0.41.5" 18 | tabulate = "^0.9.0" 19 | pandoc = "^2.3" 20 | pypandoc = "^1.11" 21 | tqdm = "^4.65.0" 22 | sentence-transformers = "^2.2.2" 23 | 24 | [build-system] 25 | requires = ["poetry-core"] 26 | build-backend = "poetry.core.masonry.api" 27 | -------------------------------------------------------------------------------- /2-ollama-privateGPT-chat-with-docs/README.md: -------------------------------------------------------------------------------- 1 | #### Inspired from (https://github.com/imartinez/privateGPT) and (https://github.com/jmorganca/ollama) 2 | 3 | #### Step 1: Step a Virtual Environment 4 | 5 | #### Step 2: Install the Requirements 6 | ``` 7 | pip install -r requirements.txt 8 | ``` 9 | 10 | #### Step 3: Pull the models (if you already have models loaded in Ollama, then not required) 11 | #### Make sure to have Ollama running on your system from https://ollama.ai 12 | ``` 13 | ollama pull mistral 14 | ``` 15 | 16 | #### Step 4: put your files in the source_documents folder after making a directory 17 | ``` 18 | mkdir source_documents 19 | ``` 20 | 21 | #### Step 5: Ingest the files (use python3 if on mac) 22 | ``` 23 | python ingest.py 24 | ``` 25 | 26 | Output should look like this: 27 | ```shell 28 | Creating new vectorstore 29 | Loading documents from source_documents 30 | Loading new documents: 100%|██████████████████████| 1/1 [00:01<00:00, 1.99s/it] 31 | Loaded 235 new documents from source_documents 32 | Split into 1268 chunks of text (max. 500 tokens each) 33 | Creating embeddings. May take some minutes... 34 | Ingestion complete! You can now run privateGPT.py to query your documents 35 | ``` 36 | 37 | #### Step 6: Run this command (use python3 if on mac) 38 | ``` 39 | python privateGPT.py 40 | ``` 41 | 42 | ##### Play with your docs 43 | Enter a query: How many locations does WeWork have? 44 | 45 | 46 | ### Try with a different model: 47 | ``` 48 | ollama pull llama2:13b 49 | MODEL=llama2:13b python privateGPT.py 50 | ``` 51 | 52 | ## Add more files 53 | 54 | Put any and all your files into the `source_documents` directory 55 | 56 | The supported extensions are: 57 | 58 | - `.csv`: CSV, 59 | - `.docx`: Word Document, 60 | - `.doc`: Word Document, 61 | - `.enex`: EverNote, 62 | - `.eml`: Email, 63 | - `.epub`: EPub, 64 | - `.html`: HTML File, 65 | - `.md`: Markdown, 66 | - `.msg`: Outlook Message, 67 | - `.odt`: Open Document Text, 68 | - `.pdf`: Portable Document Format (PDF), 69 | - `.pptx` : PowerPoint Document, 70 | - `.ppt` : PowerPoint Document, 71 | - `.txt`: Text file (UTF-8), 72 | -------------------------------------------------------------------------------- /2-ollama-privateGPT-chat-with-docs/privateGPT.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from langchain.chains import RetrievalQA 3 | from langchain.embeddings import HuggingFaceEmbeddings 4 | from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler 5 | from langchain.vectorstores import Chroma 6 | from langchain.llms import Ollama 7 | import chromadb 8 | import os 9 | import argparse 10 | import time 11 | 12 | model = os.environ.get("MODEL", "mistral") 13 | # For embeddings model, the example uses a sentence-transformers model 14 | # https://www.sbert.net/docs/pretrained_models.html 15 | # "The all-mpnet-base-v2 model provides the best quality, while all-MiniLM-L6-v2 is 5 times faster and still offers good quality." 16 | embeddings_model_name = os.environ.get("EMBEDDINGS_MODEL_NAME", "all-MiniLM-L6-v2") 17 | persist_directory = os.environ.get("PERSIST_DIRECTORY", "db") 18 | target_source_chunks = int(os.environ.get('TARGET_SOURCE_CHUNKS',4)) 19 | 20 | from constants import CHROMA_SETTINGS 21 | 22 | def main(): 23 | # Parse the command line arguments 24 | args = parse_arguments() 25 | embeddings = HuggingFaceEmbeddings(model_name=embeddings_model_name) 26 | 27 | db = Chroma(persist_directory=persist_directory, embedding_function=embeddings) 28 | 29 | retriever = db.as_retriever(search_kwargs={"k": target_source_chunks}) 30 | # activate/deactivate the streaming StdOut callback for LLMs 31 | callbacks = [] if args.mute_stream else [StreamingStdOutCallbackHandler()] 32 | 33 | llm = Ollama(model=model, callbacks=callbacks) 34 | 35 | qa = RetrievalQA.from_chain_type(llm=llm, chain_type="stuff", retriever=retriever, return_source_documents= not args.hide_source) 36 | # Interactive questions and answers 37 | while True: 38 | query = input("\nEnter a query: ") 39 | if query == "exit": 40 | break 41 | if query.strip() == "": 42 | continue 43 | 44 | # Get the answer from the chain 45 | start = time.time() 46 | res = qa(query) 47 | answer, docs = res['result'], [] if args.hide_source else res['source_documents'] 48 | end = time.time() 49 | 50 | # Print the result 51 | print("\n\n> Question:") 52 | print(query) 53 | print(answer) 54 | 55 | # Print the relevant sources used for the answer 56 | for document in docs: 57 | print("\n> " + document.metadata["source"] + ":") 58 | print(document.page_content) 59 | 60 | def parse_arguments(): 61 | parser = argparse.ArgumentParser(description='privateGPT: Ask questions to your documents without an internet connection, ' 62 | 'using the power of LLMs.') 63 | parser.add_argument("--hide-source", "-S", action='store_true', 64 | help='Use this flag to disable printing of source documents used for answers.') 65 | 66 | parser.add_argument("--mute-stream", "-M", 67 | action='store_true', 68 | help='Use this flag to disable the streaming StdOut callback for LLMs.') 69 | 70 | return parser.parse_args() 71 | 72 | 73 | if __name__ == "__main__": 74 | main() 75 | -------------------------------------------------------------------------------- /2-ollama-privateGPT-chat-with-docs/ingest.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import os 3 | import glob 4 | from typing import List 5 | from multiprocessing import Pool 6 | from tqdm import tqdm 7 | 8 | from langchain.document_loaders import ( 9 | CSVLoader, 10 | EverNoteLoader, 11 | PyMuPDFLoader, 12 | TextLoader, 13 | UnstructuredEmailLoader, 14 | UnstructuredEPubLoader, 15 | UnstructuredHTMLLoader, 16 | UnstructuredMarkdownLoader, 17 | UnstructuredODTLoader, 18 | UnstructuredPowerPointLoader, 19 | UnstructuredWordDocumentLoader, 20 | ) 21 | 22 | from langchain.text_splitter import RecursiveCharacterTextSplitter 23 | from langchain.vectorstores import Chroma 24 | from langchain.embeddings import HuggingFaceEmbeddings 25 | from langchain.docstore.document import Document 26 | from constants import CHROMA_SETTINGS 27 | 28 | 29 | # Load environment variables 30 | persist_directory = os.environ.get('PERSIST_DIRECTORY', 'db') 31 | source_directory = os.environ.get('SOURCE_DIRECTORY', 'source_documents') 32 | embeddings_model_name = os.environ.get('EMBEDDINGS_MODEL_NAME', 'all-MiniLM-L6-v2') 33 | chunk_size = 500 34 | chunk_overlap = 50 35 | 36 | # Custom document loaders 37 | class MyElmLoader(UnstructuredEmailLoader): 38 | """Wrapper to fallback to text/plain when default does not work""" 39 | 40 | def load(self) -> List[Document]: 41 | """Wrapper adding fallback for elm without html""" 42 | try: 43 | try: 44 | doc = UnstructuredEmailLoader.load(self) 45 | except ValueError as e: 46 | if 'text/html content not found in email' in str(e): 47 | # Try plain text 48 | self.unstructured_kwargs["content_source"]="text/plain" 49 | doc = UnstructuredEmailLoader.load(self) 50 | else: 51 | raise 52 | except Exception as e: 53 | # Add file_path to exception message 54 | raise type(e)(f"{self.file_path}: {e}") from e 55 | 56 | return doc 57 | 58 | 59 | # Map file extensions to document loaders and their arguments 60 | LOADER_MAPPING = { 61 | ".csv": (CSVLoader, {}), 62 | # ".docx": (Docx2txtLoader, {}), 63 | ".doc": (UnstructuredWordDocumentLoader, {}), 64 | ".docx": (UnstructuredWordDocumentLoader, {}), 65 | ".enex": (EverNoteLoader, {}), 66 | ".eml": (MyElmLoader, {}), 67 | ".epub": (UnstructuredEPubLoader, {}), 68 | ".html": (UnstructuredHTMLLoader, {}), 69 | ".md": (UnstructuredMarkdownLoader, {}), 70 | ".odt": (UnstructuredODTLoader, {}), 71 | ".pdf": (PyMuPDFLoader, {}), 72 | ".ppt": (UnstructuredPowerPointLoader, {}), 73 | ".pptx": (UnstructuredPowerPointLoader, {}), 74 | ".txt": (TextLoader, {"encoding": "utf8"}), 75 | # Add more mappings for other file extensions and loaders as needed 76 | } 77 | 78 | 79 | def load_single_document(file_path: str) -> List[Document]: 80 | ext = "." + file_path.rsplit(".", 1)[-1] 81 | if ext in LOADER_MAPPING: 82 | loader_class, loader_args = LOADER_MAPPING[ext] 83 | loader = loader_class(file_path, **loader_args) 84 | return loader.load() 85 | 86 | raise ValueError(f"Unsupported file extension '{ext}'") 87 | 88 | def load_documents(source_dir: str, ignored_files: List[str] = []) -> List[Document]: 89 | """ 90 | Loads all documents from the source documents directory, ignoring specified files 91 | """ 92 | all_files = [] 93 | for ext in LOADER_MAPPING: 94 | all_files.extend( 95 | glob.glob(os.path.join(source_dir, f"**/*{ext}"), recursive=True) 96 | ) 97 | filtered_files = [file_path for file_path in all_files if file_path not in ignored_files] 98 | 99 | with Pool(processes=os.cpu_count()) as pool: 100 | results = [] 101 | with tqdm(total=len(filtered_files), desc='Loading new documents', ncols=80) as pbar: 102 | for i, docs in enumerate(pool.imap_unordered(load_single_document, filtered_files)): 103 | results.extend(docs) 104 | pbar.update() 105 | 106 | return results 107 | 108 | def process_documents(ignored_files: List[str] = []) -> List[Document]: 109 | """ 110 | Load documents and split in chunks 111 | """ 112 | print(f"Loading documents from {source_directory}") 113 | documents = load_documents(source_directory, ignored_files) 114 | if not documents: 115 | print("No new documents to load") 116 | exit(0) 117 | print(f"Loaded {len(documents)} new documents from {source_directory}") 118 | text_splitter = RecursiveCharacterTextSplitter(chunk_size=chunk_size, chunk_overlap=chunk_overlap) 119 | texts = text_splitter.split_documents(documents) 120 | print(f"Split into {len(texts)} chunks of text (max. {chunk_size} tokens each)") 121 | return texts 122 | 123 | def does_vectorstore_exist(persist_directory: str) -> bool: 124 | """ 125 | Checks if vectorstore exists 126 | """ 127 | if os.path.exists(os.path.join(persist_directory, 'index')): 128 | if os.path.exists(os.path.join(persist_directory, 'chroma-collections.parquet')) and os.path.exists(os.path.join(persist_directory, 'chroma-embeddings.parquet')): 129 | list_index_files = glob.glob(os.path.join(persist_directory, 'index/*.bin')) 130 | list_index_files += glob.glob(os.path.join(persist_directory, 'index/*.pkl')) 131 | # At least 3 documents are needed in a working vectorstore 132 | if len(list_index_files) > 3: 133 | return True 134 | return False 135 | 136 | def main(): 137 | # Create embeddings 138 | embeddings = HuggingFaceEmbeddings(model_name=embeddings_model_name) 139 | 140 | if does_vectorstore_exist(persist_directory): 141 | # Update and store locally vectorstore 142 | print(f"Appending to existing vectorstore at {persist_directory}") 143 | db = Chroma(persist_directory=persist_directory, embedding_function=embeddings, client_settings=CHROMA_SETTINGS) 144 | collection = db.get() 145 | texts = process_documents([metadata['source'] for metadata in collection['metadatas']]) 146 | print(f"Creating embeddings. May take some minutes...") 147 | db.add_documents(texts) 148 | else: 149 | # Create and store locally vectorstore 150 | print("Creating new vectorstore") 151 | texts = process_documents() 152 | print(f"Creating embeddings. May take some minutes...") 153 | db = Chroma.from_documents(texts, embeddings, persist_directory=persist_directory) 154 | db.persist() 155 | db = None 156 | 157 | print(f"Ingestion complete! You can now run privateGPT.py to query your documents") 158 | 159 | 160 | if __name__ == "__main__": 161 | main() 162 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /2-ollama-privateGPT-chat-with-docs/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------