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

chore: Export base Message class in OpenAI chat SDK #616

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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## UNRELEASED - AssemblyScript SDK 0.14.2

- chore: Export base Message class in OpenAI chat SDK [#616](https://github.com/hypermodeinc/modus/pull/616)

## UNRELEASED - Go SDK 0.14.3

- chore: Export base Message class in OpenAI chat SDK [#616](https://github.com/hypermodeinc/modus/pull/616)

## 2024-11-25 - Go SDK 0.14.2

- fix: Reduce Go build times [#615](https://github.com/hypermodeinc/modus/pull/615)
Expand Down
2 changes: 1 addition & 1 deletion sdk/assemblyscript/src/models/openai/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ export class TopLogprobsContent {
* A message object that can be sent to the chat model.
*/
@json
abstract class Message {
export abstract class Message {
/**
* Creates a new message object.
*
Expand Down
22 changes: 11 additions & 11 deletions sdk/go/pkg/models/openai/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ type Message interface {
isMessage()
}

// The base implementation for all messageBase objects.
type messageBase struct {
// The base implementation for all MessageBase objects.
type MessageBase struct {

// The role of the author of this message.
Role string `json:"role"`
Expand All @@ -243,17 +243,17 @@ type messageBase struct {
Content string `json:"content"`
}

func (m *MessageBase) isMessage() {}

// Adds a Name for the participant to the base message.
type participantMessage struct {
messageBase
MessageBase

// An optional name for the participant.
// Provides the model information to differentiate between participants of the same role.
Name string `json:"name,omitempty"`
}

func (m *messageBase) isMessage() {}

// A system message object.
type SystemMessage struct {
participantMessage
Expand All @@ -263,7 +263,7 @@ type SystemMessage struct {
func NewSystemMessage(content string) *SystemMessage {
return &SystemMessage{
participantMessage{
messageBase: messageBase{
MessageBase: MessageBase{
Role: "system",
Content: content,
},
Expand All @@ -280,7 +280,7 @@ type UserMessage struct {
func NewUserMessage(content string) *UserMessage {
return &UserMessage{
participantMessage{
messageBase: messageBase{
MessageBase: MessageBase{
Role: "user",
Content: content,
},
Expand All @@ -300,7 +300,7 @@ type AssistantMessage struct {
func NewAssistantMessage(content string, toolCalls ...ToolCall) *AssistantMessage {
return &AssistantMessage{
participantMessage{
messageBase: messageBase{
MessageBase: MessageBase{
Role: "assistant",
Content: content,
},
Expand All @@ -311,7 +311,7 @@ func NewAssistantMessage(content string, toolCalls ...ToolCall) *AssistantMessag

// A tool message object.
type ToolMessage struct {
messageBase
MessageBase

// The tool call that this message is responding to.
ToolCallId string `json:"tool_call_id"`
Expand All @@ -320,7 +320,7 @@ type ToolMessage struct {
// Creates a new tool message object.
func NewToolMessage(content, toolCallId string) *ToolMessage {
return &ToolMessage{
messageBase{
MessageBase{
Role: "tool",
Content: content,
},
Expand All @@ -330,7 +330,7 @@ func NewToolMessage(content, toolCallId string) *ToolMessage {

// A chat completion message generated by the model.
type CompletionMessage struct {
messageBase
MessageBase

// The refusal message generated by the model.
Refusal string `json:"refusal,omitempty"`
Expand Down
Loading