prompt

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

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 CacheOption struct {
	EnableAsyncUpdate bool          // Whether to enable asynchronous updates
	UpdateInterval    time.Duration // Update interval, if 0, use default value
	MaxCacheSize      int
}

type ContentPart added in v0.1.10

type ContentPart struct {
	Type *ContentType `json:"type"`
	Text *string      `json:"text,omitempty"`
}

type ContentType added in v0.1.10

type ContentType string
const (
	ContentTypeText              ContentType = "text"
	ContentTypeMultiPartVariable ContentType = "multi_part_variable"
)

type Function

type Function struct {
	Name        string  `json:"name"`
	Description *string `json:"description,omitempty"`
	Parameters  *string `json:"parameters,omitempty"`
}

type GetPromptOptions

type GetPromptOptions struct {
}

type GetPromptParam

type GetPromptParam struct {
	PromptKey string
	Version   string
	Label     string
}

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"`
	Content *string        `json:"content,omitempty"`
	Parts   []*ContentPart `json:"parts,omitempty"`
}

type OpenAPIClient

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

func (*OpenAPIClient) MPullPrompt

func (o *OpenAPIClient) MPullPrompt(ctx context.Context, req MPullPromptRequest) ([]*PromptResult, error)

type Option

type Option func(*CacheOption)

type Options

type Options struct {
	WorkspaceID                string
	PromptCacheMaxCount        int
	PromptCacheRefreshInterval time.Duration
	PromptTrace                bool
}

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 PromptQuery struct {
	PromptKey string `json:"prompt_key"`
	Version   string `json:"version"`
	Label     string `json:"label,omitempty"`
}

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 NewPromptProvider(httpClient *httpclient.Client, traceProvider *trace.Provider, options Options) *Provider

func (*Provider) GetPrompt

func (p *Provider) GetPrompt(ctx context.Context, param GetPromptParam, options GetPromptOptions) (prompt *entity.Prompt, err error)

func (*Provider) PromptFormat

func (p *Provider) PromptFormat(ctx context.Context, prompt *entity.Prompt, variables map[string]any, options PromptFormatOptions) (messages []*entity.Message, err error)

type Role

type Role string
const (
	RoleSystem      Role = "system"
	RoleUser        Role = "user"
	RoleAssistant   Role = "assistant"
	RoleTool        Role = "tool"
	RolePlaceholder Role = "placeholder"
)

type TemplateType

type TemplateType string
const (
	TemplateTypeNormal TemplateType = "normal"
	TemplateTypeJinja2 TemplateType = "jinja2"
)

type Tool

type Tool struct {
	Type     ToolType  `json:"type"`
	Function *Function `json:"function,omitempty"`
}

type ToolCallConfig

type ToolCallConfig struct {
	ToolChoice ToolChoiceType `json:"tool_choice"`
}

type ToolChoiceType

type ToolChoiceType string
const (
	ToolChoiceTypeAuto ToolChoiceType = "auto"
	ToolChoiceTypeNone ToolChoiceType = "none"
)

type ToolType

type ToolType string
const (
	ToolTypeFunction ToolType = "function"
)

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"
)

Jump to

Keyboard shortcuts

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