cohere-toolkit icon indicating copy to clipboard operation
cohere-toolkit copied to clipboard

fix: missing field in api response causing backend failure

Open ryuzio opened this issue 1 year ago • 4 comments

Thank you for contributing to the Cohere Toolkit!

  • Description: Backend failed to start due to missing field in API response for listing models. See details:

Logs:

...
INFO:     Finished server process [46]
Process SpawnProcess-5:
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/usr/local/lib/python3.11/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/workspace/.venv/lib/python3.11/site-packages/uvicorn/_subprocess.py", line 78, in subprocess_started
    target(sockets=sockets)
  File "/workspace/.venv/lib/python3.11/site-packages/uvicorn/server.py", line 62, in run
    return asyncio.run(self.serve(sockets=sockets))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
  File "/workspace/.venv/lib/python3.11/site-packages/uvicorn/server.py", line 69, in serve
    config.load()
  File "/workspace/.venv/lib/python3.11/site-packages/uvicorn/config.py", line 458, in load
    self.loaded_app = import_from_string(self.app)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspace/.venv/lib/python3.11/site-packages/uvicorn/importer.py", line 21, in import_from_string
    module = importlib.import_module(module_str)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/workspace/src/backend/main.py", line 9, in <module>
    from backend.routers.chat import router as chat_router
  File "/workspace/src/backend/routers/__init__.py", line 1, in <module>
    from backend.routers.chat import *
  File "/workspace/src/backend/routers/chat.py", line 14, in <module>
    from backend.chat.custom.custom import CustomChat
  File "/workspace/src/backend/chat/custom/custom.py", line 8, in <module>
    from backend.chat.custom.model_deployments.deployment import get_deployment
  File "/workspace/src/backend/chat/custom/model_deployments/deployment.py", line 2, in <module>
    from backend.config.deployments import AVAILABLE_MODEL_DEPLOYMENTS, ModelDeploymentName
  File "/workspace/src/backend/config/deployments.py", line 25, in <module>
    models=CohereDeployment.list_models(),
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspace/src/backend/chat/custom/model_deployments/cohere_platform.py", line 44, in list_models
    return [
           ^
  File "/workspace/src/backend/chat/custom/model_deployments/cohere_platform.py", line 47, in <listcomp>
    if "chat" in model["endpoints"]
                 ~~~~~^^^^^^^^^^^^^
KeyError: 'endpoints'

Response causing the issue:

[
...
{'name': 'a8daa33b-50db-40c3-a910-52f6421095a8-ft', 'finetuned': True, 'context_length': 512, 'tokenizer_url': None, 'default_endpoints': []},
{'name': 'bb80b1b9-1259-451f-b7b9-cad03b45489f-ft', 'finetuned': True, 'context_length': 512, 'tokenizer_url': None, 'default_endpoints': []}
]
  • [x] Lint and test: Run make lint and make run-tests

ryuzio avatar May 03 '24 23:05 ryuzio

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar May 03 '24 23:05 CLAassistant

We did some refactoring that led to conflicts. Would you mind resolving them? Then I can go ahead and merge the PR

lusmoura avatar May 08 '24 09:05 lusmoura

I see your commits are not signed, and this is a requirement to merge the PR 😅. You can find information about how to do it here.

lusmoura avatar May 08 '24 12:05 lusmoura

Sure, no problem. I'll quickly educate myself about signing commits in GitHub and update shortly. Thanks for looking into this PR!

ryuzio avatar May 08 '24 12:05 ryuzio

Hello Luisa, I've updated the PR with signed commits and brought it up to date with main branch. Please let me know if there's anything else needed from me. Thank you!

ryuzio avatar May 09 '24 15:05 ryuzio

thanks @ryuzio, merging this in!

scott-cohere avatar May 09 '24 22:05 scott-cohere