cai

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package cai

Copyright © 2023 Harmony AI Solutions & Contributors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package cai

Copyright © 2023 Harmony AI Solutions & Contributors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package cai

Copyright © 2023 Harmony AI Solutions & Contributors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package cai

Copyright © 2023 Harmony AI Solutions & Contributors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package cai

Copyright © 2023 Harmony AI Solutions & Contributors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package cai

Copyright © 2023 Harmony AI Solutions & Contributors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package cai

Copyright © 2023 Harmony AI Solutions & Contributors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Character

type Character struct {
	Token   string
	Session *Session
}

func (*Character) Categories

func (c *Character) Categories() (map[string]interface{}, error)

func (*Character) Create

func (c *Character) Create(greeting, identifier, name, avatarRelPath, baseImgPrompt, definition, description, title, visibility, token string, categories []string, copyable, imgGenEnabled bool, extraArgs map[string]interface{}) (map[string]interface{}, error)

func (*Character) Info

func (c *Character) Info(char, token string) (map[string]interface{}, error)

func (*Character) Recommended

func (c *Character) Recommended(token string) (map[string]interface{}, error)

func (*Character) Search

func (c *Character) Search(query, token string) (map[string]interface{}, error)

func (*Character) Trending

func (c *Character) Trending() (map[string]interface{}, error)

func (*Character) Update

func (c *Character) Update(externalID, greeting, identifier, name, title, definition, description, visibility, token string, categories []string, copyable bool, extraArgs map[string]interface{}) (map[string]interface{}, error)

func (*Character) Voices

func (c *Character) Voices() (map[string]interface{}, error)

type Chat

type Chat struct {
	Token   string
	Session *Session
}

func (*Chat) CreateRoom

func (c *Chat) CreateRoom(characters []string, name, topic string, extraArgs map[string]interface{}) (map[string]interface{}, error)

func (*Chat) DeleteMessage

func (c *Chat) DeleteMessage(historyID string, uuidsToDelete []string, extraArgs map[string]interface{}) (map[string]interface{}, error)

func (*Chat) GetChat

func (c *Chat) GetChat(char string) (*ChatData, error)

func (*Chat) GetHistories

func (c *Chat) GetHistories(char string, number int) (map[string]interface{}, error)

func (*Chat) GetHistory

func (c *Chat) GetHistory(historyID string) (*ChatHistory, error)

func (*Chat) NewChat

func (c *Chat) NewChat(char string) (*ChatData, error)

func (*Chat) NextMessage

func (c *Chat) NextMessage(historyID, parentMsgUUID, tgt string, extraArgs map[string]interface{}) (map[string]interface{}, error)

func (*Chat) Rate

func (c *Chat) Rate(rate int, historyID, messageID string, extraArgs map[string]interface{}) (map[string]interface{}, error)

func (*Chat) SendMessage

func (c *Chat) SendMessage(historyID, tgt, text string, extraArgs map[string]interface{}) (*ChatMessage, error)

type Chat2

type Chat2 struct {
	Token   string
	Session *Session
	WS      *websocket.Conn
}

func (*Chat2) DeleteMessage

func (c *Chat2) DeleteMessage(chatID string, turnIDs []string) (map[string]interface{}, error)

func (*Chat2) GetChat

func (c *Chat2) GetChat(char string) (map[string]interface{}, error)

func (*Chat2) GetHistories

func (c *Chat2) GetHistories(char string, preview int) (map[string]interface{}, error)

func (*Chat2) GetHistory

func (c *Chat2) GetHistory(chatID string) (map[string]interface{}, error)

func (*Chat2) NewChat

func (c *Chat2) NewChat(char, chatID, creatorID string, withGreeting ...bool) (map[string]interface{}, map[string]interface{}, error)

func (*Chat2) NextMessage

func (c *Chat2) NextMessage(char, chatID, parentMsgUUID string) (map[string]interface{}, error)

func (*Chat2) Rate

func (c *Chat2) Rate(rate int, chatID, turnID, candidateID string) (map[string]interface{}, error)

func (*Chat2) SendMessage

func (c *Chat2) SendMessage(char, chatID, text string, author map[string]interface{}, turnID, customID, candidateID *string) (map[string]interface{}, error)

type ChatAccount added in v0.0.3

type ChatAccount struct {
	Name                     string `json:"name"`
	AvatarType               string `json:"avatar_type"`
	OnboardingComplete       bool   `json:"onboarding_complete"`
	AvatarFileName           string `json:"avatar_file_name"`
	MobileOnboardingComplete *bool  `json:"mobile_onboarding_complete"`
}

type ChatChar added in v0.0.3

type ChatChar struct {
	Participant    *ChatParticipant `json:"participant"`
	AvatarFileName *string          `json:"avatar_file_name"`
}

type ChatData added in v0.0.3

type ChatData struct {
	Title           string             `json:"title"`
	Participants    []*ChatParticipant `json:"participants"`
	ExternalID      string             `json:"external_id"`
	Created         string             `json:"created"`
	LastInteraction string             `json:"last_interaction"`
	Type            string             `json:"type"`
	Description     string             `json:"description"`
}

type ChatHistory added in v0.0.3

type ChatHistory struct {
	Messages []*ChatHistoryMessage `json:"messages"`
	HasMore  bool                  `json:"has_more"`
	NextPage int                   `json:"next_page"`
}

