chatGPTapi

package module
v0.0.0-...-1ee1072 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2023 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Choice

type Choice struct {
	Text         string
	Index        int
	LogProbs     int
	FinishReason string
}

type Client

type Client struct {
	APIurl     string
	APIkey     string
	HTTPclient http.Client
}

func CreateClient

func CreateClient(APIkey, APIurl string) (C Client)

func (Client) AskGPTansw

func (C Client) AskGPTansw(prompt string) (answer string, err error)

func (Client) AskGPTresp

func (C Client) AskGPTresp(prompt string) (resp *http.Response, err error)

type PromptParams

type PromptParams struct {
	Model            string         `json:"model"` // required
	Prompt           string         `json:"prompt"`
	Suffix           string         `json:"suffix,omitempty"`
	MaxTokens        int            `json:"max_tokens,omitempty"`
	Temperature      float64        `json:"temperature,omitempty"`
	TopP             float64        `json:"top_p,omitempty"`
	N                int            `json:"n,omitempty"`
	Stream           bool           `json:"stream,omitempty"`
	LogProbs         int            `json:"logprobs,omitempty"`
	Echo             bool           `json:"echo,omitempty"`
	Stop             string         `json:"stop,omitempty"`
	PressencePenalty float64        `json:"presence_penalty,omitempty"`
	FrequencyPenalty float64        `json:"frequency_penalty,omitempty"`
	BestOf           int            `json:"best_of,omitempty"`
	LogitBias        map[string]int `json:"logit_bias,omitempty"`
	User             string         `json:"user,omitempty"`
}

func CreatePrompParams

func CreatePrompParams(prompt string) (P PromptParams)

type Response

type Response struct {
	ID      string
	Object  string
	Created int
	Model   string
	Choices []Choice
	Usage   Usage
}

type Usage

type Usage struct {
	PromptTokens     int
	CompletionTokens int
	TotalTokens      int
}

Jump to

Keyboard shortcuts

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