Skip to content

C7: move LLM catalogue and config to praisonai-code#2549

Merged
MervinPraison merged 2 commits into
feat/c7-llm-credentials-standalonefrom
feat/c7-llm-catalogue-config
Jul 1, 2026
Merged

C7: move LLM catalogue and config to praisonai-code#2549
MervinPraison merged 2 commits into
feat/c7-llm-credentials-standalonefrom
feat/c7-llm-catalogue-config

Conversation

@MervinPraison

Copy link
Copy Markdown
Owner

Summary

  • Move llm/catalogue.py and llm/config.py into praisonai_code so praisonai models list and AutoGen build_config_list work without the wrapper
  • Replace wrapper modules with identity-preserving shims; update env.py to load catalogue locally (no _wrapper_bridge hop)
  • Update models command and main.py; extend C5 compat tests and CI standalone smoke

Stacks on: #2548 (feat/c7-llm-credentials-standalone) β€” merge that first.

Test plan

  • pytest tests/unit/test_c5_backward_compat.py tests/unit/llm/test_env_resolver.py tests/unit/llm/test_credentials_is_configured.py β€” 90 passed
  • Standalone venv: ModelCatalogue().list_models(provider="openai") β€” 132 models
  • Zero praisonai.llm.* imports remain in praisonai-code
  • CI on merge

Model listing and AutoGen config_list building no longer import the wrapper;
shims preserve praisonai.llm.* module identity for backward compatibility.
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more β†’

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account β†’

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us β†’

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 30645cfd-2e33-446b-9c96-43211d32cd50

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • πŸ” Trigger review
✨ Finishing Touches
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/c7-llm-catalogue-config

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands.

@MervinPraison

Copy link
Copy Markdown
Owner Author

@copilot Do a thorough review of this PR. Read ALL existing reviewer comments above from Qodo, Coderabbit, and Gemini first β€” incorporate their findings.

Review areas:

  1. Bloat check: Are changes minimal and focused? Any unnecessary code or scope creep?
  2. Security: Any hardcoded secrets, unsafe eval/exec, missing input validation?
  3. Performance: Any module-level heavy imports? Hot-path regressions?
  4. Tests: Are tests included? Do they cover the changes adequately?
  5. Backward compat: Any public API changes without deprecation?
  6. Code quality: DRY violations, naming conventions, error handling?
  7. Address reviewer feedback: If Qodo, Coderabbit, or Gemini flagged valid issues, include them in your review
  8. Suggest specific improvements with code examples where possible

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request moves the implementation of ModelCatalogue and build_config_list from praisonai to praisonai_code to support standalone usage, replacing the old locations with backward-compatibility shims. Feedback on the changes suggests correcting a falsy check on model costs in catalogue.py to prevent zero-cost values from being ignored, and optimizing validate_model to avoid redundant calls to describe_model.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +250 to +251
input_cost=info.get("input_cost_per_token") * 1000 if info.get("input_cost_per_token") else None,
output_cost=info.get("output_cost_per_token") * 1000 if info.get("output_cost_per_token") else None,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

When retrieving the model cost from litellm, checking if info.get("input_cost_per_token") will treat a cost of 0 (which is common for free or local models) as falsy, causing it to fall back to None. Use an explicit is not None check to correctly preserve zero-cost values.

Suggested change
input_cost=info.get("input_cost_per_token") * 1000 if info.get("input_cost_per_token") else None,
output_cost=info.get("output_cost_per_token") * 1000 if info.get("output_cost_per_token") else None,
input_cost=info.get("input_cost_per_token") * 1000 if info.get("input_cost_per_token") is not None else None,
output_cost=info.get("output_cost_per_token") * 1000 if info.get("output_cost_per_token") is not None else None,

Comment on lines +448 to +453
if self.is_valid_model(model_id):
# Return the correctly cased version
info = self.describe_model(model_id)
if info:
return info["id"]
return model_id

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

