Documentation ¶
Index ¶
- Constants
- type App
- func (a *App) ChatMessage(req ChatMessageRequest) (*ChatMessageResponse, error)
- func (a *App) ChatMessageStream(req ChatMessageRequest) (*ChatMessageStream, error)
- func (a *App) CompletionMessage(req CompletionMessageRequest) (*ChatCompletionMessageResponse, error)
- func (a *App) CompletionMessageStreaming(req CompletionMessageRequest) (*CompletionMessageStream, error)
- func (a *App) Conversations(req ConversationsRequest) (*ConversationsResponse, error)
- func (a *App) Feedback(req MessagesFeedbacksRequest) (*MessagesFeedbacksResponse, error)
- func (a *App) Messages(req MessagesRequest) (*MessagesResponse, error)
- func (a *App) Parameters(req ParametersRequest) (*ParametersResponse, error)
- func (a *App) SetDebug()
- func (a *App) StopChatMessage(taskID string) error
- func (a *App) StopCompletionMessage(taskID string) error
- func (a *App) StopWorkflowRun(taskID string) error
- func (a *App) Suggested(messageID, user string) (*SuggestedResponse, error)
- func (a *App) WorkflowRun(req WorkflowRunRequest) (*WorkflowRunResponse, error)
- func (a *App) WorkflowRunStream(req WorkflowRunRequest) (*WorkflowRunStream, error)
- type ChatCompletionMessageResponse
- type ChatMessageRequest
- type ChatMessageResponse
- type ChatMessageStream
- type ChatMessageStreamChannelResponse
- type ChatMessageStreamResponse
- type CompletionMessageRequest
- type CompletionMessageStream
- type ConversationsDataResponse
- type ConversationsRenamingRequest
- type ConversationsRenamingResponse
- type ConversationsRequest
- type ConversationsResponse
- type DefaultErrorAccumulator
- type ErrorAccumulator
- type ErrorResponse
- type JSONUnmarshaler
- type MessagesDataResponse
- type MessagesFeedbacksDataResponse
- type MessagesFeedbacksRequest
- type MessagesFeedbacksResponse
- type MessagesRequest
- type MessagesResponse
- type ParametersRequest
- type ParametersResponse
- type SuggestedResponse
- type Unmarshaler
- type WorkflowRunRequest
- type WorkflowRunResponse
- type WorkflowRunStream
- type WorkflowRunStreamResponse
Examples ¶
Constants ¶
View Source
const ( ResponseModeBlocking = "blocking" ResponseModeStreaming = "streaming" )
View Source
const ( RatingLike = "like" RatingDislike = "dislike" RatingNull = "null" )
View Source
const ( AppTypeTextGenerator = iota AppTypeChatApp AppTypeWorkflow )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct { Type int // contains filtered or unexported fields }
func (*App) ChatMessage ¶
func (a *App) ChatMessage(req ChatMessageRequest) (*ChatMessageResponse, error)
ChatMessage sends a chat message in blocking mode.
func (*App) ChatMessageStream ¶
func (a *App) ChatMessageStream(req ChatMessageRequest) (*ChatMessageStream, error)
func (*App) CompletionMessage ¶
func (a *App) CompletionMessage(req CompletionMessageRequest) (*ChatCompletionMessageResponse, error)
CompletionMessage sends a completion message and wait for completion in blocking mode.
func (*App) CompletionMessageStreaming ¶
func (a *App) CompletionMessageStreaming(req CompletionMessageRequest) (*CompletionMessageStream, error)
CompletionMessageStreaming sends a completion message and wait for completion in streaming mode.
Example ¶
client := New("", "") client.SetDebug() text := "Hello, how are you?" req := CompletionMessageRequest{ Inputs: map[string]interface{}{ "query": text, }, User: uuid.New().String(), } resp, err := client.CompletionMessageStreaming(req) if err != nil { panic(err) } for { r, err := resp.Recv() if err != nil { if errors.Is(err, io.EOF) { break } } if r.Answer != "" { print(r.Answer) } }
Output:
func (*App) Conversations ¶
func (a *App) Conversations(req ConversationsRequest) (*ConversationsResponse, error)
func (*App) Feedback ¶
func (a *App) Feedback(req MessagesFeedbacksRequest) (*MessagesFeedbacksResponse, error)
func (*App) Messages ¶
func (a *App) Messages(req MessagesRequest) (*MessagesResponse, error)
func (*App) Parameters ¶
func (a *App) Parameters(req ParametersRequest) (*ParametersResponse, error)
func (*App) StopChatMessage ¶
func (*App) StopCompletionMessage ¶
StopCompletionMessage stops the completion.
func (*App) StopWorkflowRun ¶
func (*App) WorkflowRun ¶
func (a *App) WorkflowRun(req WorkflowRunRequest) (*WorkflowRunResponse, error)
func (*App) WorkflowRunStream ¶
func (a *App) WorkflowRunStream(req WorkflowRunRequest) (*WorkflowRunStream, error)
type ChatMessageRequest ¶
type ChatMessageResponse ¶
type ChatMessageStream ¶
type ChatMessageStream struct {
// contains filtered or unexported fields
}
type ChatMessageStreamChannelResponse ¶
type ChatMessageStreamChannelResponse struct { ChatMessageStreamResponse Err error `json:"-"` }
type CompletionMessageStream ¶
type CompletionMessageStream struct {
// contains filtered or unexported fields
}
type ConversationsRenamingResponse ¶
type ConversationsRenamingResponse struct {
Result string `json:"result"`
}
type ConversationsRequest ¶
type ConversationsResponse ¶
type ConversationsResponse struct { Limit int `json:"limit"` HasMore bool `json:"has_more"` Data []ConversationsDataResponse `json:"data"` }
type DefaultErrorAccumulator ¶
type DefaultErrorAccumulator struct {
Buffer errorBuffer
}
func (*DefaultErrorAccumulator) Bytes ¶
func (e *DefaultErrorAccumulator) Bytes() (errBytes []byte)
func (*DefaultErrorAccumulator) Write ¶
func (e *DefaultErrorAccumulator) Write(p []byte) error
type ErrorAccumulator ¶
func NewErrorAccumulator ¶
func NewErrorAccumulator() ErrorAccumulator
type ErrorResponse ¶
type ErrorResponse struct { Status int `json:"status"` Code string `json:"code"` Message string `json:"message"` Params string `json:"params"` }
func (*ErrorResponse) Error ¶
func (e *ErrorResponse) Error() string
type JSONUnmarshaler ¶
type JSONUnmarshaler struct{}
type MessagesDataResponse ¶
type MessagesFeedbacksDataResponse ¶
type MessagesFeedbacksDataResponse struct { ID string `json:"id"` Username string `json:"username"` PhoneNumber string `json:"phone_number"` AvatarURL string `json:"avatar_url"` DisplayName string `json:"display_name"` ConversationID string `json:"conversation_id"` LastActiveAt int64 `json:"last_active_at"` CreatedAt int64 `json:"created_at"` }
type MessagesFeedbacksResponse ¶
type MessagesFeedbacksResponse struct { HasMore bool `json:"has_more"` Data []MessagesFeedbacksDataResponse `json:"data"` }
type MessagesRequest ¶
type MessagesResponse ¶
type MessagesResponse struct { Limit int `json:"limit"` HasMore bool `json:"has_more"` Data []MessagesDataResponse `json:"data"` }
type ParametersRequest ¶
type ParametersRequest struct {
User string `json:"user"`
}
type ParametersResponse ¶
type ParametersResponse struct { OpeningStatement string `json:"opening_statement"` SuggestedQuestions []interface{} `json:"suggested_questions"` SuggestedQuestionsAfterAnswer struct { Enabled bool `json:"enabled"` } `json:"suggested_questions_after_answer"` MoreLikeThis struct { Enabled bool `json:"enabled"` } `json:"more_like_this"` UserInputForm []map[string]interface{} `json:"user_input_form"` }
type SuggestedResponse ¶
type Unmarshaler ¶
type WorkflowRunRequest ¶
type WorkflowRunResponse ¶
type WorkflowRunResponse struct { LogID string `json:"log_id"` TaskID string `json:"task_id"` Data struct { ID string `json:"id"` WorkflowID string `json:"workflow_id"` Status string `json:"status"` Outputs map[string]interface{} `json:"outputs"` Error string `json:"error"` ElapsedTime float64 `json:"elapsed_time"` TotalTokens int `json:"total_tokens"` TotalSteps int `json:"total_steps"` CreatedAt int64 `json:"created_at"` FinishedAt int64 `json:"finished_at"` } }
type WorkflowRunStream ¶
type WorkflowRunStream struct {
// contains filtered or unexported fields
}
type WorkflowRunStreamResponse ¶
type WorkflowRunStreamResponse struct { Event string `json:"event"` TaskID string `json:"task_id"` WorkflowRunID string `json:"workflow_run_id"` Data struct { ID string `json:"id"` WorkflowID string `json:"workflow_id"` SequenceNumber int `json:"sequence_number,omitempty"` CreatedAt int64 `json:"created_at,omitempty"` NodeID string `json:"node_id,omitempty"` NodeType string `json:"node_type,omitempty"` Title string `json:"title,omitempty"` Index int `json:"index,omitempty"` PredecessorNodeID string `json:"predecessor_node_id,omitempty"` Inputs map[string]interface{} `json:"inputs,omitempty"` Outputs string `json:"outputs,omitempty"` // JSON string Status string `json:"status,omitempty"` Error string `json:"error,omitempty"` ElapsedTime float64 `json:"elapsed_time,omitempty"` TotalTokens int `json:"total_tokens,omitempty"` TotalSteps int `json:"total_steps,omitempty"` FinishedAt int64 `json:"finished_at,omitempty"` } }
Click to show internal directories.
Click to hide internal directories.