Skip to content

update for 060 litellm callable updates #78

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

Merged
merged 3 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion guardrails_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.3"
__version__ = "0.1.0-alpha1"
18 changes: 3 additions & 15 deletions guardrails_api/utils/get_llm_callable.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
import litellm
from typing import Any, Awaitable, Callable, Union
from guardrails.utils.openai_utils import (
get_static_openai_create_func,
get_static_openai_chat_create_func,
get_static_openai_acreate_func,
get_static_openai_chat_acreate_func,
)
from guardrails_api_client.models.llm_resource import LLMResource


def get_llm_callable(
llm_api: str,
) -> Union[Callable, Callable[[Any], Awaitable[Any]]]:
# TODO: Add error handling and throw 400
if llm_api == LLMResource.OPENAI_DOT_COMPLETION_DOT_CREATE.value:
return get_static_openai_create_func()
elif llm_api == LLMResource.OPENAI_DOT_CHAT_COMPLETION_DOT_CREATE.value:
return get_static_openai_chat_create_func()
elif llm_api == LLMResource.OPENAI_DOT_COMPLETION_DOT_ACREATE.value:
return get_static_openai_acreate_func()
elif llm_api == LLMResource.OPENAI_DOT_CHAT_COMPLETION_DOT_ACREATE.value:
return get_static_openai_chat_acreate_func()
elif llm_api == LLMResource.LITELLM_DOT_COMPLETION.value:
# do we need this anymore if were going to use the default handling
# and only set model
if llm_api == LLMResource.LITELLM_DOT_COMPLETION.value:
return litellm.completion
elif llm_api == LLMResource.LITELLM_DOT_ACOMPLETION.value:
return litellm.acompletion
Expand Down