Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: missing field in api response causing backend failure #99

Merged

Conversation

ryuzio
Copy link
Contributor

@ryuzio ryuzio commented May 3, 2024

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': []}
]
  • Lint and test: Run make lint and make run-tests

@ryuzio ryuzio requested a review from a team as a code owner May 3, 2024 23:01
@CLAassistant
Copy link

CLAassistant commented May 3, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@lusmoura lusmoura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! Thank for contributing

@lusmoura
Copy link
Contributor

lusmoura commented May 8, 2024

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

@ryuzio ryuzio force-pushed the bugfix/missing-field-in-api-response branch from 2e5d3e6 to 204a293 Compare May 8, 2024 12:33
@lusmoura
Copy link
Contributor

lusmoura commented May 8, 2024

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.

@ryuzio
Copy link
Contributor Author

ryuzio commented May 8, 2024

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

@ryuzio ryuzio force-pushed the bugfix/missing-field-in-api-response branch from 204a293 to df7c9e0 Compare May 8, 2024 12:59
@ryuzio ryuzio force-pushed the bugfix/missing-field-in-api-response branch from df7c9e0 to af771e0 Compare May 8, 2024 13:12
@ryuzio
Copy link
Contributor Author

ryuzio commented May 9, 2024

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!

@scott-cohere
Copy link
Contributor

thanks @ryuzio, merging this in!

@scott-cohere scott-cohere merged commit ee939e1 into cohere-ai:main May 9, 2024
2 checks passed
@ryuzio ryuzio deleted the bugfix/missing-field-in-api-response branch May 9, 2024 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants