mem0ai / mem0

The Memory layer for your AI apps
https://mem0.ai
Apache License 2.0
21.89k stars 2k forks source link

Error when initiating embedchain app in flask on docker #526

Open arihantparsoya opened 1 year ago

arihantparsoya commented 1 year ago

🐛 Describe the bug

When trying to add embedchain app in a flask project and running it on docker, I am getting the following error.

embedchain-server-1  | Traceback (most recent call last):
embedchain-server-1  |   File "/app/app.py", line 8, in <module>
embedchain-server-1  |     from api.chat import chat_api
embedchain-server-1  |   File "/app/api/chat.py", line 6, in <module>
embedchain-server-1  |     embedchain_bot = App()
embedchain-server-1  |                      ^^^^^
embedchain-server-1  |   File "/usr/local/lib/python3.11/site-packages/embedchain/embedchain.py", line 344, in __init__
embedchain-server-1  |     config._set_db_to_default()
embedchain-server-1  |   File "/usr/local/lib/python3.11/site-packages/embedchain/config/InitConfig.py", line 68, in _set_db_to_default
embedchain-server-1  |     self.db = ChromaDB(ef=self.ef, host=self.host, port=self.port)
embedchain-server-1  |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
embedchain-server-1  |   File "/usr/local/lib/python3.11/site-packages/embedchain/vectordb/chroma_db.py", line 31, in __init__
embedchain-server-1  |     super().__init__()
embedchain-server-1  |   File "/usr/local/lib/python3.11/site-packages/embedchain/vectordb/base_vector_db.py", line 6, in __init__
embedchain-server-1  |     self.collection = self._get_or_create_collection()
embedchain-server-1  |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
embedchain-server-1  |   File "/usr/local/lib/python3.11/site-packages/embedchain/vectordb/chroma_db.py", line 39, in _get_or_create_collection
embedchain-server-1  |     return self.client.get_or_create_collection(
embedchain-server-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
embedchain-server-1  |   File "/usr/local/lib/python3.11/site-packages/chromadb/api/local.py", line 141, in get_or_create_collection
embedchain-server-1  |     return self.create_collection(
embedchain-server-1  |            ^^^^^^^^^^^^^^^^^^^^^^^
embedchain-server-1  |   File "/usr/local/lib/python3.11/site-packages/chromadb/api/local.py", line 110, in create_collection
embedchain-server-1  |     res = self._db.create_collection(name, metadata, get_or_create)
embedchain-server-1  |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
embedchain-server-1  |   File "/usr/local/lib/python3.11/site-packages/chromadb/db/duckdb.py", line 98, in create_collection
embedchain-server-1  |     dupe_check = self.get_collection(name)
embedchain-server-1  |                  ^^^^^^^^^^^^^^^^^^^^^^^^^
embedchain-server-1  |   File "/usr/local/lib/python3.11/site-packages/chromadb/db/duckdb.py", line 123, in get_collection
embedchain-server-1  |     res = self._conn.execute(
embedchain-server-1  |           ^^^^^^^^^^^^^^^^^^^
embedchain-server-1  | duckdb.InvalidInputException: Invalid Input Error: Required module 'pandas.core.arrays.arrow.dtype' failed to import, due to the following Python exception:
embedchain-server-1  | ModuleNotFoundError: No module named 'pandas.core.arrays.arrow.dtype'

Python Code

from flask import Flask, jsonify, request
from flask_cors import CORS
from embedchain import App
import os

app = Flask(__name__)
CORS(app, origins="*")

embedchain_bot = App()

if __name__ == '__main__':
    app.run(debug=True, host='0.0.0.0', port=4000)

I am using python:3.11 image to run the flask project and have installed the dependencies before starting the project.

DOCKERFILE

# Use an official Python runtime as a parent image
FROM python:3.11

# Set the working directory in the container
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.python.org -r requirements.txt

# Make port 4000 available to the world outside this container
EXPOSE 4000

# Define environment variable
ENV NAME World

# Run app.py when the container launches
CMD ["python", "app.py"]
arihantparsoya commented 1 year ago

They are facing same issues: https://github.com/oobabooga/text-generation-webui/issues/3762

taranjeet commented 9 months ago

assigning @sidmohanty11

sidmohanty11 commented 9 months ago

Hey @arihantparsoya, can you please tell what version of embedchain are you using?

Also, can you please try using the latest version? I think that should fix the issue,

In our newer versions, we use Pipeline instead of App, you can achieve the same by,

from flask import Flask, jsonify, request
from flask_cors import CORS
from embedchain import Pipeline as App
import os

app = Flask(__name__)
CORS(app, origins="*")

embedchain_bot = App()

if __name__ == '__main__':
    app.run(debug=True, host='0.0.0.0', port=4000)

Please let me know if you encounter any issues