Add Novita AI LLM service provider
This commit is contained in:
13
src/pipecat/services/novita/__init__.py
Normal file
13
src/pipecat/services/novita/__init__.py
Normal file
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# Copyright (c) 2024-2026, Daily
|
||||
#
|
||||
# SPDX-License-Identifier: BSD 2-Clause License
|
||||
#
|
||||
|
||||
import sys
|
||||
|
||||
from pipecat.services import DeprecatedModuleProxy
|
||||
|
||||
from .llm import *
|
||||
|
||||
sys.modules[__name__] = DeprecatedModuleProxy(globals(), "novita", "novita.llm")
|
||||
81
src/pipecat/services/novita/llm.py
Normal file
81
src/pipecat/services/novita/llm.py
Normal file
@@ -0,0 +1,81 @@
|
||||
#
|
||||
# Copyright (c) 2024-2026, Daily
|
||||
#
|
||||
# SPDX-License-Identifier: BSD 2-Clause License
|
||||
#
|
||||
|
||||
"""Novita AI LLM service implementation using OpenAI-compatible interface."""
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional
|
||||
|
||||
from loguru import logger
|
||||
|
||||
from pipecat.services.openai.base_llm import BaseOpenAILLMService
|
||||
from pipecat.services.openai.llm import OpenAILLMService
|
||||
|
||||
|
||||
@dataclass
|
||||
class NovitaLLMSettings(BaseOpenAILLMService.Settings):
|
||||
"""Settings for NovitaLLMService."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class NovitaLLMService(OpenAILLMService):
|
||||
"""A service for interacting with Novita AI's API using the OpenAI-compatible interface.
|
||||
|
||||
This service extends OpenAILLMService to connect to Novita AI's API endpoint while
|
||||
maintaining full compatibility with OpenAI's interface and functionality.
|
||||
"""
|
||||
|
||||
Settings = NovitaLLMSettings
|
||||
_settings: Settings
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
api_key: str,
|
||||
base_url: str = "https://api.novita.ai/openai",
|
||||
model: Optional[str] = None,
|
||||
settings: Optional[Settings] = None,
|
||||
**kwargs,
|
||||
):
|
||||
"""Initialize Novita AI LLM service.
|
||||
|
||||
Args:
|
||||
api_key: The API key for accessing Novita AI's API.
|
||||
base_url: The base URL for Novita AI API. Defaults to "https://api.novita.ai/openai".
|
||||
model: The model identifier to use. Defaults to "moonshotai/kimi-k2.5".
|
||||
|
||||
.. deprecated:: 0.0.105
|
||||
Use ``settings=NovitaLLMService.Settings(model=...)`` instead.
|
||||
|
||||
settings: Runtime-updatable settings. When provided alongside deprecated
|
||||
parameters, ``settings`` values take precedence.
|
||||
**kwargs: Additional keyword arguments passed to OpenAILLMService.
|
||||
"""
|
||||
default_settings = self.Settings(model="moonshotai/kimi-k2.5")
|
||||
|
||||
if model is not None:
|
||||
self._warn_init_param_moved_to_settings("model", "model")
|
||||
default_settings.model = model
|
||||
|
||||
if settings is not None:
|
||||
default_settings.apply_update(settings)
|
||||
|
||||
super().__init__(api_key=api_key, base_url=base_url, settings=default_settings, **kwargs)
|
||||
|
||||
def create_client(self, api_key=None, base_url=None, **kwargs):
|
||||
"""Create OpenAI-compatible client for Novita AI API endpoint.
|
||||
|
||||
Args:
|
||||
api_key: The API key to use for the client. If None, uses instance api_key.
|
||||
base_url: The base URL for the API. If None, uses instance base_url.
|
||||
**kwargs: Additional keyword arguments passed to the parent create_client method.
|
||||
|
||||
Returns:
|
||||
An OpenAI-compatible client configured for Novita AI's API.
|
||||
"""
|
||||
logger.debug(f"Creating Novita AI client with api {base_url}")
|
||||
return super().create_client(api_key, base_url, **kwargs)
|
||||
Reference in New Issue
Block a user