In validate_model, calling self.is_valid_model(model_id) followed by self.describe_model(model_id) results in redundant passes over the models list (since is_valid_model internally calls describe_model). You can optimize this by calling describe_model once and checking if the result is not None.

Suggested change
if self.is_valid_model(model_id):
# Return the correctly cased version
info = self.describe_model(model_id)
if info:
return info["id"]
return model_id
info = self.describe_model(model_id)
if info:
return info["id"]

@greptile-apps

greptile-apps Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR moves the LLM catalogue and config helpers into praisonai_code. The main changes are:

  • Standalone praisonai_code.llm.catalogue and praisonai_code.llm.config modules.
  • CLI imports updated to use the standalone LLM modules.
  • Package-level exports added for the moved LLM helpers.
  • Wrapper LLM modules replaced with compatibility shims.
  • Tests and CI smoke coverage extended for the standalone path.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
src/praisonai-code/praisonai_code/llm/init.py Adds package-level bindings for the moved LLM catalogue and config helpers.
src/praisonai-code/praisonai_code/llm/catalogue.py Adds the standalone model catalogue implementation under praisonai_code.
src/praisonai-code/praisonai_code/llm/config.py Adds the standalone AutoGen-style config list builder.
src/praisonai/praisonai/llm/catalogue.py Replaces the wrapper catalogue implementation with a compatibility shim.
src/praisonai/praisonai/llm/config.py Replaces the wrapper config implementation with a compatibility shim.

Reviews (2): Last reviewed commit: "fix(c7): correct zero-cost handling, ded..." | Re-trigger Greptile

Comment thread src/praisonai-code/praisonai_code/llm/__init__.py
@MervinPraison

Copy link
Copy Markdown
Owner Author

@claude You are the FINAL architecture reviewer. If the branch is under MervinPraison/PraisonAI (not a fork), you are able to make modifications to this branch and push directly. SCOPE: Focus ONLY on Python packages (praisonaiagents, praisonai). Do NOT modify praisonai-rust or praisonai-ts. Read ALL comments above from Gemini, Qodo, CodeRabbit, and Copilot carefully before responding.

Phase 1: Review per AGENTS.md

  1. Protocol-driven: check heavy implementations vs core SDK
  2. Backward compatible: ensure zero feature regressions
  3. Performance: no hot-path regressions
  4. SDK value: review in depth whether the change genuinely adds value to the SDK β€” never add features for the sake of adding them. It must strengthen the SDK (simpler, more user-friendly, robust, world-class, secure). If it does not clearly add value, request changes or recommend rejecting/closing rather than merging scope creep
  5. Do not bloat the Agent class with additional params β€” only if absolutely required; we already support many params.

Phase 2: FIX Valid Issues
5. For any VALID bugs or architectural flaws found by Gemini, CodeRabbit, Qodo, Copilot, or any other reviewer: implement the fix
6. Push all code fixes directly to THIS branch (do NOT create a new PR)
7. Comment a summary of exact files modified and what you skipped

Phase 3: Final Verdict
8. If all issues are resolved, approve the PR / close the Issue
9. If blocking issues remain, request changes / leave clear action items

@MervinPraison MervinPraison added pipeline/blocked:ci Blocked: CI not green on HEAD pipeline/blocked:manual-review Blocked: requires manual review pipeline/blocked:cooldown Blocked: post-push or @claude cooldown pipeline/reviews-pending Waiting for CodeRabbit/Qodo/Copilot reviews labels Jul 1, 2026
@praisonai-triage-agent

praisonai-triage-agent Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Claude finished @MervinPraison's task β€”β€” View job


Final Architecture Review β€” PR #2549 (C7: LLM catalogue & config)

Verdict: βœ… Approve (all valid reviewer findings fixed and pushed to feat/c7-llm-catalogue-config)


