openai

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProcessAudioTranscriptions

func ProcessAudioTranscriptions(process *process.Process) interface{}

ProcessAudioTranscriptions openai.audio.Transcriptions

func ProcessChatCompletions

func ProcessChatCompletions(process *process.Process) interface{}

ProcessChatCompletions openai.chat.Completions

func ProcessEmbeddings

func ProcessEmbeddings(process *process.Process) interface{}

ProcessEmbeddings openai.Embeddings

func ProcessTiktoken

func ProcessTiktoken(process *process.Process) interface{}

ProcessTiktoken openai.Tiktoken

func Tiktoken

func Tiktoken(model string, input string) (int, error)

Tiktoken get number of tokens

Types

type Error

type Error struct {
	Message string      `json:"message,omitempty"`
	Type    string      `json:"type,omitempty"`
	Param   interface{} `json:"param,omitempty"`
	Code    string      `json:"code,omitempty"`
}

Error is the error response from OpenAI

type ErrorMessage

type ErrorMessage struct {
	Error Error `json:"error,omitempty"`
}

ErrorMessage is the error response from OpenAI

type Message

type Message struct {
	ID      string `json:"id,omitempty"`
	Object  string `json:"object,omitempty"`
	Created int64  `json:"created,omitempty"`
	Model   string `json:"model,omitempty"`
	Choices []struct {
		Delta struct {
			Content string `json:"content,omitempty"`
		} `json:"delta,omitempty"`
		Index        int    `json:"index,omitempty"`
		FinishReason string `json:"finish_reason,omitempty"`
	} `json:"choices,omitempty"`
}

Message is the response from OpenAI {"id":"chatcmpl-7Atx502nGBuYcvoZfIaWU4FREI1mT","object":"chat.completion.chunk","created":1682832715,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":"Hello"},"index":0,"finish_reason":null}]}

type OpenAI

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

OpenAI struct

func New

func New(id string) (*OpenAI, error)

New create a new OpenAI instance by connector id

func (OpenAI) AudioTranscriptions

func (openai OpenAI) AudioTranscriptions(dataBase64 string, option map[string]interface{}) (interface{}, *exception.Exception)

AudioTranscriptions Transcribes audio into the input language. https://platform.openai.com/docs/api-reference/audio/create

func (OpenAI) ChatCompletions

func (openai OpenAI) ChatCompletions(messages []map[string]interface{}, option map[string]interface{}, cb func(data []byte) int) (interface{}, *exception.Exception)

ChatCompletions Creates a model response for the given chat conversation. https://platform.openai.com/docs/api-reference/chat/create

func (OpenAI) ChatCompletionsWith

func (openai OpenAI) ChatCompletionsWith(ctx context.Context, messages []map[string]interface{}, option map[string]interface{}, cb func(data []byte) int) (interface{}, *exception.Exception)

ChatCompletionsWith Creates a model response for the given chat conversation. https://platform.openai.com/docs/api-reference/chat/create

func (OpenAI) Completions

func (openai OpenAI) Completions(prompt interface{}, option map[string]interface{}, cb func(data []byte) int) (interface{}, *exception.Exception)

Completions Creates a completion for the provided prompt and parameters. https://platform.openai.com/docs/api-reference/completions/create

func (OpenAI) CompletionsWith

func (openai OpenAI) CompletionsWith(ctx context.Context, prompt interface{}, option map[string]interface{}, cb func(data []byte) int) (interface{}, *exception.Exception)

CompletionsWith Creates a completion for the provided prompt and parameters. https://platform.openai.com/docs/api-reference/completions/create

func (OpenAI) Edits

func (openai OpenAI) Edits(instruction string, option map[string]interface{}) (interface{}, *exception.Exception)

Edits Creates a new edit for the provided input, instruction, and parameters. https://platform.openai.com/docs/api-reference/edits/create

func (OpenAI) Embeddings

func (openai OpenAI) Embeddings(input interface{}, user string) (interface{}, *exception.Exception)

Embeddings Creates an embedding vector representing the input text. https://platform.openai.com/docs/api-reference/embeddings/create

func (OpenAI) GetContent

func (openai OpenAI) GetContent(response interface{}) (string, *exception.Exception)

GetContent get the content of chat completions

func (OpenAI) ImagesEdits

func (openai OpenAI) ImagesEdits(imageBase64 string, prompt string, option map[string]interface{}) (interface{}, *exception.Exception)

ImagesEdits Creates an edited or extended image given an original image and a prompt. https://platform.openai.com/docs/api-reference/images/create-edit

func (OpenAI) ImagesGenerations

func (openai OpenAI) ImagesGenerations(prompt string, option map[string]interface{}) (interface{}, *exception.Exception)

ImagesGenerations Creates an image given a prompt. https://platform.openai.com/docs/api-reference/images

func (OpenAI) ImagesVariations

func (openai OpenAI) ImagesVariations(imageBase64 string, option map[string]interface{}) (interface{}, *exception.Exception)

ImagesVariations Creates a variation of a given image. https://platform.openai.com/docs/api-reference/images/create-variation

func (OpenAI) MaxToken

func (openai OpenAI) MaxToken() int

MaxToken get max number of tokens

func (OpenAI) Tiktoken

func (openai OpenAI) Tiktoken(input string) (int, error)

Tiktoken get number of tokens

Jump to

Keyboard shortcuts

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