Documentation
¶
Index ¶
- func ClipLink(backendURL string, accessToken string, client string, uid string, url string, ...) (map[string]interface{}, error)
- func DetectFileContentType(filePath string, data []byte) string
- func DownloadMedia(mediaURL, backendURL, accessToken, client, uid string) ([]byte, error)
- func PrettyJSON(raw []byte) (string, error)
- func ResolveFinalURL(rawURL string, fallbackBase string) string
- func SafeResponseBody(raw []byte) string
- type AIModelRef
- type AIModelsResponse
- type AIRun
- type AIRunOutput
- type Answer
- type AnswerFileURL
- type AnswerImageURL
- type AnswerImageV2
- type AnswerResponse
- type BsvAttachment
- type BsvOrdinal
- type ChildQuest
- type CreateAnswerRequest
- type CreateAnswerResponse
- type CreateClipQuestRequest
- type CreateQuestRequest
- type CreateQuestResponse
- type GenerationActionInfo
- type GenerationMedia
- type GenerationQuote
- type GenerationResponse
- type MessagesResponse
- type MultipartFile
- type NotificationsCountResponse
- type NotificationsResponse
- type PollOptionPayload
- type Quest
- type ReferenceUploadResponse
- type ResolvedMediaLink
- type SettingInfo
- type StripeAiBillingCheckoutResponse
- type StripeAiBillingStatusResponse
- type StripeAiBillingStripe
- type StripeAiBillingSyncResponse
- type StripeAiBillingUsEvent
- type StripeAiBillingUsage
- type StripeAiPaymentModeResponse
- type TagInfo
- type TeamRef
- type TeamsResponse
- type ThreadResponse
- type URL
- type UpvaluedContentLeaderboardItem
- type UpvaluedContentLeaderboardResponse
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectFileContentType ¶
DetectFileContentType returns a stable media MIME type for local upload paths.
func DownloadMedia ¶
DownloadMedia fetches a generated media URL. Treechat auth headers are sent only to same-origin API URLs so signed storage/CDN URLs never receive credentials.
func PrettyJSON ¶
func ResolveFinalURL ¶
func SafeResponseBody ¶
Types ¶
type AIModelRef ¶
type AIModelRef struct {
ID string `json:"id"`
Name string `json:"name"`
HumanName string `json:"human_name"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
DescriptionShort string `json:"description_short"`
Provider string `json:"provider"`
ModelType string `json:"model_type"`
ActionTagName string `json:"action_tag_name"`
}
type AIModelsResponse ¶
type AIModelsResponse []AIModelRef
func ListAIModels ¶
func ListAIModels(backendURL, accessToken, client, uid string) (AIModelsResponse, error)
type AIRun ¶
type AIRun struct {
ID string `json:"id"`
Status string `json:"status"`
OutputURLs []AIRunOutput `json:"output_urls"`
}
type AIRunOutput ¶
type Answer ¶
type Answer struct {
ID string `json:"id"`
SpaceID string `json:"space_id"`
QuestID string `json:"quest_id"`
UserID string `json:"user_id"`
Content string `json:"content"`
DisplayContent string `json:"display_content"`
Path string `json:"path"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
MessageType string `json:"message_type"`
IsPost bool `json:"is_post"`
IsDraft bool `json:"is_draft"`
IsSystem bool `json:"is_system"`
IsClip bool `json:"is_clip"`
Deleted bool `json:"deleted"`
RecordingURL *string `json:"recording_url"`
MP4RecordingURL *string `json:"mp4_recording_url"`
RecordingThumbnailURL *string `json:"recording_thumbnail_url"`
RecordingType *string `json:"recording_type"`
OriginalRecordingType *string `json:"original_recording_type"`
RecordingInfo json.RawMessage `json:"recording_info"`
AnswerImageURL *string `json:"answer_image_url"`
ImagesV2 []AnswerImageV2 `json:"images_v2"`
ImageURLs []AnswerImageURL `json:"image_urls"`
FileURLs []AnswerFileURL `json:"file_urls"`
AIRuns []AIRun `json:"ai_runs"`
IsGeneratingImage bool `json:"is_generating_image"`
ImageGenerationFailed bool `json:"image_generation_failed"`
ImageGenerationFailureReason *string `json:"image_generation_failure_reason"`
User *User `json:"user"`
URL *URL `json:"url"`
ChildQuests []ChildQuest `json:"child_quests"`
BsvAttachments []BsvAttachment `json:"bsv_attachments"`
ImageBsvOrdinal *BsvOrdinal `json:"image_bsv_ordinal"`
VideoBsvOrdinal *BsvOrdinal `json:"video_bsv_ordinal"`
PollOpen bool `json:"poll_open"`
PollTotalVotes int `json:"poll_total_votes"`
PollUserVoteOptionID *string `json:"poll_user_vote_option_id"`
PollResultsVisible bool `json:"poll_results_visible"`
PollOptionsPayload []PollOptionPayload `json:"poll_options_payload"`
}
func (Answer) CanonicalMediaURLs ¶
func (Answer) GenerationFailureReason ¶
func (Answer) GenerationStatus ¶
type AnswerFileURL ¶
type AnswerImageURL ¶
type AnswerImageURL struct {
ImageURL string `json:"image_url"`
AttachmentID string `json:"attachment_id"`
ImageByteSize *int64 `json:"image_byte_size"`
ImageWidth *int `json:"image_width"`
ImageHeight *int `json:"image_height"`
ImageContentType string `json:"image_content_type"`
ImageFilename string `json:"image_filename"`
PreviewURLs map[string]string `json:"preview_urls"`
PreviewURL *string `json:"preview_url"`
}
type AnswerImageV2 ¶
type AnswerImageV2 struct {
AttachmentID string `json:"attachment_id"`
BlobID string `json:"blob_id"`
AttachedAt string `json:"attached_at"`
BlobCreatedAt string `json:"blob_created_at"`
Access string `json:"access"`
ImageByteSize *int64 `json:"image_byte_size"`
ImageWidth *int `json:"image_width"`
ImageHeight *int `json:"image_height"`
ImageContentType string `json:"image_content_type"`
ImageFilename string `json:"image_filename"`
URLs map[string]string `json:"urls"`
PreviewURL *string `json:"preview_url"`
}
type AnswerResponse ¶
type AnswerResponse struct {
Answer Answer `json:"answer"`
Raw json.RawMessage `json:"-"`
}
func GetAnswer ¶
func GetAnswer(backendURL, answerID, accessToken, client, uid string) (AnswerResponse, error)
type BsvAttachment ¶
type BsvOrdinal ¶
type ChildQuest ¶
type CreateAnswerRequest ¶
type CreateAnswerResponse ¶
type CreateAnswerResponse struct {
Answer Answer `json:"answer"`
Quest *Quest `json:"quest"`
SideQuest *Quest `json:"side_quest"`
Raw json.RawMessage `json:"-"`
}
func CreateAnswer ¶
func CreateAnswer( backendURL string, accessToken string, client string, uid string, request CreateAnswerRequest, ) (CreateAnswerResponse, error)
type CreateClipQuestRequest ¶
type CreateQuestRequest ¶
type CreateQuestResponse ¶
type CreateQuestResponse struct {
Quest Quest `json:"quest"`
Raw json.RawMessage `json:"-"`
}
func CreateClipQuest ¶
func CreateClipQuest( backendURL string, accessToken string, client string, uid string, request CreateClipQuestRequest, ) (CreateQuestResponse, error)
func CreateQuest ¶
func CreateQuest( backendURL string, accessToken string, client string, uid string, request CreateQuestRequest, ) (CreateQuestResponse, error)
type GenerationActionInfo ¶
type GenerationActionInfo struct {
Action string `json:"action"`
Tag string `json:"tag,omitempty"`
Provider string `json:"provider"`
Kind string `json:"kind"` // image | audio | video
Async bool `json:"async"`
AcceptsReference bool `json:"accepts_reference"`
RequiresReference bool `json:"requires_reference"`
ReferenceKinds []string `json:"reference_kinds,omitempty"`
SupportsInstrumental bool `json:"supports_instrumental"`
Settings []SettingInfo `json:"settings,omitempty"`
DurationMin int `json:"duration_min,omitempty"`
DurationMax int `json:"duration_max,omitempty"`
Inputs []string `json:"inputs,omitempty"`
}
GenerationActionInfo describes one AI action available to the direct generation endpoint and what it accepts.
func ListGenerationActions ¶
func ListGenerationActions(backendURL, accessToken, client, uid string) ([]GenerationActionInfo, error)
ListGenerationActions fetches the AI actions the direct generation endpoint supports and what each accepts. It prefers GET /api/v1/ai/generations/actions and falls back to /tags for older backends.
type GenerationMedia ¶
type GenerationMedia struct {
URL string `json:"url"`
ContentType string `json:"content_type,omitempty"`
Kind string `json:"kind,omitempty"`
}
GenerationMedia describes one generated media artifact.
type GenerationQuote ¶
type GenerationQuote struct {
AmountSats int64 `json:"amount_sats"`
AmountUSD float64 `json:"amount_usd"`
Action string `json:"action,omitempty"`
Tag string `json:"tag"`
Provider string `json:"provider,omitempty"`
PaymentMode string `json:"payment_mode,omitempty"`
}
GenerationQuote is the price for a generation, returned when quote=true (no media is produced).
type GenerationResponse ¶
type GenerationResponse struct {
ID string `json:"id"`
Status string `json:"status"`
Tag string `json:"tag"`
Action string `json:"action,omitempty"`
Source string `json:"source"`
Provider string `json:"provider,omitempty"`
PaymentMode string `json:"payment_mode,omitempty"`
MediaURLs []string `json:"media_urls"`
MediaOutputs []GenerationMedia `json:"media_outputs,omitempty"`
AmountSats int64 `json:"amount_sats,omitempty"`
AmountUSD float64 `json:"amount_usd,omitempty"`
Quote *GenerationQuote `json:"quote,omitempty"`
Failure map[string]interface{} `json:"failure,omitempty"`
Error string `json:"error,omitempty"`
Raw []byte `json:"-"`
}
GenerationResponse is the payload from the direct (post-less) generation endpoints.
func CreateGeneration ¶
func CreateGeneration( backendURL string, accessToken string, client string, uid string, action string, prompt string, settings map[string]interface{}, paymentMode string, quote bool, timeout time.Duration, ) (GenerationResponse, error)
CreateGeneration runs a direct AI generation that charges the user and returns media without ever creating a post. POST /api/v1/ai/generations.
func GetGeneration ¶
func GetGeneration(backendURL, id, accessToken, client, uid string) (GenerationResponse, error)
GetGeneration polls a direct generation by id. GET /api/v1/ai/generations/:id.
type MessagesResponse ¶
type MessagesResponse struct {
Answers []Answer `json:"answers"`
Raw json.RawMessage `json:"-"`
}
func GetMessages ¶
func GetMessages(backendURL, accessToken, client, uid string, messageIDs []string) (MessagesResponse, error)
GetMessages fetches messages from the API and returns them
type MultipartFile ¶
type NotificationsCountResponse ¶
type NotificationsCountResponse struct {
NumNotifications *int `json:"num_noti"`
ClientVersion int `json:"client_version"`
Raw json.RawMessage `json:"-"`
}
func GetNotificationsCount ¶
type NotificationsResponse ¶
type NotificationsResponse struct {
Quests []Quest `json:"quests"`
PinnedQuest *Quest `json:"pinned_quest"`
Raw json.RawMessage `json:"-"`
}
type PollOptionPayload ¶
type Quest ¶
type Quest struct {
ID string `json:"id"`
SpaceID string `json:"space_id"`
UserID string `json:"user_id"`
Content string `json:"content"`
Path string `json:"path"`
QuestURL string `json:"quest_url"`
ParentID string `json:"parent_id"`
NotificationReasonLabel string `json:"notification_reason_label"`
SortedAnswerIDs []string `json:"sorted_answer_ids"`
MatchingAnswerIDs []string `json:"matching_answer_ids"`
Parent *Answer `json:"parent"`
SortedAnswers []Answer `json:"sorted_answers"`
}
type ReferenceUploadResponse ¶
type ReferenceUploadResponse struct {
ID string `json:"id"`
URL string `json:"url"`
ContentType string `json:"content_type,omitempty"`
Kind string `json:"kind,omitempty"`
Error string `json:"error,omitempty"`
}
ReferenceUploadResponse is returned by the reference-upload endpoint.
func UploadReference ¶
func UploadReference(backendURL, accessToken, client, uid, filePath string) (ReferenceUploadResponse, error)
UploadReference uploads a local file to use as a model reference and returns its presigned URL. POST /api/v1/ai/generations/references (multipart). The file is held on a direct AiRun; no charge.
type ResolvedMediaLink ¶
func ResolveAnswerMediaLinks ¶
func ResolveAnswerMediaLinks(answer Answer, fallbackBase string) []ResolvedMediaLink
type SettingInfo ¶
type SettingInfo struct {
Name string `json:"name"`
Type string `json:"type,omitempty"`
Description string `json:"description,omitempty"`
Default interface{} `json:"default,omitempty"`
Min int `json:"min,omitempty"`
Max int `json:"max,omitempty"`
AllowedValues []int `json:"allowed_values,omitempty"`
}
SettingInfo describes one backend-advertised direct generation setting.
type StripeAiBillingCheckoutResponse ¶ added in v0.2.2
type StripeAiBillingCheckoutResponse struct {
URL string `json:"url"`
Raw json.RawMessage `json:"-"`
}
StripeAiBillingCheckoutResponse is returned by POST /api/v1/stripe_ai_billing/checkout.
func CreateStripeAiBillingCheckoutSession ¶ added in v0.2.2
func CreateStripeAiBillingCheckoutSession(backendURL, accessToken, client, uid string) (StripeAiBillingCheckoutResponse, error)
type StripeAiBillingStatusResponse ¶ added in v0.2.2
type StripeAiBillingStatusResponse struct {
Stripe StripeAiBillingStripe `json:"stripe"`
Usage StripeAiBillingUsage `json:"usage"`
Raw json.RawMessage `json:"-"`
}
StripeAiBillingStatusResponse is returned by GET /api/v1/stripe_ai_billing/status.
func GetStripeAiBillingStatus ¶ added in v0.2.2
func GetStripeAiBillingStatus(backendURL, accessToken, client, uid string, refresh bool) (StripeAiBillingStatusResponse, error)
type StripeAiBillingStripe ¶ added in v0.2.2
type StripeAiBillingStripe struct {
CustomerID string `json:"customer_id"`
SubscriptionID string `json:"subscription_id"`
SubscriptionStatus string `json:"subscription_status"`
AIPaymentMode string `json:"ai_payment_mode"`
MeteredLockedAt string `json:"metered_locked_at"`
MeteredLockReason string `json:"metered_lock_reason"`
RefreshedAt string `json:"refreshed_at"`
}
type StripeAiBillingSyncResponse ¶ added in v0.2.2
type StripeAiBillingSyncResponse struct {
OK bool `json:"ok"`
Raw json.RawMessage `json:"-"`
}
StripeAiBillingSyncResponse is returned by GET /api/v1/stripe_ai_billing/sync.
func SyncStripeAiBillingCheckoutSession ¶ added in v0.2.2
func SyncStripeAiBillingCheckoutSession(backendURL, accessToken, client, uid, sessionID string) (StripeAiBillingSyncResponse, error)
type StripeAiBillingUsEvent ¶ added in v0.2.2
type StripeAiBillingUsage ¶ added in v0.2.2
type StripeAiBillingUsage struct {
UnpaidTotalCents int64 `json:"unpaid_total_cents"`
TotalsCentsByStatus map[string]int64 `json:"totals_cents_by_status"`
Events []StripeAiBillingUsEvent `json:"events"`
}
type StripeAiPaymentModeResponse ¶ added in v0.2.2
type StripeAiPaymentModeResponse struct {
OK bool `json:"ok"`
AIPaymentMode string `json:"ai_payment_mode"`
Raw json.RawMessage `json:"-"`
}
StripeAiPaymentModeResponse is returned by POST /api/v1/stripe_ai_billing/mode.
func SetStripeAiPaymentMode ¶ added in v0.2.2
func SetStripeAiPaymentMode(backendURL, accessToken, client, uid, mode string) (StripeAiPaymentModeResponse, error)
type TagInfo ¶
type TagInfo = GenerationActionInfo
TagInfo is kept as a source-compatible alias for older callers.
func ListGenerationTags ¶
ListGenerationTags is kept as a compatibility wrapper for older callers.
type TeamsResponse ¶
type TeamsResponse struct {
Teams []TeamRef `json:"teams"`
Raw json.RawMessage `json:"-"`
}
func ListPublicTeams ¶
type ThreadResponse ¶
type ThreadResponse struct {
Quest Quest `json:"quest"`
Raw json.RawMessage `json:"-"`
}
func GetThread ¶
func GetThread(backendURL, threadID, accessToken, client, uid string) (ThreadResponse, error)
type UpvaluedContentLeaderboardItem ¶
type UpvaluedContentLeaderboardItem struct {
AnswerID string `json:"answer_id"`
QuestID string `json:"quest_id"`
QuestURL string `json:"quest_url"`
User User `json:"user"`
TotalSats int64 `json:"total_sats"`
UpvalueCount int `json:"upvalue_count"`
LastUpvalueAt string `json:"last_upvalue_at"`
Answer Answer `json:"answer"`
Quest Quest `json:"quest"`
}
type UpvaluedContentLeaderboardResponse ¶
type UpvaluedContentLeaderboardResponse struct {
Period struct {
StartDate string `json:"start_date"`
EndDate string `json:"end_date"`
} `json:"period"`
Limit int `json:"limit"`
Items []UpvaluedContentLeaderboardItem `json:"items"`
Raw json.RawMessage `json:"-"`
}