From e2a9cd0c75f357feef45f90b15d5994cee28ea63 Mon Sep 17 00:00:00 2001 From: Tom Matthews Date: Fri, 9 May 2025 19:39:23 +0100 Subject: [PATCH] Add nscale support for streaming (#10698) --- docs/my-website/docs/providers/nscale.md | 16 ++++++++++++++++ litellm/llms/nscale/chat/transformation.py | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/docs/my-website/docs/providers/nscale.md b/docs/my-website/docs/providers/nscale.md index 5ebd948db6..670d92a517 100644 --- a/docs/my-website/docs/providers/nscale.md +++ b/docs/my-website/docs/providers/nscale.md @@ -67,6 +67,22 @@ response = completion( print(response) ``` +```python showLineNumbers title="Nscale Text Generation - Streaming" +from litellm import completion +import os + +os.environ["NSCALE_API_KEY"] = "" # your Nscale API key +stream = completion( + model="nscale/meta-llama/Llama-4-Scout-17B-16E-Instruct", + messages=[{"role": "user", "content": "What is LiteLLM?"}], + stream=True +) + +for chunk in stream: + if chunk.choices[0].delta.content is not None: + print(chunk.choices[0].delta.content, end="") +``` + ### Image Generation ```python showLineNumbers title="Nscale Image Generation" diff --git a/litellm/llms/nscale/chat/transformation.py b/litellm/llms/nscale/chat/transformation.py index 2f7619c13e..6103b8e3c4 100644 --- a/litellm/llms/nscale/chat/transformation.py +++ b/litellm/llms/nscale/chat/transformation.py @@ -41,4 +41,12 @@ class NscaleConfig(OpenAIGPTConfig): "n", "temperature", "top_p", + "stream", + "logprobs", + "top_logprobs", + "frequency_penalty", + "presence_penalty", + "response_format", + "stop", + "logit_bias", ]