type ChatHistoryMessage added in v0.0.3

type ChatHistoryMessage struct {
	Target                        string    `json:"tgt"`
	ImageRelPath                  string    `json:"image_rel_path"`
	ImagePromptText               string    `json:"image_prompt_text"`
	Deleted                       *bool     `json:"deleted"` // TODO: confirm bool
	IsAlternative                 bool      `json:"is_alternative"`
	SourceName                    string    `json:"src__name"`
	SourceUserUsername            string    `json:"src__user__username"`
	ResponsibleUserUsername       *string   `json:"responsible_user__username"`
	ID                            uint64    `json:"id"`
	UUID                          string    `json:"uuid"`
	Source                        string    `json:"src"`
	SourceIsHuman                 bool      `json:"src__is_human"`
	SourceCharacterAvatarFileName *string   `json:"src__character__avatar_file_name"`
	SourceChar                    *ChatChar `json:"src_char"`
	Text                          string    `json:"text"`
}

type ChatMessage added in v0.0.3

type ChatMessage struct {
	Replies         []*ChatMessageReply `json:"replies"`
	SourceChar      *ChatChar           `json:"src_char"`
	IsFinalChunk    bool                `json:"is_final_chunk"`
	LastUserMsgId   uint64              `json:"last_user_msg_id"`
	LastUserMsgUUID string              `json:"last_user_msg_uuid"`
}

type ChatMessageReply added in v0.0.3

type ChatMessageReply struct {
	Text string `json:"text"`
	UUID string `json:"uuid"`
	ID   uint64 `json:"id"`
}

type ChatParticipant added in v0.0.3

type ChatParticipant struct {
	User            *ChatUser `json:"user"`
	Name            string    `json:"name"`
	IsHuman         bool      `json:"is_human"`
	NumInteractions int       `json:"num_interactions"`
}

type ChatUser added in v0.0.3

type ChatUser struct {
	Username  string       `json:"username"`
	ID        uint64       `json:"id"`
	FirstName string       `json:"first_name"`
	IsStaff   bool         `json:"is_staff"`
	Account   *ChatAccount `json:"account"`
}

type GoCAI

type GoCAI struct {
	Token     string
	Session   *Session // Assuming Session is a type from tls_client or its Go equivalent
	User      *User    // Assuming these types are defined elsewhere or will be
	Post      *Post
	Character *Character
	Chat      *Chat
	Chat2     *Chat2
}

func NewGoCAI

func NewGoCAI(token string, plus bool) (*GoCAI, error)

func (*GoCAI) Ping

func (g *GoCAI) Ping() (map[string]interface{}, error)

type Post

type Post struct {
	Token   string
	Session *Session
}

func (*Post) Create

func (p *Post) Create(postType, externalID, title, text, postVisibility string, data map[string]interface{}) (map[string]interface{}, error)

func (*Post) Delete

func (p *Post) Delete(postID string) (map[string]interface{}, error)

func (*Post) DeleteComment

func (p *Post) DeleteComment(messageID int, postID string) (map[string]interface{}, error)

func (*Post) Feed

func (p *Post) Feed(topic string, num, load int, sort string) (map[string]interface{}, error)

func (*Post) GetPost

func (p *Post) GetPost(postID string) (map[string]interface{}, error)

func (*Post) GetPosts

func (p *Post) GetPosts(username string, postsPage int, postsToLoad int) (map[string]interface{}, error)

func (*Post) GetTopics

func (p *Post) GetTopics() (map[string]interface{}, error)

func (*Post) My

func (p *Post) My(postsPage int, postsToLoad int) (map[string]interface{}, error)

func (*Post) SendComment

func (p *Post) SendComment(postID, text, parentUUID string) (map[string]interface{}, error)

func (*Post) UndoUpvote

func (p *Post) UndoUpvote(postExternalID string) (map[string]interface{}, error)

func (*Post) Upvote

func (p *Post) Upvote(postExternalID string) (map[string]interface{}, error)

type Session

type Session struct {
	// Public Attributes
	URL   string
	Token string
	// contains filtered or unexported fields
}

func NewSession

func NewSession(url, token string, clientIdentifier profiles.ClientProfile) (*Session, error)

func (*Session) GET

func (s *Session) GET(url string, headers http.Header) (*http.Response, error)

func (*Session) POST

func (s *Session) POST(url string, headers http.Header, data []byte) (*http.Response, error)

func (*Session) PUT

func (s *Session) PUT(url string, headers http.Header, data []byte) (*http.Response, error)

type User

type User struct {
	Token   string
	Session *Session
}

func (*User) Characters

func (u *User) Characters() (map[string]interface{}, error)

func (*User) Followers

func (u *User) Followers() (map[string]interface{}, error)

func (*User) Following

func (u *User) Following() (map[string]interface{}, error)

func (*User) GetProfile

func (u *User) GetProfile(username string) (map[string]interface{}, error)

func (*User) Info

func (u *User) Info() (map[string]interface{}, error)

func (*User) Recent

func (u *User) Recent() (map[string]interface{}, error)

func (*User) Update

func (u *User) Update(username string, data map[string]interface{}) (map[string]interface{}, error)

Jump to

Keyboard shortcuts

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