Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:Update openapi.yaml file in src/libs/Cohere directory #112

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,41 @@ public StreamedChatResponseV2(global::Cohere.ChatMessageEndEvent? value)
MessageEndEvent = value;
}

/// <summary>
///
/// </summary>
#if NET6_0_OR_GREATER
public global::Cohere.ChatDebugEvent? DebugEvent { get; init; }
#else
public global::Cohere.ChatDebugEvent? DebugEvent { get; }
#endif

/// <summary>
///
/// </summary>
#if NET6_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(DebugEvent))]
#endif
public bool IsDebugEvent => DebugEvent != null;

/// <summary>
///
/// </summary>
public static implicit operator StreamedChatResponseV2(global::Cohere.ChatDebugEvent value) => new StreamedChatResponseV2(value);

/// <summary>
///
/// </summary>
public static implicit operator global::Cohere.ChatDebugEvent?(StreamedChatResponseV2 @this) => @this.DebugEvent;

/// <summary>
///
/// </summary>
public StreamedChatResponseV2(global::Cohere.ChatDebugEvent? value)
{
DebugEvent = value;
}

/// <summary>
///
/// </summary>
Expand All @@ -336,7 +371,8 @@ public StreamedChatResponseV2(
global::Cohere.ChatToolCallStartEvent? toolCallStartEvent,
global::Cohere.ChatToolCallDeltaEvent? toolCallDeltaEvent,
global::Cohere.ChatToolCallEndEvent? toolCallEndEvent,
global::Cohere.ChatMessageEndEvent? messageEndEvent
global::Cohere.ChatMessageEndEvent? messageEndEvent,
global::Cohere.ChatDebugEvent? debugEvent
)
{
MessageStartEvent = messageStartEvent;
Expand All @@ -348,12 +384,14 @@ public StreamedChatResponseV2(
ToolCallDeltaEvent = toolCallDeltaEvent;
ToolCallEndEvent = toolCallEndEvent;
MessageEndEvent = messageEndEvent;
DebugEvent = debugEvent;
}

/// <summary>
///
/// </summary>
public object? Object =>
DebugEvent as object ??
MessageEndEvent as object ??
ToolCallEndEvent as object ??
ToolCallDeltaEvent as object ??
Expand All @@ -370,7 +408,7 @@ MessageStartEvent as object
/// </summary>
public bool Validate()
{
return IsMessageStartEvent && !IsContentStartEvent && !IsContentDeltaEvent && !IsContentEndEvent && !IsToolPlanDeltaEvent && !IsToolCallStartEvent && !IsToolCallDeltaEvent && !IsToolCallEndEvent && !IsMessageEndEvent || !IsMessageStartEvent && IsContentStartEvent && !IsContentDeltaEvent && !IsContentEndEvent && !IsToolPlanDeltaEvent && !IsToolCallStartEvent && !IsToolCallDeltaEvent && !IsToolCallEndEvent && !IsMessageEndEvent || !IsMessageStartEvent && !IsContentStartEvent && IsContentDeltaEvent && !IsContentEndEvent && !IsToolPlanDeltaEvent && !IsToolCallStartEvent && !IsToolCallDeltaEvent && !IsToolCallEndEvent && !IsMessageEndEvent || !IsMessageStartEvent && !IsContentStartEvent && !IsContentDeltaEvent && IsContentEndEvent && !IsToolPlanDeltaEvent && !IsToolCallStartEvent && !IsToolCallDeltaEvent && !IsToolCallEndEvent && !IsMessageEndEvent || !IsMessageStartEvent && !IsContentStartEvent && !IsContentDeltaEvent && !IsContentEndEvent && IsToolPlanDeltaEvent && !IsToolCallStartEvent && !IsToolCallDeltaEvent && !IsToolCallEndEvent && !IsMessageEndEvent || !IsMessageStartEvent && !IsContentStartEvent && !IsContentDeltaEvent && !IsContentEndEvent && !IsToolPlanDeltaEvent && IsToolCallStartEvent && !IsToolCallDeltaEvent && !IsToolCallEndEvent && !IsMessageEndEvent || !IsMessageStartEvent && !IsContentStartEvent && !IsContentDeltaEvent && !IsContentEndEvent && !IsToolPlanDeltaEvent && !IsToolCallStartEvent && IsToolCallDeltaEvent && !IsToolCallEndEvent && !IsMessageEndEvent || !IsMessageStartEvent && !IsContentStartEvent && !IsContentDeltaEvent && !IsContentEndEvent && !IsToolPlanDeltaEvent && !IsToolCallStartEvent && !IsToolCallDeltaEvent && IsToolCallEndEvent && !IsMessageEndEvent || !IsMessageStartEvent && !IsContentStartEvent && !IsContentDeltaEvent && !IsContentEndEvent && !IsToolPlanDeltaEvent && !IsToolCallStartEvent && !IsToolCallDeltaEvent && !IsToolCallEndEvent && IsMessageEndEvent;
return IsMessageStartEvent && !IsContentStartEvent && !IsContentDeltaEvent && !IsContentEndEvent && !IsToolPlanDeltaEvent && !IsToolCallStartEvent && !IsToolCallDeltaEvent && !IsToolCallEndEvent && !IsMessageEndEvent && !IsDebugEvent || !IsMessageStartEvent && IsContentStartEvent && !IsContentDeltaEvent && !IsContentEndEvent && !IsToolPlanDeltaEvent && !IsToolCallStartEvent && !IsToolCallDeltaEvent && !IsToolCallEndEvent && !IsMessageEndEvent && !IsDebugEvent || !IsMessageStartEvent && !IsContentStartEvent && IsContentDeltaEvent && !IsContentEndEvent && !IsToolPlanDeltaEvent && !IsToolCallStartEvent && !IsToolCallDeltaEvent && !IsToolCallEndEvent && !IsMessageEndEvent && !IsDebugEvent || !IsMessageStartEvent && !IsContentStartEvent && !IsContentDeltaEvent && IsContentEndEvent && !IsToolPlanDeltaEvent && !IsToolCallStartEvent && !IsToolCallDeltaEvent && !IsToolCallEndEvent && !IsMessageEndEvent && !IsDebugEvent || !IsMessageStartEvent && !IsContentStartEvent && !IsContentDeltaEvent && !IsContentEndEvent && IsToolPlanDeltaEvent && !IsToolCallStartEvent && !IsToolCallDeltaEvent && !IsToolCallEndEvent && !IsMessageEndEvent && !IsDebugEvent || !IsMessageStartEvent && !IsContentStartEvent && !IsContentDeltaEvent && !IsContentEndEvent && !IsToolPlanDeltaEvent && IsToolCallStartEvent && !IsToolCallDeltaEvent && !IsToolCallEndEvent && !IsMessageEndEvent && !IsDebugEvent || !IsMessageStartEvent && !IsContentStartEvent && !IsContentDeltaEvent && !IsContentEndEvent && !IsToolPlanDeltaEvent && !IsToolCallStartEvent && IsToolCallDeltaEvent && !IsToolCallEndEvent && !IsMessageEndEvent && !IsDebugEvent || !IsMessageStartEvent && !IsContentStartEvent && !IsContentDeltaEvent && !IsContentEndEvent && !IsToolPlanDeltaEvent && !IsToolCallStartEvent && !IsToolCallDeltaEvent && IsToolCallEndEvent && !IsMessageEndEvent && !IsDebugEvent || !IsMessageStartEvent && !IsContentStartEvent && !IsContentDeltaEvent && !IsContentEndEvent && !IsToolPlanDeltaEvent && !IsToolCallStartEvent && !IsToolCallDeltaEvent && !IsToolCallEndEvent && IsMessageEndEvent && !IsDebugEvent || !IsMessageStartEvent && !IsContentStartEvent && !IsContentDeltaEvent && !IsContentEndEvent && !IsToolPlanDeltaEvent && !IsToolCallStartEvent && !IsToolCallDeltaEvent && !IsToolCallEndEvent && !IsMessageEndEvent && IsDebugEvent;
}

/// <summary>
Expand All @@ -386,6 +424,7 @@ public bool Validate()
global::System.Func<global::Cohere.ChatToolCallDeltaEvent?, TResult>? toolCallDeltaEvent = null,
global::System.Func<global::Cohere.ChatToolCallEndEvent?, TResult>? toolCallEndEvent = null,
global::System.Func<global::Cohere.ChatMessageEndEvent?, TResult>? messageEndEvent = null,
global::System.Func<global::Cohere.ChatDebugEvent?, TResult>? debugEvent = null,
bool validate = true)
{
if (validate)
Expand Down Expand Up @@ -429,6 +468,10 @@ public bool Validate()
{
return messageEndEvent(MessageEndEvent!);
}
else if (IsDebugEvent && debugEvent != null)
{
return debugEvent(DebugEvent!);
}

return default(TResult);
}
Expand All @@ -446,6 +489,7 @@ public void Match(
global::System.Action<global::Cohere.ChatToolCallDeltaEvent?>? toolCallDeltaEvent = null,
global::System.Action<global::Cohere.ChatToolCallEndEvent?>? toolCallEndEvent = null,
global::System.Action<global::Cohere.ChatMessageEndEvent?>? messageEndEvent = null,
global::System.Action<global::Cohere.ChatDebugEvent?>? debugEvent = null,
bool validate = true)
{
if (validate)
Expand Down Expand Up @@ -489,6 +533,10 @@ public void Match(
{
messageEndEvent?.Invoke(MessageEndEvent!);
}
else if (IsDebugEvent)
{
debugEvent?.Invoke(DebugEvent!);
}
}

/// <summary>
Expand Down Expand Up @@ -516,6 +564,8 @@ public override int GetHashCode()
typeof(global::Cohere.ChatToolCallEndEvent),
MessageEndEvent,
typeof(global::Cohere.ChatMessageEndEvent),
DebugEvent,
typeof(global::Cohere.ChatDebugEvent),
};
const int offset = unchecked((int)2166136261);
const int prime = 16777619;
Expand All @@ -540,7 +590,8 @@ public bool Equals(StreamedChatResponseV2 other)
global::System.Collections.Generic.EqualityComparer<global::Cohere.ChatToolCallStartEvent?>.Default.Equals(ToolCallStartEvent, other.ToolCallStartEvent) &&
global::System.Collections.Generic.EqualityComparer<global::Cohere.ChatToolCallDeltaEvent?>.Default.Equals(ToolCallDeltaEvent, other.ToolCallDeltaEvent) &&
global::System.Collections.Generic.EqualityComparer<global::Cohere.ChatToolCallEndEvent?>.Default.Equals(ToolCallEndEvent, other.ToolCallEndEvent) &&
global::System.Collections.Generic.EqualityComparer<global::Cohere.ChatMessageEndEvent?>.Default.Equals(MessageEndEvent, other.MessageEndEvent)
global::System.Collections.Generic.EqualityComparer<global::Cohere.ChatMessageEndEvent?>.Default.Equals(MessageEndEvent, other.MessageEndEvent) &&
global::System.Collections.Generic.EqualityComparer<global::Cohere.ChatDebugEvent?>.Default.Equals(DebugEvent, other.DebugEvent)
;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,18 @@ public class StreamedChatResponseV2JsonConverter : global::System.Text.Json.Seri
{
}

