Repository navigation
Conversation
api_key was typed as str, but the method already implements and documents an explicit ValueError for api_key is None. That branch is real: podcast.py sources the key via os.getenv, which returns None when the env var is unset, and set_api_key() forwards it here unchanged. Widen the annotation to str | None so it matches the reachable, implemented behavior, and rename the method to _get_litellm_object per the maintainer's comment on biocypher#306 since it is not part of the public API. Fixes biocypher#306
Author
|
No rush, just checking in about a week after opening. CI on this fork hasn't run yet since it needs a maintainer to approve the workflow run for a first-time contributor, so let me know if there's anything else you'd like changed in the meantime. |
Author
|
Closing to keep the queue clean; happy to reopen if there's interest. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
LiteLLMConversation.get_litellm_object()declaredapi_key: str, but the method'sown docstring and body document and implement a
ValueErrorforapi_key is None.That branch is real, not hypothetical:
set_api_key()forwards itsapi_keyargument here unchanged, and
biochatter/podcast.pycallsset_api_key(api_key=os.getenv("OPENAI_API_KEY"), ...), which isNonewheneverthat environment variable is unset. The declared type contradicted the implemented
and documented behavior.
Fix
Widened the annotation to
api_key: str | None, matching the siblingimplementations in
openrouter.pyandlangchain.py, which already type thisparameter the same way. Also renamed the method to
_get_litellm_object, per@slobentanzer's comment on #306: it is not part of the public API.
Verification
test/test_llm_connect/test_litellm_conversation.py: one assertsthe annotation now includes
NoneType(fails on main, passes on this branch),one asserts the documented
ValueErrorfires forapi_key=None.pytest test/test_llm_connect/: 119 passed. 3 pre-existing failures areunrelated to this change (the
xinferenceoptional dependency group, notinstalled in my local run) and reproduce identically on unmodified
main.ruff check/ruff formaton both changed files: no new violations beyondthe four
SLF001hits from the rename itself, consistent with how this filealready tests other private methods directly.
xinferenceextra and the full CI matrix, sinceinstalling
torchlocally exceeded available disk on my machine.Fixes #306