Oleg d63df93c65 Add OpenAI Mock Server (#31)
* add constants for completions, refactor usage, add test server

Signed-off-by: Oleg <97077423+RobotSail@users.noreply.github.com>

* append v1 endpoint to test

Signed-off-by: Oleg <97077423+RobotSail@users.noreply.github.com>

* add makefile for easy targets

Signed-off-by: Oleg <97077423+RobotSail@users.noreply.github.com>

* lint files & add linter

Signed-off-by: Oleg <97077423+RobotSail@users.noreply.github.com>

* disable real API tests in short mode

Signed-off-by: Oleg <97077423+RobotSail@users.noreply.github.com>

Signed-off-by: Oleg <97077423+RobotSail@users.noreply.github.com>
2022-08-11 15:29:23 +06:00
2022-07-01 21:13:12 +06:00
2020-08-19 12:57:32 +03:00
2022-08-11 15:29:23 +06:00
2022-08-11 15:29:23 +06:00
2022-08-11 15:29:23 +06:00
2022-08-11 15:29:23 +06:00
2022-08-11 15:29:23 +06:00
2022-08-11 15:29:23 +06:00
2022-08-11 15:29:23 +06:00
2022-08-11 15:29:23 +06:00
2022-08-11 15:29:23 +06:00
2021-12-15 22:24:34 +03:00
2020-08-18 17:42:55 +03:00
2022-08-11 15:29:23 +06:00
2022-08-11 15:29:23 +06:00
2022-08-11 15:29:23 +06:00

go-gpt3

GoDoc Go Report Card

OpenAI GPT-3 API wrapper for Go

Installation:

go get github.com/sashabaranov/go-gpt3

Example usage:

package main

import (
	"context"
	"fmt"
	gogpt "github.com/sashabaranov/go-gpt3"
)

func main() {
	c := gogpt.NewClient("your token")
	ctx := context.Background()

	req := gogpt.CompletionRequest{
		Model: "ada",
		MaxTokens: 5,
		Prompt:    "Lorem ipsum",
	}
	resp, err := c.CreateCompletion(ctx, req)
	if err != nil {
		return
	}
	fmt.Println(resp.Choices[0].Text)

	searchReq := gogpt.SearchRequest{
		Documents: []string{"White House", "hospital", "school"},
		Query:     "the president",
	}
	searchResp, err := c.Search(ctx, "ada", searchReq)
	if err != nil {
		return
	}
	fmt.Println(searchResp.SearchResults)
}
Description
No description provided
Readme Apache-2.0 952 KiB
Languages
Go 100%