openai

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Overview

Copyright 2025 National Technology and Engineering Solutions of Sandia SPDX-License-Identifier: BSD-3-Clause

Copyright 2025 National Technology and Engineering Solutions of Sandia SPDX-License-Identifier: BSD-3-Clause

Copyright 2025 National Technology and Engineering Solutions of Sandia SPDX-License-Identifier: BSD-3-Clause

Index

Constants

View Source
const (
	RoleUser      string = "user"
	RoleAssistant string = "assistant"
)

Variables

This section is empty.

Functions

func Temperature

func Temperature(t float64) *float64

Types

type ChatRequest

type ChatRequest struct {
	Model          string          `json:"model"`
	Messages       []Message       `json:"messages"`
	ResponseFormat *ResponseFormat `json:"response_format,omitempty"`
	Temperature    *float64        `json:"temperature,omitempty"`
}

type ChatResponse

type ChatResponse struct {
	Choices []Choice `json:"choices"`
}

func (*ChatResponse) GetChoiceZero added in v0.3.0

func (r *ChatResponse) GetChoiceZero() ([]byte, error)

type Choice

type Choice struct {
	Message Message `json:"Message"`
}

type Client

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

func NewClient

func NewClient(apiKey string, options ...ClientOpt) *Client

func (*Client) BaseUrl added in v0.3.1

func (c *Client) BaseUrl() string

func (*Client) Chat

func (c *Client) Chat(req *ChatRequest) (*ChatResponse, error)

func (*Client) ChatGetChoiceZero added in v0.3.0

func (c *Client) ChatGetChoiceZero(req *ChatRequest) ([]byte, error)

type ClientOpt

type ClientOpt func(*Client)

func WithAuditDir added in v0.3.0

func WithAuditDir(dir string) ClientOpt

func WithAuditEnabled added in v0.3.0

func WithAuditEnabled(enabled bool) ClientOpt

func WithBaseUrl

func WithBaseUrl(baseUrl string) ClientOpt

func WithTimeout

func WithTimeout(t time.Duration) ClientOpt

type Message

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

func MakeSystemMessage

func MakeSystemMessage(c string) Message

func MakeUserMessage

func MakeUserMessage(c string) Message

type ResponseFormat

type ResponseFormat struct {
	Type       string `json:"type"`
	JSONSchema any    `json:"json_schema"`
}

func NewResponseFormat

func NewResponseFormat(schema any) *ResponseFormat

Jump to

Keyboard shortcuts

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