Spaces:
No application file
No application file
File size: 2,498 Bytes
a85c9b8 |
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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
{
"cells": [
{
"cell_type": "markdown",
"id": "553f2e71",
"metadata": {},
"source": [
"## Embedchain chromadb server example"
]
},
{
"cell_type": "markdown",
"id": "513e12e6",
"metadata": {},
"source": [
"This notebook shows an example of how you can use embedchain with chromdb (server). \n",
"\n",
"\n",
"First, run chroma inside docker using the following command:\n",
"\n",
"\n",
"```bash\n",
"git clone https://github.com/chroma-core/chroma\n",
"cd chroma && docker-compose up -d --build\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "92e7ad71",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"from embedchain import App\n",
"from embedchain.config import AppConfig\n",
"\n",
"\n",
"chromadb_host = \"localhost\"\n",
"chromadb_port = 8000\n",
"\n",
"config = AppConfig(host=chromadb_host, port=chromadb_port)\n",
"elon_bot = App(config)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "1a6d6841",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"All data from https://en.wikipedia.org/wiki/Elon_Musk already exists in the database.\n",
"All data from https://www.tesla.com/elon-musk already exists in the database.\n"
]
}
],
"source": [
"# Embed Online Resources\n",
"elon_bot.add(\"web_page\", \"https://en.wikipedia.org/wiki/Elon_Musk\")\n",
"elon_bot.add(\"web_page\", \"https://www.tesla.com/elon-musk\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "34cda99c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Elon Musk runs four companies: Tesla, SpaceX, Neuralink, and The Boring Company.'"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"elon_bot.query(\"How many companies does Elon Musk run?\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|