Spaces:
Paused
Paused
package chatgpt | |
import ( | |
"github.com/google/uuid" | |
) | |
type CreateConversationRequest struct { | |
Action string `json:"action"` | |
Messages []Message `json:"messages"` | |
Model string `json:"model"` | |
ParentMessageID string `json:"parent_message_id"` | |
ConversationID *string `json:"conversation_id"` | |
PluginIDs []string `json:"plugin_ids"` | |
TimezoneOffsetMin int `json:"timezone_offset_min"` | |
ArkoseToken string `json:"arkose_token"` | |
HistoryAndTrainingDisabled bool `json:"history_and_training_disabled"` | |
AutoContinue bool `json:"auto_continue"` | |
Suggestions []string `json:"suggestions"` | |
} | |
func (c *CreateConversationRequest) AddMessage(role string, content string) { | |
c.Messages = append(c.Messages, Message{ | |
ID: uuid.New().String(), | |
Author: Author{Role: role}, | |
Content: Content{ContentType: "text", Parts: []interface{}{content}}, | |
Metadata: map[string]string{}, | |
}) | |
} | |
type Message struct { | |
Author Author `json:"author"` | |
Content Content `json:"content"` | |
ID string `json:"id"` | |
Metadata interface{} `json:"metadata"` | |
} | |
type Author struct { | |
Role string `json:"role"` | |
} | |
type Content struct { | |
ContentType string `json:"content_type"` | |
Parts []interface{} `json:"parts"` | |
} | |
type CreateConversationResponse struct { | |
Message struct { | |
ID string `json:"id"` | |
Author struct { | |
Role string `json:"role"` | |
Name interface{} `json:"name"` | |
Metadata struct { | |
} `json:"metadata"` | |
} `json:"author"` | |
CreateTime float64 `json:"create_time"` | |
UpdateTime interface{} `json:"update_time"` | |
Content struct { | |
ContentType string `json:"content_type"` | |
Parts []string `json:"parts"` | |
} `json:"content"` | |
Status string `json:"status"` | |
EndTurn bool `json:"end_turn"` | |
Weight float64 `json:"weight"` | |
Metadata struct { | |
MessageType string `json:"message_type"` | |
ModelSlug string `json:"model_slug"` | |
FinishDetails struct { | |
Type string `json:"type"` | |
} `json:"finish_details"` | |
} `json:"metadata"` | |
Recipient string `json:"recipient"` | |
} `json:"message"` | |
ConversationID string `json:"conversation_id"` | |
Error interface{} `json:"error"` | |
} | |
type GetModelsResponse struct { | |
Models []struct { | |
Slug string `json:"slug"` | |
MaxTokens int `json:"max_tokens"` | |
Title string `json:"title"` | |
Description string `json:"description"` | |
Tags []string `json:"tags"` | |
Capabilities struct { | |
} `json:"capabilities"` | |
EnabledTools []string `json:"enabled_tools,omitempty"` | |
} `json:"models"` | |
Categories []struct { | |
Category string `json:"category"` | |
HumanCategoryName string `json:"human_category_name"` | |
SubscriptionLevel string `json:"subscription_level"` | |
DefaultModel string `json:"default_model"` | |
CodeInterpreterModel string `json:"code_interpreter_model"` | |
PluginsModel string `json:"plugins_model"` | |
} `json:"categories"` | |
} | |