Skip to content
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
19 changes: 8 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ together = [
"together",
]

sambanova = [
"instructor",
]

ollama = [
"ollama>=0.5.1"
]
Expand All @@ -94,19 +90,20 @@ sagemaker = [

# These providers don't require any additional dependencies, but are included for completeness.
azureopenai = []
moonshot = []
nebius = []
databricks = []
deepseek = []
fireworks = []
inception = []
openai = []
portkey = []
openrouter = []
lmstudio = []
llama = []
llamafile = []
llamacpp = []
llamafile = []
lmstudio = []
moonshot = []
nebius = []
openai = []
openrouter = []
portkey = []
sambanova = []

[project.urls]
Documentation = "https://mozilla-ai.github.io/any-llm/"
Expand Down
45 changes: 0 additions & 45 deletions src/any_llm/providers/sambanova/sambanova.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
from collections.abc import AsyncIterator
from typing import Any, cast

from pydantic import BaseModel

from any_llm.providers.openai.base import BaseOpenAIProvider
from any_llm.types.completion import ChatCompletion, ChatCompletionChunk, CompletionParams
from any_llm.utils.instructor import _convert_instructor_response

MISSING_PACKAGES_ERROR = None
try:
import instructor

except ImportError as e:
MISSING_PACKAGES_ERROR = e


class SambanovaProvider(BaseOpenAIProvider):
Expand All @@ -21,35 +7,4 @@ class SambanovaProvider(BaseOpenAIProvider):
PROVIDER_NAME = "sambanova"
PROVIDER_DOCUMENTATION_URL = "https://sambanova.ai/"

MISSING_PACKAGES_ERROR = MISSING_PACKAGES_ERROR
SUPPORTS_COMPLETION_PDF = False

async def _acompletion(
self, params: CompletionParams, **kwargs: Any
) -> ChatCompletion | AsyncIterator[ChatCompletionChunk]:
"""Make the API call to SambaNova service with instructor for structured output."""

if params.reasoning_effort == "auto":
params.reasoning_effort = None

if params.response_format:
instructor_client = instructor.from_openai(self.client)
if not isinstance(params.response_format, type) or not issubclass(params.response_format, BaseModel):
msg = "response_format must be a pydantic model"
raise ValueError(msg)
response = await instructor_client.chat.completions.create(
model=params.model_id,
messages=cast("Any", params.messages),
response_model=params.response_format,
**params.model_dump(exclude_none=True, exclude={"model_id", "messages", "response_format"}),
**kwargs,
)
return _convert_instructor_response(response, params.model_id, self.PROVIDER_NAME)
return self._convert_completion_response_async(
await self.client.chat.completions.create(
model=params.model_id,
messages=cast("Any", params.messages),
**params.model_dump(exclude_none=True, exclude={"model_id", "messages"}),
**kwargs,
)
)
1 change: 0 additions & 1 deletion tests/unit/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ def test_providers_raise_MissingApiKeyError(provider: LLMProvider) -> None:
("huggingface", "huggingface_hub"),
("mistral", "mistralai"),
("ollama", "ollama"),
("sambanova", "instructor"),
("together", "together"),
("voyage", "voyageai"),
("watsonx", "ibm_watsonx_ai"),
Expand Down