lhenault / simpleAI

An easy way to host your own AI API and expose alternative models, while being compatible with "open" AI clients.

Home Page:https://pypi.org/project/simple-ai-server/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Module not found error after pip install

SupreethRao99 opened this issue · comments

Hello, I've installed time library through pip pip install simple_ai_server and I'm getting the following error ModuleNotFoundError: No module named 'simple_ai.api' could you suggest a fix for this issue. Thanks

Hi thanks for the feedback! The latest release on PyPi is actually a bit outdated at this point.

I should tag and upload a newer version in the upcoming days, as we’ve fixed a few issues, and added new features, but was waiting for some to be merged.

The easiest fix here is to install from the repository:

pip install git+https://github.com/lhenault/simpleAI.git

Edit: don’t forget to first uninstall the Pypi one.

Hi, thank you @lhenault,i will definitely do that.

slightly off topic, but while running the container, I see "[::]:50051" as the default port. does this expose the port 50051 on the localhost, as I'm having a bit of trouble getting the completions to work

That’s correct, the provided function to launch a gRPC server uses port 50051 by default. If you’re exposing a model through Docker you indeed have to open and redirect the 50051 port (which is done through the -p 50051:50051 argument in the docker command in the examples README).

Thanks again @lhenault , another observation I made is that is that python>3.11 is required to run simple_ai serve [--host 127.0.0.1] [--port 8080] as it has a dependency on tomllib. am I doing something wrong ? the error occurred while installing from source as well as installing from pip. Thank You!

This should have been addressed here, so it shouldn’t occur anymore if you install from source.

I was able to get to work, by switching to python 3.11 where tomllib is supported. it seems like I'm on the home stretch now, but when I send a POST request, I'm getting the following error

Traceback (most recent call last):
  File "<conda-env-path>/lib/python3.11/site-packages/uvicorn/protocols/http/h11_impl.py", line 429, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<conda-env-path>/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<conda-env-path>/lib/python3.11/site-packages/fastapi/applications.py", line 276, in __call__
    await super().__call__(scope, receive, send)
  File "<conda-env-path>/lib/python3.11/site-packages/starlette/applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "<conda-env-path>/lib/python3.11/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "<conda-env-path>/lib/python3.11/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "<conda-env-path>/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "<conda-env-path>/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "<conda-env-path>/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "<conda-env-path>/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "<conda-env-path>/lib/python3.11/site-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "<conda-env-path>/lib/python3.11/site-packages/starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "<conda-env-path>/lib/python3.11/site-packages/starlette/routing.py", line 66, in app
    response = await func(request)
               ^^^^^^^^^^^^^^^^^^^
  File "<conda-env-path>/lib/python3.11/site-packages/fastapi/routing.py", line 237, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<conda-env-path>/lib/python3.11/site-packages/fastapi/routing.py", line 163, in run_endpoint_function
    return await dependant.call(**values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<conda-env-path>/lib/python3.11/site-packages/simple_ai/server.py", line 51, in complete
    predictions = llm.complete(
                  ^^^^^^^^^^^^^
  File "<conda-env-path>/lib/python3.11/site-packages/simple_ai/models.py", line 35, in complete
    return lm_client.run(
           ^^^^^^^^^^^^^^
  File "<conda-env-path>/lib/python3.11/site-packages/simple_ai/clients/completion/client.py", line 41, in run
    with grpc.insecure_channel(url) as channel:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<conda-env-path>/lib/python3.11/site-packages/grpc/__init__.py", line 1964, in insecure_channel
    return _channel.Channel(target, () if options is None else options, None,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<conda-env-path>/lib/python3.11/site-packages/grpc/_channel.py", line 1649, in __init__
    _common.encode(target), _augment_options(core_options, compression),
    ^^^^^^^^^^^^^^^^^^^^^^
  File "<conda-env-path>/lib/python3.11/site-packages/grpc/_common.py", line 74, in encode
    return s.encode('utf8')
           ^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'encode'

Could you help me with this? Thank you @lhenault

Looks like we’re moving forward! :)

I’d need to have a look at your toml config and request to help further here. It looks like some parameter is passed as None instead of a string and cannot be encoded, so my best guess is a parameter you’ve forgotten.

hey, here's my toml file

[vicuna-13b]
    [vicuna-13b.metadata]
        owned_by    = 'Meta'
        permission  = []
        description = 'Instruction Tuned LLaMA running on 8bit precision'
    [model.network]
        type = 'gRPC'
        url = 'localhost:50051'


thanks @lhenault , had to fix my toml file, to this

[vicuna-13b]
    [vicuna-13b.metadata]
        owned_by    = 'Meta'
        permission  = []
        description = 'Instruction Tuned LLaMA running on 8bit precision'
    [vicuna-13b.network]
        type = 'gRPC'
        url = 'localhost:50051'

worked perfectly,