Phase 1 β€” Architecture (AGENTS.md)

  • Routing: βœ… Correct. Heavy implementations (ModelCatalogue, build_config_list) live in the standalone praisonai-code package; praisonai/llm/* are identity shims (sys.modules[__name__] = _impl). This matches the C5/C6 pattern.
  • Backward compat: βœ… Shim identity preserved β€” praisonai.llm.catalogue.ModelCatalogue is praisonai_code.llm.catalogue.ModelCatalogue β†’ True. No public API regressions.
  • Performance: βœ… No hot-path regressions. litellm load remains lazy inside _load_from_litellm; catalogue load in env.py stays lazy. My validate_model fix removes a redundant full-list pass.
  • Agent class: βœ… Untouched β€” no param bloat.
  • SDK value: βœ… Genuine β€” enables praisonai models list and AutoGen build_config_list to work standalone without the wrapper bridge. Focused, no scope creep.

Phase 2 β€” Fixes implemented

# Finding (source) Status Fix
1 Zero-cost falsy check catalogue.py:250-251 (Gemini) βœ… Fixed if info.get(...) is not None β€” free/local models now keep 0.0 instead of None
2 Redundant describe_model in validate_model catalogue.py:447 (Gemini) βœ… Fixed Single describe_model() lookup instead of is_valid_model() + describe_model() double pass
3 __all__ names unbound in llm/__init__.py (Greptile) βœ… Fixed Bound all __all__ names (not just the 3 new ones β€” the endpoint/credential names were also unbound, so import * was fully broken). Verified from praisonai_code.llm import * now works

Files modified:

  • src/praisonai-code/praisonai_code/llm/catalogue.py
  • src/praisonai-code/praisonai_code/llm/__init__.py

Skipped / N/A:

  • Qodo: reviews paused (no findings). CodeRabbit: auto-review skipped on non-default base branch (no findings). Copilot: no substantive findings posted.
  • No security issues (no secrets/eval/exec). README.md, models.py, main.py, config.py, workflow, and shim edits are correct as-is.

Phase 3 β€” Tests

pytest tests/unit/test_c5_backward_compat.py \
       tests/unit/llm/test_env_resolver.py \
       tests/unit/llm/test_credentials_is_configured.py
β†’ 90 passed

Also verified: ModelCatalogue().validate_model('gpt-4o') and wildcard/named imports resolve; circular-import safe (catalogue import in env.py stays lazy).

Note: import * binding brings the whole env/credentials/catalogue module tree into the package namespace at import time. These are all lightweight (no heavy top-level deps; litellm stays lazy), so no import-cost regression.


Job run Β· Branch feat/c7-llm-catalogue-config Β· commit 7843c1a6f

…__all__

- catalogue.py: use 'is not None' so zero-cost (free/local) models keep 0.0 cost instead of falling back to None (Gemini)
- catalogue.py: validate_model now does a single describe_model lookup instead of is_valid_model + describe_model double pass (Gemini)
- llm/__init__.py: bind all names advertised in __all__ so 'from praisonai_code.llm import *' and named imports resolve (Greptile)

Co-authored-by: Mervin Praison <MervinPraison@users.noreply.github.com>
@MervinPraison

Copy link
Copy Markdown
Owner Author

@claude You are the FINAL architecture reviewer. If the branch is under MervinPraison/PraisonAI (not a fork), you are able to make modifications to this branch and push directly. SCOPE: Focus ONLY on Python packages (praisonaiagents, praisonai). Do NOT modify praisonai-rust or praisonai-ts. Read ALL comments above from Gemini, Qodo, CodeRabbit, and Copilot carefully before responding.

Phase 1: Review per AGENTS.md

  1. Protocol-driven: check heavy implementations vs core SDK
  2. Backward compatible: ensure zero feature regressions
  3. Performance: no hot-path regressions
  4. SDK value: review in depth whether the change genuinely adds value to the SDK β€” never add features for the sake of adding them. It must strengthen the SDK (simpler, more user-friendly, robust, world-class, secure). If it does not clearly add value, request changes or recommend rejecting/closing rather than merging scope creep
  5. Do not bloat the Agent class with additional params β€” only if absolutely required; we already support many params.

Phase 2: FIX Valid Issues
5. For any VALID bugs or architectural flaws found by Gemini, CodeRabbit, Qodo, Copilot, or any other reviewer: implement the fix
6. Push all code fixes directly to THIS branch (do NOT create a new PR)
7. Comment a summary of exact files modified and what you skipped

Phase 3: Final Verdict
8. If all issues are resolved, approve the PR / close the Issue
9. If blocking issues remain, request changes / leave clear action items

@praisonai-triage-agent

praisonai-triage-agent Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Claude finished @MervinPraison's task β€”β€” View job


Final Architecture Review β€” PR #2549 (C7: LLM catalogue & config)

Verdict: βœ… Approve β€” all valid reviewer findings are already fixed on this branch (commit 7843c1a6f); verified working. No new changes required.


Phase 1 β€” Architecture (AGENTS.md)

  • Routing βœ… Heavy implementations (ModelCatalogue, build_config_list) live in standalone praisonai-code; praisonai/llm/{catalogue,config}.py are identity shims (sys.modules[__name__] = _impl via ensure_praisonai_code()). Matches the C5/C6 pattern.
  • Backward compat βœ… Shim identity preserved β€” praisonai.llm.catalogue is praisonai_code.llm.catalogue. No public API regressions.
  • Performance βœ… No hot-path regressions. litellm load stays lazy inside _load_from_litellm; catalogue load in env.py stays lazy. The validate_model fix removes a redundant list pass.
  • Agent class βœ… Untouched β€” no param bloat.
  • SDK value βœ… Genuine β€” enables praisonai models list and AutoGen build_config_list standalone without the wrapper bridge. Focused, no scope creep.

Phase 2 β€” Reviewer findings (all already resolved on branch)

# Finding (source) Status Verification
1 Zero-cost falsy check catalogue.py:250-251 (Gemini) βœ… Fixed ... is not None else None present β€” free/local models keep 0.0
2 Redundant describe_model in validate_model catalogue.py:447-450 (Gemini) βœ… Fixed Single describe_model() lookup; if info: return info["id"]
3 __all__ names unbound in llm/__init__.py (Greptile) βœ… Fixed All __all__ names bound (incl. endpoint/credential names); from praisonai_code.llm import * verified working

Skipped / N/A: Qodo (reviews paused, no findings) Β· CodeRabbit (auto-review skipped on non-default base, no findings) Β· Copilot (no substantive findings). No security issues (no secrets/eval/exec). Shims, models.py, main.py, env.py, README, and CI workflow edits are correct as-is.

Phase 3 β€” Tests

pytest tests/unit/test_c5_backward_compat.py \
       tests/unit/llm/test_env_resolver.py \
       tests/unit/llm/test_credentials_is_configured.py
β†’ 90 passed

Also verified in a fresh interpreter:

  • from praisonai_code.llm import * β†’ ModelCatalogue, ModelInfo, build_config_list all resolve
  • ModelCatalogue().validate_model('gpt-4o') β†’ gpt-4o

Note: import * binding pulls env/credentials/catalogue into the package namespace at import time β€” all lightweight (no heavy top-level deps; litellm stays lazy), so no import-cost regression.

No files modified in this run (branch already clean at 7843c1a6f). βœ… Ready to merge (after its base #2548).


Job run Β· Branch feat/c7-llm-catalogue-config Β· commit 7843c1a6f

@MervinPraison MervinPraison removed the pipeline/blocked:ci Blocked: CI not green on HEAD label Jul 1, 2026
@MervinPraison MervinPraison merged commit 3e6fa0f into feat/c7-llm-credentials-standalone Jul 1, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pipeline/blocked:cooldown Blocked: post-push or @claude cooldown pipeline/blocked:manual-review Blocked: requires manual review pipeline/reviews-pending Waiting for CodeRabbit/Qodo/Copilot reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant