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

feat(llms): default values for default_llm_factories #209

Merged
merged 7 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/ragbits-core/src/ragbits/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class CoreConfig(BaseModel):
prompt_path_pattern: str = "**/prompt_*.py"

# Path to a functions that returns LLM objects, e.g. "my_project.llms.get_llm"
default_llm_factories: dict[LLMType, str | None] = {
LLMType.TEXT: None,
LLMType.VISION: None,
LLMType.STRUCTURED_OUTPUT: None,
default_llm_factories: dict[LLMType, str] = {
LLMType.TEXT: "ragbits.core.llms.factory.simple_litellm_factory",
LLMType.VISION: "ragbits.core.llms.factory.simple_litellm_vision_factory",
LLMType.STRUCTURED_OUTPUT: "ragbits.core.llms.factory.simple_litellm_structured_output_factory",
}


Expand Down
14 changes: 11 additions & 3 deletions packages/ragbits-core/src/ragbits/core/llms/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ def get_default_llm(llm_type: LLMType = LLMType.TEXT) -> LLM:
if llm_type not in core_config.default_llm_factories:
raise ValueError(f"Default LLM of type {llm_type} is not defined in pyproject.toml config.")
factory = core_config.default_llm_factories[llm_type]
if factory is None:
raise ValueError("Default LLM factory is not set")

return get_llm_from_factory(factory)


Expand All @@ -75,3 +72,14 @@ def simple_litellm_vision_factory() -> LLM:
LLM: An instance of the LiteLLM.
"""
return LiteLLM(model_name="gpt-4o-mini")


def simple_litellm_structured_output_factory() -> LLM:
"""
A basic LLM factory that creates an LiteLLM instance with the structured output.
Functionality supported
kdziedzic68 marked this conversation as resolved.
Show resolved Hide resolved

Returns:
LLM: An instance of the LiteLLM.
kdziedzic68 marked this conversation as resolved.
Show resolved Hide resolved
"""
return LiteLLM(model_name="gpt-4o-mini-2024-07-18", use_structured_output=True)
Loading