Documentation
¶
Index ¶
- func ToSpanPartType(partType entity.ContentType) tracespec.ModelMessagePartType
- type CacheOption
- type ContentPart
- type ContentType
- type ExecuteData
- type ExecuteOption
- type ExecuteOptions
- type ExecuteRequest
- type ExecuteResponse
- type ExecuteSSEParser
- type ExecuteStreamReader
- type ExecuteStreamingData
- type ExecuteStreamingOption
- type ExecuteStreamingOptions
- type Function
- type FunctionCall
- type GetPromptOptions
- type GetPromptParam
- type LLMConfig
- type MPullPromptRequest
- type MPullPromptResponse
- type Message
- type OpenAPIClient
- func (o *OpenAPIClient) Execute(ctx context.Context, req ExecuteRequest) (*ExecuteData, error)
- func (o *OpenAPIClient) ExecuteStreaming(ctx context.Context, req ExecuteRequest) (*http.Response, error)
- func (o *OpenAPIClient) MPullPrompt(ctx context.Context, req MPullPromptRequest) ([]*PromptResult, error)
- type Option
- type Options
- type Prompt
- type PromptCache
- type PromptFormatOptions
- type PromptQuery
- type PromptResult
- type PromptResultData
- type PromptTemplate
- type Provider
- func (p *Provider) Execute(ctx context.Context, req *entity.ExecuteParam, options ...ExecuteOption) (entity.ExecuteResult, error)
- func (p *Provider) ExecuteStreaming(ctx context.Context, req *entity.ExecuteParam, ...) (entity.StreamReader[entity.ExecuteResult], error)
- func (p *Provider) GetPrompt(ctx context.Context, param GetPromptParam, options GetPromptOptions) (prompt *entity.Prompt, err error)
- func (p *Provider) PromptFormat(ctx context.Context, prompt *entity.Prompt, variables map[string]any, ...) (messages []*entity.Message, err error)
- type Role
- type TemplateType
- type TokenUsage
- type Tool
- type ToolCall
- type ToolCallConfig
- type ToolChoiceType
- type ToolType
- type VariableDef
- type VariableType
- type VariableVal
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToSpanPartType ¶ added in v0.1.10
func ToSpanPartType(partType entity.ContentType) tracespec.ModelMessagePartType
Types ¶
type CacheOption ¶
type ContentPart ¶ added in v0.1.10
type ContentPart struct {
Type *ContentType `json:"type"`
Text *string `json:"text,omitempty"`
ImageURL *string `json:"image_url,omitempty"`
Base64Data *string `json:"base64_data,omitempty"`
}
type ContentType ¶ added in v0.1.10
type ContentType string
const ( ContentTypeText ContentType = "text" ContentTypeImageURL ContentType = "image_url" ContentTypeBase64Data ContentType = "base64_data" ContentTypeMultiPartVariable ContentType = "multi_part_variable" )
type ExecuteData ¶ added in v0.1.12
type ExecuteData struct {
Message *Message `json:"message,omitempty"`
FinishReason *string `json:"finish_reason,omitempty"`
Usage *TokenUsage `json:"usage,omitempty"`
}
type ExecuteOption ¶ added in v0.1.12
type ExecuteOption func(option *ExecuteOptions)
ExecuteOption Execute选项函数
type ExecuteRequest ¶ added in v0.1.12
type ExecuteRequest struct {
WorkspaceID string `json:"workspace_id"`
PromptIdentifier *PromptQuery `json:"prompt_identifier,omitempty"`
VariableVals []*VariableVal `json:"variable_vals,omitempty"`
Messages []*Message `json:"messages,omitempty"`
}
type ExecuteResponse ¶ added in v0.1.12
type ExecuteResponse struct {
httpclient.BaseResponse
Data *ExecuteData `json:"data"`
}
type ExecuteSSEParser ¶ added in v0.1.12
type ExecuteSSEParser struct {
// contains filtered or unexported fields
}
ExecuteSSEParser implements SSEParser for ExecuteResult
func NewExecuteSSEParser ¶ added in v0.1.12
func NewExecuteSSEParser(logID string) *ExecuteSSEParser
NewExecuteSSEParser creates a new ExecuteSSEParser
func (*ExecuteSSEParser) HandleError ¶ added in v0.1.12
func (p *ExecuteSSEParser) HandleError(sse *stream.ServerSentEvent) error
HandleError checks if the SSE event contains an error
func (*ExecuteSSEParser) Parse ¶ added in v0.1.12
func (p *ExecuteSSEParser) Parse(sse *stream.ServerSentEvent) (entity.ExecuteResult, error)
Parse parses SSE event into ExecuteResult
type ExecuteStreamReader ¶ added in v0.1.12
type ExecuteStreamReader struct {
*stream.BaseStreamReader[entity.ExecuteResult]
}
ExecuteStreamReader wraps BaseStreamReader for ExecuteResult
func NewExecuteStreamReader ¶ added in v0.1.12
NewExecuteStreamReader creates a new ExecuteStreamReader
type ExecuteStreamingData ¶ added in v0.1.12
type ExecuteStreamingData struct {
Code *int32 `json:"code,omitempty"`
Msg *string `json:"msg,omitempty"`
Message *Message `json:"message,omitempty"`
FinishReason *string `json:"finish_reason,omitempty"`
Usage *TokenUsage `json:"usage,omitempty"`
}
ExecuteStreamingData 流式执行响应数据结构体
type ExecuteStreamingOption ¶ added in v0.1.12
type ExecuteStreamingOption func(option *ExecuteStreamingOptions)
ExecuteStreamingOption ExecuteStreaming选项函数
type ExecuteStreamingOptions ¶ added in v0.1.12
type ExecuteStreamingOptions struct{}
ExecuteStreamingOptions ExecuteStreaming选项
type FunctionCall ¶ added in v0.1.12
type GetPromptOptions ¶
type GetPromptOptions struct{}
type GetPromptParam ¶
type LLMConfig ¶
type LLMConfig struct {
Temperature *float64 `json:"temperature,omitempty"`
MaxTokens *int32 `json:"max_tokens,omitempty"`
TopK *int32 `json:"top_k,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"`
PresencePenalty *float64 `json:"presence_penalty,omitempty"`
JSONMode *bool `json:"json_mode,omitempty"`
}
type MPullPromptRequest ¶
type MPullPromptRequest struct {
WorkSpaceID string `json:"workspace_id"`
Queries []PromptQuery `json:"queries"`
}
type MPullPromptResponse ¶
type MPullPromptResponse struct {
httpclient.BaseResponse
Data PromptResultData `json:"data"`
}
type Message ¶
type Message struct {
Role Role `json:"role"`
ReasoningContent *string `json:"reasoning_content,omitempty"`
Content *string `json:"content,omitempty"`
Parts []*ContentPart `json:"parts,omitempty"`
ToolCallID *string `json:"tool_call_id,omitempty"`
ToolCalls []*ToolCall `json:"tool_calls,omitempty"`
}
type OpenAPIClient ¶
type OpenAPIClient struct {
// contains filtered or unexported fields
}
func (*OpenAPIClient) Execute ¶ added in v0.1.12
func (o *OpenAPIClient) Execute(ctx context.Context, req ExecuteRequest) (*ExecuteData, error)
Execute 执行Prompt请求
func (*OpenAPIClient) ExecuteStreaming ¶ added in v0.1.12
func (o *OpenAPIClient) ExecuteStreaming(ctx context.Context, req ExecuteRequest) (*http.Response, error)
ExecuteStreaming 流式执行Prompt请求
func (*OpenAPIClient) MPullPrompt ¶
func (o *OpenAPIClient) MPullPrompt(ctx context.Context, req MPullPromptRequest) ([]*PromptResult, error)
type Option ¶
type Option func(*CacheOption)
type Prompt ¶
type Prompt struct {
WorkspaceID string `json:"workspace_id"`
PromptKey string `json:"prompt_key"`
Version string `json:"version"`
PromptTemplate *PromptTemplate `json:"prompt_template,omitempty"`
Tools []*Tool `json:"tools,omitempty"`
ToolCallConfig *ToolCallConfig `json:"tool_call_config,omitempty"`
LLMConfig *LLMConfig `json:"llm_config,omitempty"`
}
type PromptCache ¶
type PromptCache struct {
// contains filtered or unexported fields
}
func (*PromptCache) Get ¶
func (c *PromptCache) Get(promptKey, version, label string) (*entity.Prompt, bool)
func (*PromptCache) GetAllPromptQueries ¶
func (c *PromptCache) GetAllPromptQueries() []PromptQuery
GetAllPromptQueries gets all cached Prompt query conditions
func (*PromptCache) Set ¶
func (c *PromptCache) Set(promptKey, version, label string, prompt *entity.Prompt)
func (*PromptCache) Start ¶
func (c *PromptCache) Start()
func (*PromptCache) Stop ¶
func (c *PromptCache) Stop()
type PromptFormatOptions ¶
type PromptFormatOptions struct{}
type PromptQuery ¶
type PromptResult ¶
type PromptResult struct {
Query PromptQuery `json:"query"`
Prompt *Prompt `json:"prompt,omitempty"`
}
type PromptResultData ¶
type PromptResultData struct {
Items []*PromptResult `json:"items,omitempty"`
}
type PromptTemplate ¶
type PromptTemplate struct {
TemplateType TemplateType `json:"template_type"`
Messages []*Message `json:"messages,omitempty"`
VariableDefs []*VariableDef `json:"variable_defs,omitempty"`
}
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
func NewPromptProvider ¶
func (*Provider) Execute ¶ added in v0.1.12
func (p *Provider) Execute(ctx context.Context, req *entity.ExecuteParam, options ...ExecuteOption) (entity.ExecuteResult, error)
Execute 执行Prompt并返回结果
func (*Provider) ExecuteStreaming ¶ added in v0.1.12
func (p *Provider) ExecuteStreaming(ctx context.Context, req *entity.ExecuteParam, options ...ExecuteStreamingOption) (entity.StreamReader[entity.ExecuteResult], error)
ExecuteStreaming 流式执行Prompt并返回流式读取器
func (*Provider) GetPrompt ¶
func (p *Provider) GetPrompt(ctx context.Context, param GetPromptParam, options GetPromptOptions) (prompt *entity.Prompt, err error)
type TemplateType ¶
type TemplateType string
const ( TemplateTypeNormal TemplateType = "normal" TemplateTypeJinja2 TemplateType = "jinja2" )
type TokenUsage ¶ added in v0.1.12
type ToolCall ¶ added in v0.1.12
type ToolCall struct {
Index *int32 `json:"index,omitempty"`
ID *string `json:"id,omitempty"`
Type ToolType `json:"type"`
FunctionCall *FunctionCall `json:"function_call,omitempty"`
}
type ToolCallConfig ¶
type ToolCallConfig struct {
ToolChoice ToolChoiceType `json:"tool_choice"`
}
type ToolChoiceType ¶
type ToolChoiceType string
const ( ToolChoiceTypeAuto ToolChoiceType = "auto" ToolChoiceTypeNone ToolChoiceType = "none" )
type VariableDef ¶
type VariableDef struct {
Key string `json:"key"`
Desc string `json:"desc"`
Type VariableType `json:"type"`
}
type VariableType ¶
type VariableType string
const ( VariableTypeString VariableType = "string" VariableTypePlaceholder VariableType = "placeholder" VariableTypeBoolean VariableType = "boolean" VariableTypeInteger VariableType = "integer" VariableTypeFloat VariableType = "float" VariableTypeObject VariableType = "object" VariableTypeArrayString VariableType = "array<string>" VariableTypeArrayBoolean VariableType = "array<boolean>" VariableTypeArrayInteger VariableType = "array<integer>" VariableTypeArrayFloat VariableType = "array<float>" VariableTypeArrayObject VariableType = "array<object>" VariableTypeMultiPart VariableType = "multi_part" )
type VariableVal ¶ added in v0.1.12
type VariableVal struct {
Key string `json:"key"`
Value *string `json:"value,omitempty"`
PlaceholderMessages []*Message `json:"placeholder_messages,omitempty"`
MultiPartValues []*ContentPart `json:"multi_part_values,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.