serge-chat / serge

A web interface for chatting with Alpaca through llama.cpp. Fully dockerized, with an easy to use API.
https://serge.chat
Apache License 2.0
5.68k stars 407 forks source link

MongoDB Issue on Apple M2 Silicon Chip #10

Closed nawalnew closed 1 year ago

nawalnew commented 1 year ago

Hello,

can someone please help to set up the Docker image on my Mac with M2 Chip. https://github.com/bitnami/containers/issues/14169 This solution seems not to work.

Would be great if a Solution comes up.

Thank you

jsonsmth commented 1 year ago

I had the same issue on my Mac with M1 chip. I installed MongoDB locally on my Mac using Homebrew and updated the .env file to point to the local host to connect to MongoDB. Here are some links that might be helpful:

https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-os-x/

https://stackoverflow.com/questions/65357744/how-to-install-mongodb-on-apple-m1-chip

Here's the updated MongoDB connection string in my .env file:

DATABASE_URL=mongodb://docker.for.mac.host.internal:27017/lms

nsarrazin commented 1 year ago

Oh interesting. Unfortunately I can't replicate this since I don't have a mac.

Could one of you try replacing this line in the docker compose file https://github.com/nsarrazin/serge/blob/b4c329286c8ce611ddcad2301aecfff09ae580fd/docker-compose.yml#L17 by

    image: mongo

and let me know if it works ?

kells1986 commented 1 year ago

I just tried changing the image tag and it didn't make any difference for me (I'm on M1).

Here's the traceback:

serge-api-1      | ERROR:    Traceback (most recent call last):
serge-api-1      |   File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 677, in lifespan
serge-api-1      |     async with self.lifespan_context(app) as maybe_state:
serge-api-1      |   File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 566, in __aenter__
serge-api-1      |     await self._router.startup()
serge-api-1      |   File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 654, in startup
serge-api-1      |     await handler()
serge-api-1      |   File "/usr/src/app/main.py", line 50, in start_database
serge-api-1      |     await initiate_database()
serge-api-1      |   File "/usr/src/app/utils/initiate_database.py", line 25, in initiate_database
serge-api-1      |     await init_beanie(
serge-api-1      |   File "/usr/local/lib/python3.10/dist-packages/beanie/odm/utils/init.py", line 528, in init_beanie
serge-api-1      |     await Initializer(
serge-api-1      |   File "/usr/local/lib/python3.10/dist-packages/beanie/odm/utils/init.py", line 89, in __await__
serge-api-1      |     yield from self.init_class(model).__await__()
serge-api-1      |   File "/usr/local/lib/python3.10/dist-packages/beanie/odm/utils/init.py", line 498, in init_class
serge-api-1      |     await self.init_document(cls)
serge-api-1      |   File "/usr/local/lib/python3.10/dist-packages/beanie/odm/utils/init.py", line 322, in init_document
serge-api-1      |     build_info = await self.database.command({"buildInfo": 1})
serge-api-1      |   File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
serge-api-1      |     result = self.fn(*self.args, **self.kwargs)
serge-api-1      |   File "/usr/local/lib/python3.10/dist-packages/pymongo/_csot.py", line 105, in csot_wrapper
serge-api-1      |     return func(self, *args, **kwargs)
serge-api-1      |   File "/usr/local/lib/python3.10/dist-packages/pymongo/database.py", line 805, in command
serge-api-1      |     with self.__client._socket_for_reads(read_preference, session) as (
serge-api-1      |   File "/usr/local/lib/python3.10/dist-packages/pymongo/mongo_client.py", line 1296, in _socket_for_reads
serge-api-1      |     server = self._select_server(read_preference, session)
serge-api-1      |   File "/usr/local/lib/python3.10/dist-packages/pymongo/mongo_client.py", line 1257, in _select_server
serge-api-1      |     server = topology.select_server(server_selector)
serge-api-1      |   File "/usr/local/lib/python3.10/dist-packages/pymongo/topology.py", line 272, in select_server
serge-api-1      |     server = self._select_server(selector, server_selection_timeout, address)
serge-api-1      |   File "/usr/local/lib/python3.10/dist-packages/pymongo/topology.py", line 261, in _select_server
serge-api-1      |     servers = self.select_servers(selector, server_selection_timeout, address)
serge-api-1      |   File "/usr/local/lib/python3.10/dist-packages/pymongo/topology.py", line 223, in select_servers
serge-api-1      |     server_descriptions = self._select_servers_loop(selector, server_timeout, address)
serge-api-1      |   File "/usr/local/lib/python3.10/dist-packages/pymongo/topology.py", line 238, in _select_servers_loop
serge-api-1      |     raise ServerSelectionTimeoutError(
serge-api-1      | pymongo.errors.ServerSelectionTimeoutError: mongodb:27017: [Errno 111] Connection refused, Timeout: 30s, Topology Description: <TopologyDescription id: 641b09503ff17e5cf2a90bc7, topology_type: Unknown, servers: [<ServerDescription ('mongodb', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('mongodb:27017: [Errno 111] Connection refused')>]>
serge-api-1      | 
serge-api-1      | ERROR:    Application startup failed. Exiting.

I'll try the workaround suggested above.

Great project, really excited to get it up and running!

kells1986 commented 1 year ago

OK, I think it might be working!

mongodb:
    image: mongo:6.0.4-jammy
    ports:
      - "27017"
    volumes:
      - data:/data/db

I'm not seeing any errors, but I've clicked "start new chat" and it's hanging.

nawalnew commented 1 year ago

Thank you all very much. @kells1986 Solution works. Thank you very much!!

I just cant chose a model, but this seems to have another problem.

nsarrazin commented 1 year ago

OK, I think it might be working!

mongodb:
    image: mongo:6.0.4-jammy
    ports:
      - "27017"
    volumes:
      - data:/data/db

I'm not seeing any errors, but I've clicked "start new chat" and it's hanging.

Alright good to hear! Also still works for me on linux so I pushed it to main with https://github.com/nsarrazin/serge/commit/b824261bbb27c62cd8ce8ae102958e1424eff1df

I think the bitnami image was the problem.

Feel free to open new issues if you find any bugs ! I can help fix them, this is a pretty new project so there might be things that work on my machine that don't work for others.

nawalnew commented 1 year ago

Thank you very much. I am excited to try it.