claudeweb

package
v0.0.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_MODEL    = "claude-2"
	DEFAULT_TIMEZONE = "Asia/Shanghai"
)
View Source
const (
	BASE_URI = "https://claude.ai"
	UA       = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36"
	JA3      = "" /* 137-byte string literal not displayed */
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	FileName         string `json:"file_name"`
	FileType         string `json:"file_type"`
	FileSize         int    `json:"file_size"`
	ExtractedContent string `json:"extracted_content"`
}

type ChatMessage

type ChatMessage struct {
	UUID         string       `json:"uuid"`
	Text         string       `json:"text"`
	Sender       string       `json:"sender"`
	Index        int          `json:"index"`
	CreatedAt    string       `json:"created_at"`
	UpdatedAt    string       `json:"updated_at"`
	EditedAt     string       `json:"edited_at"`
	ChatFeedback string       `json:"chat_feedback"`
	Attachments  []Attachment `json:"attachments"`
}

type ChatMessageResponse

type ChatMessageResponse struct {
	Completion   string `json:"completion"`
	StopReason   string `json:"stop_reason"`
	Model        string `json:"model"`
	Stop         string `json:"stop"`
	LogId        string `json:"log_id"`
	MessageLimit struct {
		Type string `json:"type"`
	} `json:"message_limit"`
}

type ClaudeWeb

type ClaudeWeb struct {
	Client
	// contains filtered or unexported fields
}

func NewClaudeWeb

func NewClaudeWeb(token string, opts ...Option) *ClaudeWeb

NewClaudeWeb returns a new ClaudeWeb client

func (*ClaudeWeb) CreateChatMessage

func (c *ClaudeWeb) CreateChatMessage(id, prompt string) (*ChatMessageResponse, error)

func (*ClaudeWeb) CreateChatMessageStream

func (c *ClaudeWeb) CreateChatMessageStream(id, prompt string, streamChan chan *ChatMessageResponse, errChan chan error)

func (*ClaudeWeb) CreateChatMessageStreamWithFullResponse

func (c *ClaudeWeb) CreateChatMessageStreamWithFullResponse(id, prompt string, streamChan chan *ChatMessageResponse, fullRespChan chan string, errChan chan error)

func (*ClaudeWeb) CreateConversation

func (c *ClaudeWeb) CreateConversation(name string) (*Conversation, error)

CreateConversation is used to create conversation

func (*ClaudeWeb) DeleteConversation

func (c *ClaudeWeb) DeleteConversation(id string) error

DeleteConversation is used to delete conversation

func (*ClaudeWeb) GetConversation

func (c *ClaudeWeb) GetConversation(id string) (*Conversation, error)

GetConversation is used to get conversation

func (*ClaudeWeb) GetOrganizations

func (c *ClaudeWeb) GetOrganizations() ([]*Organization, error)

func (*ClaudeWeb) ListConversations

func (c *ClaudeWeb) ListConversations() ([]*Conversation, error)

func (*ClaudeWeb) UpdateConversation

func (c *ClaudeWeb) UpdateConversation(id string, name string) error

UpdateConversation is used to update conversation

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a ChatGPT request client

func NewClient

func NewClient(options ...Option) *Client

NewClient will return a ChatGPT request client

func (*Client) Delete

func (c *Client) Delete(uri string) (*models.Response, error)

Delete will request api with delete method

func (*Client) Get

func (c *Client) Get(uri string) (*models.Response, error)

func (*Client) GetModel

func (c *Client) GetModel() string

GetModel will get model set in option

func (*Client) GetOrgid

func (c *Client) GetOrgid() string

GetOrgid will get orgid set in option

func (*Client) Post

func (c *Client) Post(uri string, params MixMap, headers map[string]string) (*models.Response, error)

type Completion

type Completion struct {
	Prompt   string `json:"prompt"`
	Timezone string `json:"timezone"`
	Model    string `json:"model"`
}

type Conversation

type Conversation struct {
	UUID         string        `json:"uuid"`
	Name         string        `json:"name"`
	Summary      string        `json:"summary"`
	CreatedAt    string        `json:"created_at"`
	UpdatedAt    string        `json:"updated_at"`
	ChatMessages []ChatMessage `json:"chat_messages"`
}

type CreateChatMessageRequest

type CreateChatMessageRequest struct {
	Completion       Completion   `json:"completion"`
	OrganizationUUID string       `json:"organization_uuid"`
	ConversationUUID string       `json:"conversation_uuid"`
	Text             string       `json:"text"`
	Attachments      []Attachment `json:"attachments"`
}

type MixMap

type MixMap = map[string]interface{}

MixMap is a type alias for map[string]interface{}

func NewMixMap

func NewMixMap(in interface{}) MixMap

type Option

type Option func(*Client)

Option is used to set custom option

func WithBaseUri

func WithBaseUri(baseUri string) Option

WithBaseUri is used to set api base uri

func WithDebug

func WithDebug(debug bool) Option

WithDebug is used to output debug message

func WithJA3

func WithJA3(ja3 string) Option

func WithModel

func WithModel(model string) Option

WithModel is used to set chat model

func WithOrgid

func WithOrgid(orgid string) Option

WithOrgid is used to set orgid

func WithProxy

func WithProxy(proxy string) Option

WithProxy is used to set request proxy

func WithSessionKey

func WithSessionKey(sessionKey string) Option

WithSessionKey is used to set session key in cookie

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout is used to set request timeout

func WithUserAgent

func WithUserAgent(userAgent string) Option

WithUserAgent is used to set user_agent

type Options

type Options struct {
	// Debug is used to output debug message
	Debug bool
	// Timeout is used to end http request after timeout duration
	Timeout time.Duration
	// Proxy is used to proxy request
	Proxy string
	// SessionKey is used to set authorization key
	SessionKey string
	// Model is the chat model
	Model string
	// BaseUri is the api base uri
	BaseUri string
	// UserAgent is used to set user agent in header
	UserAgent string
	// Orgid is user's uuid
	Orgid string
	// JA3 is used to set ja3
	JA3 string
}

Options for request client

type Organization

type Organization struct {
	UUID         string   `json:"uuid"`
	Name         string   `json:"name"`
	Settings     Settings `json:"settings"`
	Capabilities []string `json:"capabilities"`
	CreatedAt    string   `json:"created_at"`
	UpdatedAt    string   `json:"updated_at"`
	ActiveFlags  []string `json:"active_flags"`
}

type Settings

type Settings struct {
	ClaudeConsolePrivacy string `json:"claude_console_privacy"`
}

type UpdateConversationRequest

type UpdateConversationRequest struct {
	OrganizationUUID string `json:"organization_uuid"`
	ConversationUUID string `json:"conversation_uuid"`
	Title            string `json:"title"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL