Skip to content

Fix optional dependency loading and tokenizer handling - #116

Open
AyushRanjanRoy-01 wants to merge 1 commit into
SamuelSchmidgall:mainfrom
AyushRanjanRoy-01:fix/optional-deps-and-tokenizers
Open

Fix optional dependency loading and tokenizer handling#116
AyushRanjanRoy-01 wants to merge 1 commit into
SamuelSchmidgall:mainfrom
AyushRanjanRoy-01:fix/optional-deps-and-tokenizers

Conversation

@AyushRanjanRoy-01

Copy link
Copy Markdown

Fixes #99.
Addresses #100.

Summary

  • add the missing AgentRxiv/web dependencies to requirements.txt
  • make AgentRxiv imports lazy so the core CLI does not fail on optional web dependencies
  • make TensorFlow optional for core workflows instead of a hard startup dependency
  • replace mixed PyPDF2/pypdf usage with a single pypdf code path
  • centralize tokenizer selection and model alias handling for cost estimation and token counting
  • lazy-load Gemini so non-Gemini runs do not emit the SDK deprecation warning at startup
  • preserve API keys across retry helpers in utils.py
  • add a small regression test for tokenizer alias and cost-estimation behavior

Why these changes are needed

Issue #99 reports that a fresh install is missing runtime dependencies required by the current codebase. The repo also imports optional AgentRxiv and TensorFlow paths during normal CLI startup, which forces users to install packages they do not need for the main workflow.

This PR separates core and optional runtime paths:

  • the standard ai_lab_repo.py workflow can start without Flask, SQLAlchemy, sentence-transformers, or TensorFlow
  • AgentRxiv still works, but now fails with a clear message if its optional dependencies are not installed
  • the install instructions now match the dependencies used by the optional web workflow

Issue #100 reports intermittent tokenization errors during cost estimation. This PR fixes that by centralizing tokenizer lookup and using explicit encoding fallbacks for models like DeepSeek and the OpenAI reasoning family.

Verification

  • python -m unittest discover -s tests
  • python -m compileall ai_lab_repo.py app.py common_imports.py inference.py tokenization.py utils.py
  • imported inference and utils.count_tokens(...) successfully in a clean Python 3.12 environment
  • ran python ai_lab_repo.py --yaml-location "experiment_configs/MATH_agentlab.yaml" and confirmed it progresses into the research workflow instead of failing at startup

Notes

  • TensorFlow is intentionally left optional here. The current repository guidance and generated experiment prompts already steer the main workflow away from TensorFlow-backed code paths, so making it a hard install dependency would increase setup burden for the common case.

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.

Missing dependencies for the AgentLaboratory after major version update

1 participant