simulatrex / simulatrex-engine

Enable decision-making based on simulations
https://simulatrex.com
Apache License 2.0
218 stars 21 forks source link

Add missing dep to requirements #29

Closed ulfaslak closed 4 months ago

ulfaslak commented 5 months ago

Was getting an import error for anthropic when running the server app:

(env) ➜  api git:(develop) uvicorn server:app --reload --loop asyncio
INFO:     Will watch for changes in these directories: ['/Users/ulfaslak/Desktop/simulatrex-engine/api']
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [44495] using WatchFiles
Process SpawnProcess-1:
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.10/3.10.13_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/opt/homebrew/Cellar/python@3.10/3.10.13_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/ulfaslak/Desktop/simulatrex-engine/env/lib/python3.10/site-packages/uvicorn/_subprocess.py", line 78, in subprocess_started
    target(sockets=sockets)
  File "/Users/ulfaslak/Desktop/simulatrex-engine/env/lib/python3.10/site-packages/uvicorn/server.py", line 65, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "/opt/homebrew/Cellar/python@3.10/3.10.13_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/opt/homebrew/Cellar/python@3.10/3.10.13_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/Users/ulfaslak/Desktop/simulatrex-engine/env/lib/python3.10/site-packages/uvicorn/server.py", line 69, in serve
    await self._serve(sockets)
  File "/Users/ulfaslak/Desktop/simulatrex-engine/env/lib/python3.10/site-packages/uvicorn/server.py", line 76, in _serve
    config.load()
  File "/Users/ulfaslak/Desktop/simulatrex-engine/env/lib/python3.10/site-packages/uvicorn/config.py", line 433, in load
    self.loaded_app = import_from_string(self.app)
  File "/Users/ulfaslak/Desktop/simulatrex-engine/env/lib/python3.10/site-packages/uvicorn/importer.py", line 22, in import_from_string
    raise exc from None
  File "/Users/ulfaslak/Desktop/simulatrex-engine/env/lib/python3.10/site-packages/uvicorn/importer.py", line 19, in import_from_string
    module = importlib.import_module(module_str)
  File "/opt/homebrew/Cellar/python@3.10/3.10.13_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/ulfaslak/Desktop/simulatrex-engine/api/server.py", line 11, in <module>
    from simulatrex.dsl_parser import (
  File "/Users/ulfaslak/Desktop/simulatrex-engine/src/simulatrex/dsl_parser.py", line 1, in <module>
    from simulatrex.simulation_entities import Agent, Simulation, Environment
  File "/Users/ulfaslak/Desktop/simulatrex-engine/src/simulatrex/simulation_entities.py", line 2, in <module>
    from simulatrex.llms.models.models import OpenAILanguageModel
  File "/Users/ulfaslak/Desktop/simulatrex-engine/src/simulatrex/llms/models/models.py", line 19, in <module>
    import instructor
  File "/Users/ulfaslak/Desktop/simulatrex-engine/env/lib/python3.10/site-packages/instructor/__init__.py", line 4, in <module>
    from .process_response import handle_response_model
  File "/Users/ulfaslak/Desktop/simulatrex-engine/env/lib/python3.10/site-packages/instructor/process_response.py", line 6, in <module>
    from instructor.dsl.iterable import IterableBase, IterableModel
  File "/Users/ulfaslak/Desktop/simulatrex-engine/env/lib/python3.10/site-packages/instructor/dsl/__init__.py", line 1, in <module>
    from .iterable import IterableModel
  File "/Users/ulfaslak/Desktop/simulatrex-engine/env/lib/python3.10/site-packages/instructor/dsl/iterable.py", line 6, in <module>
    from instructor.function_calls import OpenAISchema
  File "/Users/ulfaslak/Desktop/simulatrex-engine/env/lib/python3.10/site-packages/instructor/function_calls.py", line 18, in <module>
    from instructor.utils import classproperty, extract_json_from_codeblock
  File "/Users/ulfaslak/Desktop/simulatrex-engine/env/lib/python3.10/site-packages/instructor/utils.py", line 16, in <module>
    from anthropic.types import Usage as AnthropicUsage
ModuleNotFoundError: No module named 'anthropic'
^CINFO:     Stopping reloader process [44495]

Fixed by adding anthropic to requirements.txt.

ulfaslak commented 5 months ago

Otherwise, your setup instructions works 👌