增加 kimi Stream 支持
Some checks are pending
Dart / build (push) Waiting to run
Some checks are pending
Dart / build (push) Waiting to run
This commit is contained in:
@ -262,6 +262,56 @@ interface class OpenAIChat implements OpenAIChatBase {
|
||||
);
|
||||
}
|
||||
|
||||
Stream<OpenAIStreamChatCompletionModel> createKimiStream({
|
||||
required String model,
|
||||
required List<OpenAIChatCompletionChoiceMessageModel> messages,
|
||||
List<OpenAIToolModel>? tools,
|
||||
toolChoice,
|
||||
double? temperature,
|
||||
double? topP,
|
||||
int? n,
|
||||
stop,
|
||||
int? maxTokens,
|
||||
double? presencePenalty,
|
||||
double? frequencyPenalty,
|
||||
Map<String, dynamic>? logitBias,
|
||||
Map<String, String>? responseFormat,
|
||||
int? seed,
|
||||
String? user,
|
||||
http.Client? client,
|
||||
}) {
|
||||
return OpenAINetworkingClient.postStream<OpenAIStreamChatCompletionModel>(
|
||||
to: BaseApiUrlBuilder.build(endpoint),
|
||||
body: {
|
||||
"model": model,
|
||||
"stream": true,
|
||||
"messages": messages.map((message) {
|
||||
final role = message.role;
|
||||
final content = message.content!.first.text ?? "";
|
||||
return {"role": role, "content": content};
|
||||
}).toList(),
|
||||
if (tools != null)
|
||||
"tools": tools.map((tool) => tool.toMap()).toList(growable: false),
|
||||
if (toolChoice != null) "tool_choice": toolChoice,
|
||||
if (temperature != null) "temperature": temperature,
|
||||
if (topP != null) "top_p": topP,
|
||||
if (n != null) "n": n,
|
||||
if (stop != null) "stop": stop,
|
||||
if (maxTokens != null) "max_tokens": maxTokens,
|
||||
if (presencePenalty != null) "presence_penalty": presencePenalty,
|
||||
if (frequencyPenalty != null) "frequency_penalty": frequencyPenalty,
|
||||
if (logitBias != null) "logit_bias": logitBias,
|
||||
if (user != null) "user": user,
|
||||
if (seed != null) "seed": seed,
|
||||
if (responseFormat != null) "response_format": responseFormat,
|
||||
},
|
||||
onSuccess: (Map<String, dynamic> response) {
|
||||
return OpenAIStreamChatCompletionModel.fromMap(response);
|
||||
},
|
||||
client: client,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<OpenAIStreamChatCompletionModel> createRemoteFunctionStream({
|
||||
required String model,
|
||||
|
Reference in New Issue
Block a user