From fa200e1bbfa9038b9cae62c542e920572ec14c98 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Sat, 14 Jun 2025 15:35:27 -0700 Subject: [PATCH] sdk: update --- sdk/package-lock.json | 4 +- sdk/package.json | 2 +- sdk/types/package-lock.json | 4 +- sdk/types/package.json | 2 +- .../scrypted_python/scrypted_sdk/types.py | 60 ++++++++++++++++++- sdk/types/src/types.input.ts | 8 ++- 6 files changed, 69 insertions(+), 11 deletions(-) diff --git a/sdk/package-lock.json b/sdk/package-lock.json index 61d6bea8b..c645083fb 100644 --- a/sdk/package-lock.json +++ b/sdk/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/sdk", - "version": "0.5.15", + "version": "0.5.17", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@scrypted/sdk", - "version": "0.5.15", + "version": "0.5.17", "license": "ISC", "dependencies": { "@babel/preset-typescript": "^7.27.1", diff --git a/sdk/package.json b/sdk/package.json index f03af8303..ab48ca67e 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/sdk", - "version": "0.5.15", + "version": "0.5.17", "description": "", "main": "dist/src/index.js", "exports": { diff --git a/sdk/types/package-lock.json b/sdk/types/package-lock.json index b0b5a0045..41de3d7f6 100644 --- a/sdk/types/package-lock.json +++ b/sdk/types/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/types", - "version": "0.5.14", + "version": "0.5.16", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/types", - "version": "0.5.14", + "version": "0.5.16", "license": "ISC" } } diff --git a/sdk/types/package.json b/sdk/types/package.json index 3353b3399..607170fc9 100644 --- a/sdk/types/package.json +++ b/sdk/types/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/types", - "version": "0.5.14", + "version": "0.5.16", "description": "", "main": "dist/index.js", "author": "", diff --git a/sdk/types/scrypted_python/scrypted_sdk/types.py b/sdk/types/scrypted_python/scrypted_sdk/types.py index 39bd11773..1cc40e14d 100644 --- a/sdk/types/scrypted_python/scrypted_sdk/types.py +++ b/sdk/types/scrypted_python/scrypted_sdk/types.py @@ -467,6 +467,11 @@ class Point(TypedDict): pass +class ChatCompletionChunk(TypedDict): + + pass + + class AdoptDevice(TypedDict): nativeId: str @@ -484,6 +489,57 @@ class AudioVolumes(TypedDict): pass +class ChatCompletionChunk(TypedDict): + """Represents a streamed chunk of a chat completion response returned by the model, based on the provided input. [Learn more](https://platform.openai.com/docs/guides/streaming-responses).""" + + choices: list[Choice] # A list of chat completion choices. Can contain more than one elements if is greater than 1. Can also be empty for the last chunk if you set . + created: float # The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has the same timestamp. + id: str # A unique identifier for the chat completion. Each chunk has the same ID. + model: str # The model to generate the completion. + object: Any # The object type, which is always . + service_tier: Any | Any | Any # Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service: - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarantee. - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarantee. - If set to 'flex', the request will be processed with the Flex Processing service tier. [Learn more](https://platform.openai.com/docs/guides/flex-processing). - When not set, the default behavior is 'auto'. When this parameter is set, the response body will include the utilized. + system_fingerprint: str # This fingerprint represents the backend configuration that the model runs with. Can be used in conjunction with the request parameter to understand when backend changes have been made that might impact determinism. + usage: CompletionUsage # An optional field that will only be present when you set in your request. When present, it contains a null value **except for the last chunk** which contains the token usage statistics for the entire request. **NOTE:** If the stream is interrupted or cancelled, you may not receive the final usage chunk which contains the total token usage for the request. + +class ChatCompletionCreateParamsNonStreaming(TypedDict): + + audio: ChatCompletionAudioParam # Parameters for audio output. Required when audio output is requested with . [Learn more](https://platform.openai.com/docs/guides/audio). + frequency_penalty: float # Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. + function_call: Any | Any | ChatCompletionFunctionCallOption + functions: list[Function] + logit_bias: Mapping[str, float] # Modify the likelihood of specified tokens appearing in the completion. Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + logprobs: bool # Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the of . + max_completion_tokens: float # An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](https://platform.openai.com/docs/guides/reasoning). + max_tokens: float + messages: list[ChatCompletionMessageParam] # A list of messages comprising the conversation so far. Depending on the [model](https://platform.openai.com/docs/models) you use, different message types (modalities) are supported, like [text](https://platform.openai.com/docs/guides/text-generation), [images](https://platform.openai.com/docs/guides/vision), and [audio](https://platform.openai.com/docs/guides/audio). + metadata: Metadata # Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters. + modalities: list[Any | Any] # Output types that you would like the model to generate. Most models are capable of generating text, which is the default: The model can also be used to [generate audio](https://platform.openai.com/docs/guides/audio). To request that this model generate both text and audio responses, you can use: + model: Union[str, Any] | ChatModel # Model ID used to generate the response, like or . OpenAI offers a wide range of models with different capabilities, performance characteristics, and price points. Refer to the [model guide](https://platform.openai.com/docs/models) to browse and compare available models. + n: float # How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep as to minimize costs. + parallel_tool_calls: bool # Whether to enable [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. + prediction: ChatCompletionPredictionContent # Static predicted output content, such as the content of a text file that is being regenerated. + presence_penalty: float # Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. + reasoning_effort: ReasoningEffort # **o-series models only** Constrains effort on reasoning for [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported values are , , and . Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response. + response_format: ResponseFormatText | ResponseFormatJSONSchema | ResponseFormatJSONObject # An object specifying the format that the model must output. Setting to enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). Setting to enables the older JSON mode, which ensures the message the model generates is valid JSON. Using is preferred for models that support it. + seed: float # This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same and parameters should return the same result. Determinism is not guaranteed, and you should refer to the response parameter to monitor changes in the backend. + service_tier: Any | Any | Any # Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service: - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarantee. - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarantee. - If set to 'flex', the request will be processed with the Flex Processing service tier. [Learn more](https://platform.openai.com/docs/guides/flex-processing). - When not set, the default behavior is 'auto'. When this parameter is set, the response body will include the utilized. + stop: str | list[str] # Not supported with latest reasoning models and . Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence. + store: bool # Whether or not to store the output of this chat completion request for use in our [model distillation](https://platform.openai.com/docs/guides/distillation) or [evals](https://platform.openai.com/docs/guides/evals) products. + stream: Any # If set to true, the model response data will be streamed to the client as it is generated using [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format). See the [Streaming section below](https://platform.openai.com/docs/api-reference/chat/streaming) for more information, along with the [streaming responses](https://platform.openai.com/docs/guides/streaming-responses) guide for more information on how to handle the streaming events. + stream_options: ChatCompletionStreamOptions # Options for streaming response. Only set this when you set . + temperature: float # What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or but not both. + tool_choice: ChatCompletionToolChoiceOption # Controls which (if any) tool is called by the model. means the model will not call any tool and instead generates a message. means the model can pick between generating a message or calling one or more tools. means the model must call one or more tools. Specifying a particular tool via forces the model to call that tool. is the default when no tools are present. is the default if tools are present. + tools: list[ChatCompletionTool] # A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. + top_logprobs: float # An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. must be set to if this parameter is used. + top_p: float # An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or but not both. + user: str # A stable identifier for your end-users. Used to boost cache hit rates by better bucketing similar requests and to help OpenAI detect and prevent abuse. [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids). + web_search_options: WebSearchOptions # This tool searches the web for relevant results to use in a response. Learn more about the [web search tool](https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat). + +class ChatCompletionTool(TypedDict): + + function: FunctionDefinition + type: Any # The type of the tool. Currently, only is supported. + class ClusterForkInterfaceOptions(TypedDict): clusterWorkerId: str # The id of the cluster worker id that will execute this fork. @@ -998,7 +1054,7 @@ class TamperState(TypedDict): pass -TYPES_VERSION = "0.5.14" +TYPES_VERSION = "0.5.16" class AirPurifier: @@ -1077,7 +1133,7 @@ class ChatCompletion: async def getChatCompletion(self, body: ChatCompletionCreateParamsNonStreaming) -> ChatCompletion: pass - async def streamChatCompletion(self, params: ChatCompletionCreateParamsStreaming) -> AsyncGenerator[ChatCompletion | ChatCompletionChunk, None]: + async def streamChatCompletion(self, params: ChatCompletionStreamParams) -> AsyncGenerator[ChatCompletion | ChatCompletionChunk, None]: pass diff --git a/sdk/types/src/types.input.ts b/sdk/types/src/types.input.ts index 7491153d2..9ccf53622 100644 --- a/sdk/types/src/types.input.ts +++ b/sdk/types/src/types.input.ts @@ -1,7 +1,9 @@ import type { ChildProcess as NodeChildProcess } from 'child_process'; -import type { Worker as NodeWorker } from 'worker_threads'; import type { Socket as NodeNetSocket } from 'net'; -import type { ChatCompletionTool, ChatCompletion as ChatCompletionResponse, ChatCompletionChunk, ChatCompletionCreateParamsNonStreaming, ChatCompletionCreateParamsStreaming } from 'openai/resources'; +import type { ChatCompletionStreamParams } from 'openai/lib/ChatCompletionStream'; +import type { ChatCompletionChunk, ChatCompletionCreateParamsNonStreaming, ChatCompletion as ChatCompletionResponse, ChatCompletionTool } from 'openai/resources'; +import type { Worker as NodeWorker } from 'worker_threads'; +export type { ChatCompletionChunk, ChatCompletionCreateParamsNonStreaming, ChatCompletionCreateParamsStreaming, ChatCompletion as ChatCompletionResponse, ChatCompletionTool } from 'openai/resources'; export type ScryptedNativeId = string | undefined; @@ -1071,7 +1073,7 @@ export interface LLMTools { export interface ChatCompletion { getChatCompletion(body: ChatCompletionCreateParamsNonStreaming): Promise; - streamChatCompletion(params: ChatCompletionCreateParamsStreaming): Promise>; + streamChatCompletion(params: ChatCompletionStreamParams): Promise>; } export interface PanTiltZoomCapabilities {