openai

package
v0.0.0-...-a0e9b24 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AI

type AI struct {
	Client *openai.Client
}

AI represents a client for interacting with OpenAI's API.

func NewAI

func NewAI() *AI

func (*AI) ExtractTextFromAudio

func (ai *AI) ExtractTextFromAudio(ctx context.Context, filePath string) (string, error)

ExtractTextFromAudio extracts text from an audio file using OpenAI's Whisper model. It takes an audio file path as input and returns the transcribed text.

Parameters:

  • ctx: The context for managing request deadlines and cancellation signals.
  • filePath: The path to the audio file to be transcribed.

Returns:

  • A string containing the transcribed text.
  • An error if the transcription fails or if there is an issue with file handling.

func (*AI) GenerateImageFromText

func (ai *AI) GenerateImageFromText(ctx context.Context, prompt string) (image.Image, error)

GenerateImageFromText generates a 256x256 image based on the provided text prompt. It communicates with OpenAI's API to create the image and returns it as an image.Image object.

Parameters:

  • ctx: The context for managing request deadlines and cancellation signals.
  • prompt: A string containing the description of the image to generate.

Returns:

  • An image.Image object representing the generated image.
  • An error if the image generation or processing fails.

func (*AI) GenerateImageURLFromText

func (ai *AI) GenerateImageURLFromText(ctx context.Context, prompt string) (string, error)

GenerateImageFromText generates a 256x256 image based on the provided text prompt. It communicates with OpenAI's API to create the image and returns it as an image.Image object.

Parameters:

  • ctx: The context for managing request deadlines and cancellation signals.
  • prompt: A string containing the description of the image to generate.

Returns:

  • An image.Image object representing the generated image.
  • An error if the image generation or processing fails.

func (*AI) GeneratePresentationFromText

func (ai *AI) GeneratePresentationFromText(ctx context.Context, preprompt string, content []byte) (*structure.Presentation, error)

GeneratePresentationFromText generates a presentation from Markdown content

func (*AI) GenerateSlide

func (ai *AI) GenerateSlide(ctx context.Context, preprompt string, content []byte) (*structure.Slide, error)

GenerateSlide

func (*AI) SimpleQuery

func (ai *AI) SimpleQuery(ctx context.Context, prompt string) (string, error)

Jump to

Keyboard shortcuts

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