AIX: OpenAI: update wiretypes to allow for Mistral/NS

This commit is contained in:
Enrico Ros
2024-07-20 05:37:14 -07:00
parent 2876958ca6
commit a311531621
@@ -45,7 +45,11 @@ export namespace OpenAIWire_ContentParts {
/// Content parts - Output
const PredictedFunctionCall_schema = z.object({
type: z.literal('function'),
/*
* .optional: for Mistral non-streaming generation - this is fairly weak, and does not let the discriminator work;
* please remove this hack asap.
*/
type: z.literal('function').optional(),
id: z.string(),
function: z.object({
name: z.string(),
@@ -90,8 +94,9 @@ export namespace OpenAIWire_Messages {
role: z.literal('assistant'),
/**
* The contents of the assistant message. Required unless tool_calls or function_call is specified.
* .optional: when parsing a non-streaming message with just a FC, the content can be missing
*/
content: z.string().nullable(),
content: z.string().optional().nullable(),
/**
* The tool calls generated by the model, such as function calls.
*/
@@ -242,6 +247,7 @@ export namespace OpenAIWire_API_Chat_Completions {
// Extensions //
'', // [LocalAI] bad response from LocalAI which breaks the parser
'COMPLETE', // [OpenRouter->Command-R+]
'STOP', // [OpenRouter->Gemini]
'end_turn', // [OpenRouter->Anthropic]
'eos', // [OpenRouter->Phind]
'error', // [OpenRouter] their network error
@@ -266,7 +272,7 @@ export namespace OpenAIWire_API_Chat_Completions {
});
export type Response = z.infer<typeof Response_schema>;
const Response_schema = z.object({
export const Response_schema = z.object({
object: z.literal('chat.completion'),
id: z.string(), // A unique identifier for the chat completion.
@@ -281,6 +287,10 @@ export namespace OpenAIWire_API_Chat_Completions {
system_fingerprint: z.string().optional() // The backend configuration that the model runs with.
.nullable(), // [Grow, undocumented OpenAI] fingerprint is null on some OpenAI examples too
// service_tier: z.unknown().optional(),
// undocumented messages
error: z.any().optional(),
warning: z.unknown().optional(),
});
/// Streaming Response