openai_chatgpt

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BaseApiUrl = "https://api.openai.com/v1"

	ApiModels      = "/models"
	ApiCompletions = "/completions"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatGPTSettings

type ChatGPTSettings struct {
	Model       string  `json:"model"` // "text-davinci-003"
	Temperature float32 `json:"temperature"`
	MaxTokens   int     `json:"max_tokens"` // 1 token = 0.75 WORD
	TopP        int     `json:"top_p"`
	N           int     `json:"n"`
	Stop        string  `json:"stop"`
}

func (*ChatGPTSettings) Load

func (instance *ChatGPTSettings) Load(m map[string]interface{}) (err error)

func (*ChatGPTSettings) Map

func (instance *ChatGPTSettings) Map() (m map[string]interface{})

type OpenAIChatGPT

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

func NewOpenAIChatGPT

func NewOpenAIChatGPT(settings *commons.SettingsExternal) (instance *OpenAIChatGPT, err error)

func (*OpenAIChatGPT) Complete

func (instance *OpenAIChatGPT) Complete(prompt string, payload map[string]interface{}) (text string, response map[string]interface{}, err error)

Complete send the prompt to chatGPT payload: optional map to override default parameters (

		  "model": "text-davinci-003",
       "max_tokens": 75,
       "temperature": 0,
       "top_p": 1,
       "n": 1,
       "stop": "")

func (*OpenAIChatGPT) Get

func (instance *OpenAIChatGPT) Get(url string) (response map[string]interface{}, err error)

func (*OpenAIChatGPT) Post

func (instance *OpenAIChatGPT) Post(url string, body interface{}) (response map[string]interface{}, err error)

Jump to

Keyboard shortcuts

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