|
@@ -1,95 +1,95 @@
|
|
|
{
|
|
|
- "nbformat": 4,
|
|
|
- "nbformat_minor": 0,
|
|
|
- "metadata": {
|
|
|
- "colab": {
|
|
|
- "provenance": []
|
|
|
- },
|
|
|
- "kernelspec": {
|
|
|
- "name": "python3",
|
|
|
- "display_name": "Python 3"
|
|
|
- },
|
|
|
- "language_info": {
|
|
|
- "name": "python"
|
|
|
- }
|
|
|
- },
|
|
|
"cells": [
|
|
|
{
|
|
|
"cell_type": "markdown",
|
|
|
- "source": [
|
|
|
- "## Cookbook for using ElasticSearchDB with Embedchain"
|
|
|
- ],
|
|
|
"metadata": {
|
|
|
"id": "b02n_zJ_hl3d"
|
|
|
- }
|
|
|
+ },
|
|
|
+ "source": [
|
|
|
+ "## Cookbook for using ElasticSearchDB with Embedchain"
|
|
|
+ ]
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "markdown",
|
|
|
- "source": [
|
|
|
- "### Step-1: Install embedchain package"
|
|
|
- ],
|
|
|
"metadata": {
|
|
|
"id": "gyJ6ui2vhtMY"
|
|
|
- }
|
|
|
+ },
|
|
|
+ "source": [
|
|
|
+ "### Step-1: Install embedchain package"
|
|
|
+ ]
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
- "source": [
|
|
|
- "!pip install embedchain"
|
|
|
- ],
|
|
|
+ "execution_count": null,
|
|
|
"metadata": {
|
|
|
"id": "-NbXjAdlh0vJ"
|
|
|
},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "!pip install embedchain"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
"execution_count": null,
|
|
|
- "outputs": []
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "!pip install embedchain[dataloaders]"
|
|
|
+ ]
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "markdown",
|
|
|
+ "metadata": {
|
|
|
+ "id": "nGnpSYAAh2bQ"
|
|
|
+ },
|
|
|
"source": [
|
|
|
"### Step-2: Set OpenAI environment variables and install the dependencies.\n",
|
|
|
"\n",
|
|
|
"You can find this env variable on your [OpenAI dashboard](https://platform.openai.com/account/api-keys). Now lets install the dependencies needed for Elasticsearch."
|
|
|
- ],
|
|
|
- "metadata": {
|
|
|
- "id": "nGnpSYAAh2bQ"
|
|
|
- }
|
|
|
+ ]
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
- "source": [
|
|
|
- "!pip install --upgrade 'embedchain[elasticsearch]'"
|
|
|
- ],
|
|
|
+ "execution_count": null,
|
|
|
"metadata": {
|
|
|
"id": "-MUFRfxV7Jk7"
|
|
|
},
|
|
|
- "execution_count": null,
|
|
|
- "outputs": []
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "!pip install --upgrade 'embedchain[elasticsearch]'"
|
|
|
+ ]
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
+ "execution_count": null,
|
|
|
+ "metadata": {
|
|
|
+ "id": "0fBdQ9GAiRvK"
|
|
|
+ },
|
|
|
+ "outputs": [],
|
|
|
"source": [
|
|
|
"import os\n",
|
|
|
- "from embedchain import App\n",
|
|
|
+ "from embedchain import Pipeline as App\n",
|
|
|
"\n",
|
|
|
"os.environ[\"OPENAI_API_KEY\"] = \"sk-xxx\""
|
|
|
- ],
|
|
|
- "metadata": {
|
|
|
- "id": "0fBdQ9GAiRvK"
|
|
|
- },
|
|
|
- "execution_count": null,
|
|
|
- "outputs": []
|
|
|
+ ]
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "markdown",
|
|
|
- "source": [
|
|
|
- "### Step-3: Define your Vector Database config"
|
|
|
- ],
|
|
|
"metadata": {
|
|
|
"id": "Ns6RhPfbiitr"
|
|
|
- }
|
|
|
+ },
|
|
|
+ "source": [
|
|
|
+ "### Step-3: Define your Vector Database config"
|
|
|
+ ]
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
+ "execution_count": null,
|
|
|
+ "metadata": {
|
|
|
+ "id": "S9CkxVjriotB"
|
|
|
+ },
|
|
|
+ "outputs": [],
|
|
|
"source": [
|
|
|
"config = \"\"\"\n",
|
|
|
"vectordb:\n",
|
|
@@ -104,64 +104,64 @@
|
|
|
"# Write the multi-line string to a YAML file\n",
|
|
|
"with open('elasticsearch.yaml', 'w') as file:\n",
|
|
|
" file.write(config)"
|
|
|
- ],
|
|
|
- "metadata": {
|
|
|
- "id": "S9CkxVjriotB"
|
|
|
- },
|
|
|
- "execution_count": null,
|
|
|
- "outputs": []
|
|
|
+ ]
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "markdown",
|
|
|
- "source": [
|
|
|
- "### Step-4 Create embedchain app based on the config"
|
|
|
- ],
|
|
|
"metadata": {
|
|
|
"id": "PGt6uPLIi1CS"
|
|
|
- }
|
|
|
+ },
|
|
|
+ "source": [
|
|
|
+ "### Step-4 Create embedchain app based on the config"
|
|
|
+ ]
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
- "source": [
|
|
|
- "app = App.from_config(yaml_path=\"elasticsearch.yaml\")"
|
|
|
- ],
|
|
|
+ "execution_count": null,
|
|
|
"metadata": {
|
|
|
"id": "Amzxk3m-i3tD"
|
|
|
},
|
|
|
- "execution_count": null,
|
|
|
- "outputs": []
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "app = App.from_config(yaml_path=\"elasticsearch.yaml\")"
|
|
|
+ ]
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "markdown",
|
|
|
- "source": [
|
|
|
- "### Step-5: Add data sources to your app"
|
|
|
- ],
|
|
|
"metadata": {
|
|
|
"id": "XNXv4yZwi7ef"
|
|
|
- }
|
|
|
+ },
|
|
|
+ "source": [
|
|
|
+ "### Step-5: Add data sources to your app"
|
|
|
+ ]
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
- "source": [
|
|
|
- "app.add(\"https://www.forbes.com/profile/elon-musk\")"
|
|
|
- ],
|
|
|
+ "execution_count": null,
|
|
|
"metadata": {
|
|
|
"id": "Sn_0rx9QjIY9"
|
|
|
},
|
|
|
- "execution_count": null,
|
|
|
- "outputs": []
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "app.add(\"https://www.forbes.com/profile/elon-musk\")"
|
|
|
+ ]
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "markdown",
|
|
|
- "source": [
|
|
|
- "### Step-6: All set. Now start asking questions related to your data"
|
|
|
- ],
|
|
|
"metadata": {
|
|
|
"id": "_7W6fDeAjMAP"
|
|
|
- }
|
|
|
+ },
|
|
|
+ "source": [
|
|
|
+ "### Step-6: All set. Now start asking questions related to your data"
|
|
|
+ ]
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
+ "execution_count": null,
|
|
|
+ "metadata": {
|
|
|
+ "id": "cvIK7dWRjN_f"
|
|
|
+ },
|
|
|
+ "outputs": [],
|
|
|
"source": [
|
|
|
"while(True):\n",
|
|
|
" question = input(\"Enter question: \")\n",
|
|
@@ -169,12 +169,21 @@
|
|
|
" break\n",
|
|
|
" answer = app.query(question)\n",
|
|
|
" print(answer)"
|
|
|
- ],
|
|
|
- "metadata": {
|
|
|
- "id": "cvIK7dWRjN_f"
|
|
|
- },
|
|
|
- "execution_count": null,
|
|
|
- "outputs": []
|
|
|
+ ]
|
|
|
}
|
|
|
- ]
|
|
|
-}
|
|
|
+ ],
|
|
|
+ "metadata": {
|
|
|
+ "colab": {
|
|
|
+ "provenance": []
|
|
|
+ },
|
|
|
+ "kernelspec": {
|
|
|
+ "display_name": "Python 3",
|
|
|
+ "name": "python3"
|
|
|
+ },
|
|
|
+ "language_info": {
|
|
|
+ "name": "python"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "nbformat": 4,
|
|
|
+ "nbformat_minor": 0
|
|
|
+}
|