readerCopy = reader;
global::Cohere.ChatDebugEvent? debugEvent = default;
try
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Cohere.ChatDebugEvent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Cohere.ChatDebugEvent> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Cohere.ChatDebugEvent).Name}");
debugEvent = global::System.Text.Json.JsonSerializer.Deserialize(ref readerCopy, typeInfo);
}
catch (global::System.Text.Json.JsonException)
{
}

var result = new global::Cohere.StreamedChatResponseV2(
messageStartEvent,
contentStartEvent,
Expand All @@ -133,7 +145,8 @@ public class StreamedChatResponseV2JsonConverter : global::System.Text.Json.Seri
toolCallStartEvent,
toolCallDeltaEvent,
toolCallEndEvent,
messageEndEvent
messageEndEvent,
debugEvent
);

if (messageStartEvent != null)
Expand Down Expand Up @@ -190,6 +203,12 @@ public class StreamedChatResponseV2JsonConverter : global::System.Text.Json.Seri
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Cohere.ChatMessageEndEvent).Name}");
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
}
else if (debugEvent != null)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Cohere.ChatDebugEvent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Cohere.ChatDebugEvent> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Cohere.ChatDebugEvent).Name}");
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
}

return result;
}
Expand Down Expand Up @@ -257,6 +276,12 @@ public override void Write(
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Cohere.ChatMessageEndEvent).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.MessageEndEvent, typeInfo);
}
else if (value.IsDebugEvent)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Cohere.ChatDebugEvent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Cohere.ChatDebugEvent?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Cohere.ChatDebugEvent).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.DebugEvent, typeInfo);
}
}
}
}
3 changes: 3 additions & 0 deletions src/libs/Cohere/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,8 @@ paths:
- $ref: '#/components/schemas/ChatToolCallDeltaEvent'
- $ref: '#/components/schemas/ChatToolCallEndEvent'
- $ref: '#/components/schemas/ChatMessageEndEvent'
- $ref: '#/components/schemas/ChatDebugEvent'
debug: '#/components/schemas/ChatDebugEvent'
Comment on lines +905 to +906
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix YAML indentation and review redundant property

The debug property appears to be incorrectly indented and seems redundant since ChatDebugEvent is already included in the list of possible event types above it.

Apply this diff to fix the indentation and remove redundancy:

            - $ref: '#/components/schemas/ChatToolCallDeltaEvent'
            - $ref: '#/components/schemas/ChatToolCallEndEvent'
            - $ref: '#/components/schemas/ChatMessageEndEvent'
            - $ref: '#/components/schemas/ChatDebugEvent'
-              debug: '#/components/schemas/ChatDebugEvent'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- $ref: '#/components/schemas/ChatDebugEvent'
debug: '#/components/schemas/ChatDebugEvent'
- $ref: '#/components/schemas/ChatDebugEvent'

x-fern-examples:
- code-samples:
- sdk: typescript
Expand Down Expand Up @@ -12599,6 +12601,7 @@ components:
- $ref: '#/components/schemas/ChatToolCallDeltaEvent'
- $ref: '#/components/schemas/ChatToolCallEndEvent'
- $ref: '#/components/schemas/ChatMessageEndEvent'
- $ref: '#/components/schemas/ChatDebugEvent'
description: StreamedChatResponse is returned in streaming mode (specified with `stream=True` in the request).
SingleGeneration:
required:
Expand Down
Loading