chatGPTapi

package module
v0.0.0-...-f810ad2 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2023 License: MIT Imports: 5 Imported by: 0

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"`
	MaxTokens        int     `json:"max_tokens"`
	Temperature      float64 `json:"temperature"`
	TopP             float64 `json:"top_p"`
	N                int     `json:"n"`
	Stream           bool    `json:"stream"`
	LogProbs         int     `json:"logprobs"`
	Echo             bool    `json:"echo"`
	Stop             string  `json:"stop"`
	PressencePenalty float64 `json:"presence_penalty"`
	FrequencyPenalty float64 `json:"frequency_penalty"`
	BestOf           int     `json:"best_of"`
	// LogitBias        map[string]int `json:"logit_bias"`
	User string `json:"user"`
}

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