auto-gpt-ts
Version:
my take of Auto-GPT in typescript
28 lines (27 loc) • 1.58 kB
TypeScript
import { Agent } from "../agent/agent";
import { MemoryProvider } from "../memory/base";
import { Message, Role } from "./base";
/**
* Create a chat message with the given role and content.
*
* @param role {Role} - The role of the message sender, e.g., "system", "user", or "assistant".
* @param content {string} - The content of the message.
*
* @returns {Message} - A dictionary containing the role and content of the message.
*/
export declare function createChatMessage(role: Role, content: string): Message;
/**
* Generate context for the OpenAI API by adding messages to a prompt until
* the token limit is reached.
*
* @param prompt {string} - The prompt to use.
* @param relevant_memory {string[]} - The relevant memory to include in the context.
* @param full_message_history {Message[]} - The full message history to use.
* @param model {string} - The name of the OpenAI model to use.
*
* @returns {[number, number, number, Message[]]} - A tuple containing the index of the next message
* to add, the current tokens used, the index at
* which to insert new messages, and the current context.
*/
export declare function generateContext(prompt: string, relevant_memory: string, full_message_history: Message[], model: string): [number, number, number, Message[]];
export declare function chat_with_ai(agent: Agent, prompt: string, user_input: string, full_message_history: Message[], permanent_memory: MemoryProvider, token_limit: number): Promise<string>;