azopenai

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Overview

Package azopenai is used to provide the Azure OpenAI service

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AzureOpenAIProvider

type AzureOpenAIProvider struct {
	APIKey      string
	APIEndpoint string
}

AzureOpenAIProvider is the provider for Azure OpenAI

func New

func New() *AzureOpenAIProvider

New creates a new AzureOpenAIProvider

func NewAzureOpenAIProvider

func NewAzureOpenAIProvider(apiKey string, apiEndpoint string) *AzureOpenAIProvider

NewAzureOpenAIProvider creates a new AzureOpenAIProvider

func (*AzureOpenAIProvider) GetChatCompletions

func (p *AzureOpenAIProvider) GetChatCompletions(userInstruction string) (*ai.InvokeResponse, error)

GetChatCompletions get chat completions for ai service

func (*AzureOpenAIProvider) GetOverview

func (p *AzureOpenAIProvider) GetOverview() (*ai.OverviewResponse, error)

GetOverview get overview for ai service

func (*AzureOpenAIProvider) ListToolCalls

func (p *AzureOpenAIProvider) ListToolCalls() (map[uint32]ai.ToolCall, error)

ListToolCalls list tool functions

func (*AzureOpenAIProvider) Name

func (p *AzureOpenAIProvider) Name() string

Name returns the name of the provider

func (*AzureOpenAIProvider) RegisterFunction

func (p *AzureOpenAIProvider) RegisterFunction(tag uint32, functionDefinition *ai.FunctionDefinition, connID uint64) error

RegisterFunction register function

func (*AzureOpenAIProvider) UnregisterFunction

func (p *AzureOpenAIProvider) UnregisterFunction(_ string, connID uint64) error

UnregisterFunction unregister function Be careful: a function can have multiple instances, remove the offline instance only.

type ReqBody

type ReqBody struct {
	Messages []ReqMessage  `json:"messages"`
	Tools    []ai.ToolCall `json:"tools"` // chatCompletionTool

}

ReqBody is the request body

type ReqMessage

type ReqMessage struct {
	Role       string `json:"role"`
	Content    string `json:"content"`
	ToolCallID string `json:"tool_call_id,omitempty"`
}

ReqMessage is the message in Request

type RespBody

type RespBody struct {
	ID                string       `json:"id"`
	Object            string       `json:"object"`
	Created           int          `json:"created"`
	Model             string       `json:"model"`
	Choices           []RespChoice `json:"choices"`
	Usage             RespUsage    `json:"usage"`
	SystemFingerprint string       `json:"system_fingerprint"`
}

RespBody is the response body

type RespChoice

type RespChoice struct {
	FinishReason string      `json:"finish_reason"`
	Index        int         `json:"index"`
	Message      RespMessage `json:"message"`
}

RespChoice is used to indicate the choice in Response by `FinishReason`

type RespMessage

type RespMessage struct {
	Role      string        `json:"role"`
	Content   string        `json:"content"`
	ToolCalls []ai.ToolCall `json:"tool_calls"`
}

RespMessage is the message in Response

type RespUsage

type RespUsage struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	TotalTokens      int `json:"total_tokens"`
}

RespUsage is the token usage in Response

Jump to

Keyboard shortcuts

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