I am creating a TypeScript API for interacting with different LLM chat completion APIs.…
Rate quality
Private research annotation
Sign in to add a private research label or note.
- User
I am creating a TypeScript API for interacting with different LLM chat completion APIs. At the core of the API is a function that accepts a chat consisting of several messages or just a single message, and returns a Promise that resolves with the next message in the conversation (= the result of the call to the LLM). Can you suggest good names for the involved types?
Assistant
What a fascinating project!
For the types involved, I'd suggest the following names:
Chat: A type that represents a conversation, which can consist of multiple messages.Message: A type that represents a single message in the conversation.LLMResponse: A type that represents the response from the Large Language Model (LLM) API, which is the next message in the conversation.ChatCompletion: A type that represents the promise that resolves with the next message in the conversation (LLMResponse).
Here's a possible implementation:
typescriptinterface Message { id: string; text: string; } interface LLMResponse { id: string; text: string; } interface Chat { messages: Message[]; } type ChatCompletion = Promise<LLMResponse>;
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.