auto-gpt-ts
Version:
my take of Auto-GPT in typescript
53 lines (52 loc) • 2.01 kB
TypeScript
import { Loggable } from '../logging';
import { Message } from "./base";
import { CreateChatCompletionResponse } from "openai";
export declare class ApiManager extends Loggable {
totalTost: number;
totalBudget: number;
totalCompletionTokens: number;
totalPromptTokens: number;
reset(): void;
/**
* Create a chat completion and update the cost.
* @param {Array<Message>} messages - The list of messages to send to the API.
* @param {string} - The model to use for the API call.
* @param {number} - The temperature to use for the API call.
* @param {number} - The maximum number of tokens for the API call.
* @returns {Promise<Object>} - The AI's response.
*/
createChatCompletion(options: {
messages: Array<Message>;
model: string;
temperature?: number;
max_tokens: number;
}): Promise<CreateChatCompletionResponse>;
/**
* Update the total cost, prompt tokens, and completion tokens.
* @param {number} promptTokens - The number of tokens used in the prompt.
* @param {number} completionTokens - The number of tokens used in the completion.
* @param {string} model - The model used for the API call.
*/
updateCost(promptTokens: number, completionTokens: number, model: string): void;
/**
* Sets the total user-defined budget for API calls.
* @param {number} total_budget - The total budget for API calls.
*/
setTotalBudget(total_budget: number): void;
/**
* Get the total number of prompt tokens.
* @returns {number} - The total number of prompt tokens.
*/
getTotalPromptTokens(): number;
/**
* Get the total number of completion tokens.
* @returns {number} - The total number of completion tokens.
*/
getTotalCompletionTokens(): number;
/**
* Get the total cost of API calls.
* @returns {number} - The total cost of API calls.
*/
getTotalCost(): number;
getTotalBudget(): number;
}