ts-openai-chat
v0.1.0
Published
TypeScript, OpenAI, Chat
Downloads
3
Readme
ts-openai-chat
Easy to use OpenAI API (Only Chat)
Reference
Usage
- environment
- OPENAI_API_KEY
import { ChatMessage } from "ts-openai-chat"
const chatClient = new ChatClient();
const messages = [
{ role: "system", content: "シンプルな質問に答える" },
{ role: "user", content: "明日の天気は?" },
];
const answers = await chatClient.generate(messages);
methods
| method | parameters | return | | --------- | -------------------------------------------------------------- | ------------------- | | generate | messages: ChatMessage[] | { role: string; content: string }[] | Promise<Answer[]> | | setModel | model: ModelName | void | | setOption | key: OptionKey, value: number | void |
values
ModelName
- gpt-4
- gpt-4-0314
- gpt-4-32k
- gpt-4-32k-0314
- gpt-3.5-turbo
- gpt-3.5-turbo-0301"
OptionKey
- temperature
- top_p
- n
- max_tokens
- presence_penalty
- frequency_penalty"