From 2f6ba642c7d30cee509b33f9bc51be7cb0a671e7 Mon Sep 17 00:00:00 2001 From: Taranjeet Singh Date: Tue, 2 Jan 2024 05:48:25 -0800 Subject: [PATCH] feat: Add private ai example (#1101) --- examples/private-ai/README.md | 26 ++++++++++++++++++++++++++ examples/private-ai/config.yaml | 10 ++++++++++ examples/private-ai/privateai.py | 15 +++++++++++++++ examples/private-ai/requirements.txt | 1 + 4 files changed, 52 insertions(+) create mode 100644 examples/private-ai/README.md create mode 100644 examples/private-ai/config.yaml create mode 100644 examples/private-ai/privateai.py create mode 100644 examples/private-ai/requirements.txt diff --git a/examples/private-ai/README.md b/examples/private-ai/README.md new file mode 100644 index 00000000..c0739ced --- /dev/null +++ b/examples/private-ai/README.md @@ -0,0 +1,26 @@ +# Private AI + +In this example, we will create a private AI using embedchain. + +Private AI is useful when you want to chat with your data and you dont want to spend money and your data should stay on your machine. + +## How to install + +First create a virtual environment and install the requirements by running + +```bash +pip install -r requirements.txt +``` + +## How to use + +* Now open privateai.py file and change the line `app.add` to point to your directory or data source. +* If you want to add any other data type, you can browse the supported data types [here](https://docs.embedchain.ai/components/data-sources/overview) + +* Now simply run the file by + +```bash +python privateai.py +``` + +* Now you can enter and ask any questions from your data. \ No newline at end of file diff --git a/examples/private-ai/config.yaml b/examples/private-ai/config.yaml new file mode 100644 index 00000000..bc243f34 --- /dev/null +++ b/examples/private-ai/config.yaml @@ -0,0 +1,10 @@ +llm: + provider: gpt4all + config: + model: 'orca-mini-3b-gguf2-q4_0.gguf' + max_tokens: 1000 + top_p: 1 +embedder: + provider: huggingface + config: + model: 'sentence-transformers/all-MiniLM-L6-v2' \ No newline at end of file diff --git a/examples/private-ai/privateai.py b/examples/private-ai/privateai.py new file mode 100644 index 00000000..25c2738d --- /dev/null +++ b/examples/private-ai/privateai.py @@ -0,0 +1,15 @@ +from embedchain import App + +app = App.from_config("config.yaml") +app.add("/path/to/your/folder", data_type="directory") + +while True: + user_input = input("Enter your question (type 'exit' to quit): ") + + # Break the loop if the user types 'exit' + if user_input.lower() == 'exit': + break + + # Process the input and provide a response + response = app.chat(user_input) + print(response) diff --git a/examples/private-ai/requirements.txt b/examples/private-ai/requirements.txt new file mode 100644 index 00000000..3ad57c3a --- /dev/null +++ b/examples/private-ai/requirements.txt @@ -0,0 +1 @@ +"embedchain[opensource]" \ No newline at end of file