From 56e2b006f5744e3cc0908884257b91a3134d7333 Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Thu, 26 Jun 2025 10:47:26 -0400 Subject: [PATCH] Update NimLLMService docstrings --- src/pipecat/services/nim/llm.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/pipecat/services/nim/llm.py b/src/pipecat/services/nim/llm.py index d57fa8d4c..a637a6602 100644 --- a/src/pipecat/services/nim/llm.py +++ b/src/pipecat/services/nim/llm.py @@ -4,6 +4,12 @@ # 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.processors.aggregators.openai_llm_context import OpenAILLMContext 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). Args: - api_key (str): 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" - model (str, optional): The model identifier to use. Defaults to "nvidia/llama-3.1-nemotron-70b-instruct" - **kwargs: Additional keyword arguments passed to OpenAILLMService + api_key: The API key for accessing NVIDIA's NIM API. + base_url: The base URL for NIM API. Defaults to "https://integrate.api.nvidia.com/v1". + model: The model identifier to use. Defaults to "nvidia/llama-3.1-nemotron-70b-instruct". + **kwargs: Additional keyword arguments passed to OpenAILLMService. """ def __init__( @@ -47,8 +53,8 @@ class NimLLMService(OpenAILLMService): them once at the end of processing. Args: - context (OpenAILLMContext): The context to process, containing messages - and other information needed for the LLM interaction. + context: The context to process, containing messages and other information + needed for the LLM interaction. """ # Reset all counters and flags at the start of processing self._prompt_tokens = 0 @@ -79,8 +85,8 @@ class NimLLMService(OpenAILLMService): The final accumulated totals are reported at the end of processing. Args: - tokens (LLMTokenUsage): The token usage metrics for the current chunk - of processing, containing prompt_tokens and completion_tokens counts. + tokens: The token usage metrics for the current chunk of processing, + containing prompt_tokens and completion_tokens counts. """ # Only accumulate metrics during active processing if not self._is_processing: