Update NimLLMService docstrings
This commit is contained in:
@@ -4,6 +4,12 @@
|
|||||||
# SPDX-License-Identifier: BSD 2-Clause License
|
# SPDX-License-Identifier: BSD 2-Clause License
|
||||||
#
|
#
|
||||||
|
|
||||||
|
"""NVIDIA NIM API service implementation.
|
||||||
|
|
||||||
|
This module provides a service for interacting with NVIDIA's NIM (NVIDIA Inference
|
||||||
|
Microservice) API while maintaining compatibility with the OpenAI-style interface.
|
||||||
|
"""
|
||||||
|
|
||||||
from pipecat.metrics.metrics import LLMTokenUsage
|
from pipecat.metrics.metrics import LLMTokenUsage
|
||||||
from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext
|
from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext
|
||||||
from pipecat.services.openai.llm import OpenAILLMService
|
from pipecat.services.openai.llm import OpenAILLMService
|
||||||
@@ -17,10 +23,10 @@ class NimLLMService(OpenAILLMService):
|
|||||||
in token usage reporting between NIM (incremental) and OpenAI (final summary).
|
in token usage reporting between NIM (incremental) and OpenAI (final summary).
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
api_key (str): The API key for accessing NVIDIA's NIM API
|
api_key: The API key for accessing NVIDIA's NIM API.
|
||||||
base_url (str, optional): The base URL for NIM API. Defaults to "https://integrate.api.nvidia.com/v1"
|
base_url: The base URL for NIM API. Defaults to "https://integrate.api.nvidia.com/v1".
|
||||||
model (str, optional): The model identifier to use. Defaults to "nvidia/llama-3.1-nemotron-70b-instruct"
|
model: The model identifier to use. Defaults to "nvidia/llama-3.1-nemotron-70b-instruct".
|
||||||
**kwargs: Additional keyword arguments passed to OpenAILLMService
|
**kwargs: Additional keyword arguments passed to OpenAILLMService.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
@@ -47,8 +53,8 @@ class NimLLMService(OpenAILLMService):
|
|||||||
them once at the end of processing.
|
them once at the end of processing.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
context (OpenAILLMContext): The context to process, containing messages
|
context: The context to process, containing messages and other information
|
||||||
and other information needed for the LLM interaction.
|
needed for the LLM interaction.
|
||||||
"""
|
"""
|
||||||
# Reset all counters and flags at the start of processing
|
# Reset all counters and flags at the start of processing
|
||||||
self._prompt_tokens = 0
|
self._prompt_tokens = 0
|
||||||
@@ -79,8 +85,8 @@ class NimLLMService(OpenAILLMService):
|
|||||||
The final accumulated totals are reported at the end of processing.
|
The final accumulated totals are reported at the end of processing.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
tokens (LLMTokenUsage): The token usage metrics for the current chunk
|
tokens: The token usage metrics for the current chunk of processing,
|
||||||
of processing, containing prompt_tokens and completion_tokens counts.
|
containing prompt_tokens and completion_tokens counts.
|
||||||
"""
|
"""
|
||||||
# Only accumulate metrics during active processing
|
# Only accumulate metrics during active processing
|
||||||
if not self._is_processing:
|
if not self._is_processing:
|
||||||
|
|||||||
Reference in New Issue
Block a user