api

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithHTTPClient

func WithHTTPClient(c *http.Client) func(*Client)

func WithTokenCache

func WithTokenCache(c cache.Cache) func(*Client)

Types

type ChatRequest

type ChatRequest struct {
	Model    string    `json:"model"`
	Messages []Message `json:"messages"`
	Stream   bool      `json:"stream,omitempty"`
}

type ChatResponse

type ChatResponse struct {
	Choices []Choice `json:"choices"`
	Created int64    `json:"created,omitempty"`
	ID      string   `json:"id"`
	Usage   Usage    `json:"usage,omitempty"`
}

type ChatResponseFunc

type ChatResponseFunc func(ChatResponse) error

ChatResponseFunc is a function that is called for each chat response.

type Choice

type Choice struct {
	FinishReason string  `json:"finish_reason,omitempty"`
	Index        int64   `json:"index,omitempty"`
	Message      Message `json:"message,omitempty"`
	Delta        Message `json:"delta,omitempty"`
}

type Client

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

func NewClient

func NewClient(opts ...Option) *Client

func (*Client) ChatCompletions

func (c *Client) ChatCompletions(ctx context.Context, token string, chatRequest *ChatRequest, fn ChatResponseFunc) error

ChatCompletions sends a chat request to the GitHub Copilot API.

func (*Client) Token

func (c *Client) Token(ctx context.Context, oauthToken string) (*TokenResponse, error)

Token retrieves the token from the GitHub Copilot API.

func (*Client) TokenWishCache

func (c *Client) TokenWishCache(ctx context.Context, oauthToken string) (string, error)

type FilterResult

type FilterResult struct {
	Filtered bool   `json:"filtered"`
	Severity string `json:"severity"`
}

type Message

type Message struct {
	Role    string `json:"role"` // one of ["system", "user", "assistant"]
	Content string `json:"content"`
}

type Option

type Option func(*Client)

type TokenResponse

type TokenResponse struct {
	ExpiresAt int64  `json:"expires_at"`
	Token     string `json:"token"`

	AnnotationsEnabled bool   `json:"annotations_enabled"`
	ChatEnabled        bool   `json:"chat_enabled"`
	ChatJetbrains      bool   `json:"chat_jetbrains_enabled"`
	CodeQuoteEnabled   bool   `json:"code_quote_enabled"`
	CopilotIDEAgent    bool   `json:"copilot_ide_agent_chat_gpt4_small_prompt"`
	CopilotIgnore      bool   `json:"copilotignore_enabled"`
	IntellijEditor     bool   `json:"intellij_editor_fetcher"`
	Prompt8k           bool   `json:"prompt_8k"`
	PublicSuggestions  string `json:"public_suggestions"`
	RefreshIn          int64  `json:"refresh_in"`
	Sku                string `json:"sku"`
	SnippyLoadTest     bool   `json:"snippy_load_test_enabled"`
	Telemetry          string `json:"telemetry"`
	TrackingID         string `json:"tracking_id"`
	VSCPanel           bool   `json:"vsc_panel_v2"`
}

type Usage

type Usage struct {
	CompletionTokens int64 `json:"completion_tokens"`
	PromptTokens     int64 `json:"prompt_tokens"`
	TotalTokens      int64 `json:"total_tokens"`
}

Jump to

Keyboard shortcuts

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