Documentation
¶
Overview ¶
Package promptql provides a PromptQL client implementation.
Index ¶
- func NewApiAnthropicConfig(apiKey string) *api.ApiAnthropicConfig
- func NewApiOpenAIConfig(apiKey string) *api.ApiOpenAIConfig
- func NewArtifactUpdateChunk[A api.ArtifactInterface](artifact A) *api.ArtifactUpdateChunk
- func NewAssistantActionChunk(index int32) *api.AssistantActionChunk
- func NewErrorChunk(error_ string) *api.ErrorChunk
- func NewExecuteProgramRequest(code string) api.ExecuteRequest
- func NewHasuraLlmConfig() *api.HasuraLlmConfig
- func NewQueryRequestMessage(message string) api.QueryRequest
- func NewTableArtifact(identifier string, title string, data []map[string]any) *api.TableArtifact
- func NewTextArtifact(identifier string, title string, data string) *api.TextArtifact
- func NewThreadMetadataChunk(threadId uuid.UUID) *api.ThreadMetadataChunk
- func NewVisualizationArtifact(identifier string, title string, data api.VisualizationArtifactData) *api.VisualizationArtifact
- type Client
- func (c *Client) ExecuteProgram(ctx context.Context, body api.ExecuteRequest) (*api.PromptQlExecutionResult, error)
- func (c *Client) Query(ctx context.Context, body api.QueryRequest) (*api.QueryResponse, error)
- func (c *Client) QueryStream(ctx context.Context, body api.QueryRequest, callback QueryStreamCallback) error
- type ClientConfig
- type QueryChunks
- func (qc *QueryChunks) Add(chunk api.QueryResponseChunk) error
- func (qc QueryChunks) AsQueryResponse() api.QueryResponse
- func (qc QueryChunks) GetAssistantActions() []api.ApiThreadAssistantAction
- func (qc QueryChunks) GetErrorChunk() *api.ErrorChunk
- func (qc QueryChunks) GetModifiedArtifacts() []api.ExecuteRequestArtifactsInner
- func (qc QueryChunks) GetThreadId() uuid.UUID
- func (qc QueryChunks) IsError() bool
- func (qc *QueryChunks) SetAssistantActions(inputs []api.ApiThreadAssistantAction)
- func (qc *QueryChunks) SetErrorChunk(input *api.ErrorChunk)
- func (qc *QueryChunks) SetModifiedArtifacts(inputs []api.ExecuteRequestArtifactsInner)
- func (qc *QueryChunks) SetThreadId(threadId uuid.UUID)
- type QueryStreamCallback
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewApiAnthropicConfig ¶
func NewApiAnthropicConfig(apiKey string) *api.ApiAnthropicConfig
NewApiAnthropicConfig instantiates a new ApiAnthropicConfig object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
func NewApiOpenAIConfig ¶
func NewApiOpenAIConfig(apiKey string) *api.ApiOpenAIConfig
will change when the set of required properties is changed.
func NewArtifactUpdateChunk ¶
func NewArtifactUpdateChunk[A api.ArtifactInterface](artifact A) *api.ArtifactUpdateChunk
NewArtifactUpdateChunk create a new artifact update chunk.
func NewAssistantActionChunk ¶
func NewAssistantActionChunk(index int32) *api.AssistantActionChunk
will change when the set of required properties is changed.
func NewErrorChunk ¶
func NewErrorChunk(error_ string) *api.ErrorChunk
NewErrorChunk create a new error chunk.
func NewExecuteProgramRequest ¶
func NewExecuteProgramRequest(code string) api.ExecuteRequest
NewExecuteProgramRequest is a convenient function to create a execute program request from code.
func NewHasuraLlmConfig ¶
func NewHasuraLlmConfig() *api.HasuraLlmConfig
will change when the set of required properties is changed.
func NewQueryRequestMessage ¶
func NewQueryRequestMessage(message string) api.QueryRequest
NewQueryRequestMessage is a convenient function to create a simple query request with message only.
func NewTableArtifact ¶
will change when the set of required properties is changed.
func NewTextArtifact ¶
func NewTextArtifact(identifier string, title string, data string) *api.TextArtifact
will change when the set of required properties is changed.
func NewThreadMetadataChunk ¶ added in v0.2.0
func NewThreadMetadataChunk(threadId uuid.UUID) *api.ThreadMetadataChunk
will change when the set of required properties is changed.
func NewVisualizationArtifact ¶
func NewVisualizationArtifact( identifier string, title string, data api.VisualizationArtifactData, ) *api.VisualizationArtifact
will change when the set of required properties is changed.
Types ¶
type Client ¶
Client represents a PromptQL API client.
func NewClient ¶
func NewClient(apiKey string, config *ClientConfig) (*Client, error)
NewClient create a new PromptQL client instance.
func (*Client) ExecuteProgram ¶
func (c *Client) ExecuteProgram( ctx context.Context, body api.ExecuteRequest, ) (*api.PromptQlExecutionResult, error)
ExecuteProgram sends a request to the Natural Language Query API that allows you to interact with PromptQL directly, sending messages and receiving responses. The response is non-streaming.
func (*Client) Query ¶
func (c *Client) Query(ctx context.Context, body api.QueryRequest) (*api.QueryResponse, error)
Query sends a request to the Natural Language Query API that allows you to interact with PromptQL directly, sending messages and receiving responses. The response is non-streaming.
func (*Client) QueryStream ¶
func (c *Client) QueryStream( ctx context.Context, body api.QueryRequest, callback QueryStreamCallback, ) error
QueryStream sends a request to the Natural Language Query API that allows you to interact with PromptQL directly, sending messages and receiving responses. The response is streaming.
type ClientConfig ¶
type ClientConfig struct {
// The optional base URL of PromptQL API. The default value is the endpoint to the public DDN.
PromptQLBaseURL string
// Custom headers to be injected into PromptQL requests.
PromptQLHeaders map[string]string
// The base URL of your Hasura DDN project.
DdnBaseURL string
// Default headers to be forwarded to your Hasura DDN service.
DdnHeaders map[string]string
// Lazy function to generate headers to be forwarded to your Hasura DDN service.
DdnHeadersFn func() (map[string]string, error)
// Optional default LLM configuration to be used for natural language API requests.
Llm api.LlmInterface
// Optional default configuration for the AI primitives LLM provider.
AIPrimitivesLlmProvider api.LlmInterface
// Optional default system instructions for the natural language API request.
SystemInstructions string
// An [IANA timezone] for interpreting time-based queries. Default is the UTC timezone.
//
// [IANA timezone]: https://data.iana.org/time-zones/tzdb-2021a/zone1970.tab
Timezone string
// Custom HTTP client or Doer implementation, default: http.DefaultClient
HTTPClient api.Doer
// Set a logger to enable logging.
Logger *slog.Logger
}
ClientConfig holds configurations of the PromptQL client.
type QueryChunks ¶
type QueryChunks struct {
// contains filtered or unexported fields
}
QueryChunks are a convenient data type to help us join query response chunks together.
func NewQueryChunks ¶
func NewQueryChunks() *QueryChunks
NewQueryChunks create an empty QueryChunks instance.
func (*QueryChunks) Add ¶
func (qc *QueryChunks) Add(chunk api.QueryResponseChunk) error
Add or merge the response chunk into the chunks list.
func (QueryChunks) AsQueryResponse ¶
func (qc QueryChunks) AsQueryResponse() api.QueryResponse
AsQueryResponse converts to a QueryResponse instance.
func (QueryChunks) GetAssistantActions ¶
func (qc QueryChunks) GetAssistantActions() []api.ApiThreadAssistantAction
GetAssistantActions return a list of assistant actions.
func (QueryChunks) GetErrorChunk ¶
func (qc QueryChunks) GetErrorChunk() *api.ErrorChunk
GetErrorChunk returns a nullable error chunk.
func (QueryChunks) GetModifiedArtifacts ¶
func (qc QueryChunks) GetModifiedArtifacts() []api.ExecuteRequestArtifactsInner
GetModifiedArtifacts return a list of artifacts.
func (QueryChunks) GetThreadId ¶ added in v0.2.0
func (qc QueryChunks) GetThreadId() uuid.UUID
GetThreadID return the thread id.
func (QueryChunks) IsError ¶
func (qc QueryChunks) IsError() bool
IsError checks if the chunk is an error.
func (*QueryChunks) SetAssistantActions ¶
func (qc *QueryChunks) SetAssistantActions(inputs []api.ApiThreadAssistantAction)
SetAssistantActions set assistant actions.
func (*QueryChunks) SetErrorChunk ¶
func (qc *QueryChunks) SetErrorChunk(input *api.ErrorChunk)
SetErrorChunk set the error chunk.
func (*QueryChunks) SetModifiedArtifacts ¶
func (qc *QueryChunks) SetModifiedArtifacts(inputs []api.ExecuteRequestArtifactsInner)
SetModifiedArtifacts set modified artifacts.
func (*QueryChunks) SetThreadId ¶ added in v0.2.0
func (qc *QueryChunks) SetThreadId(threadId uuid.UUID)
SetThreadID set the thread id.
type QueryStreamCallback ¶
type QueryStreamCallback func(chunk api.QueryResponseChunk) error
QueryStreamCallback is the callback function for /query streaming.