Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
conversation-engine
Advanced tools
A powerful wrapper around the OpenAI API, providing additional features and making it easier to interact with AI models. Seamlessly chat with your AI assistant, include context strings, and manage conversation history.
A powerful wrapper around the OpenAI API, providing additional features and making it easier to interact with AI models. Seamlessly chat with your AI assistant, include context strings, and manage conversation history.
Give it a message and it will handle the rest.
Install my-project with npm
npm install conversation-engine
import { configureChat, chat, ModelName } from 'conversation-engine';
// Configure the chat
configureChat({
apiKey: 'your-openai-api-key',
modelSelection: ModelName.GPT_3_5_TURBO,
});
// Send a message
async function yourChatBot() {
const userMessage = { role: 'user', content: 'Tell me a joke!' };
const response = await chat(userMessage);
/*
// The response object
{
role: 'assistant',
content: "Why couldn't the bicycle stand up by itself? Because it was two tired!"
}
*/
console.log(response.content);
}
yourChatBot();
import { configureChat, chat, ModelName } from 'conversation-engine';
// Configure the chat with more options
configureChat({
apiKey: 'your-openai-api-key',
modelSelection: ModelName.GPT_4,
historyLength: 6,
historySummarizationModel: ModelName.GPT_3_5_TURBO,
openaiOptions: {
temperature: 0.8,
maxTokens: 500,
presencePenalty: 0,
frequencyPenalty: 0,
},
});
async function yourAdvancedChatBot() {
const userMessage = { role: 'user', content: 'What are two benefits of exercise?' };
const context = [
'Exercise can reduce your risk of heart diseases',
'Exercise can improve your mental health and mood. ',
];
const systemMessageContent = 'You are an AI health expert.';
const response = await chat(userMessage, context, systemMessageContent);
console.log(response.content);
}
yourAdvancedChatBot();
Note You should use dotenv to provide your apiKey.
A message object containing a role and content.
Property | Type | Description |
---|---|---|
role | string | The role of the message sender (system , user , or assistant ) |
content | string | The content of the message |
Enum for AI model names.
Value | Description |
---|---|
GPT_4 | GPT-4 Model |
GPT_4_32K | GPT-4-32K Model |
GPT_3_5_TURBO | GPT-3.5-Turbo Model |
A chat configuration object containing various settings.
Property | Type | Description |
---|---|---|
apiKey | string | The API key for accessing the AI service |
modelSelection | ModelName | The AI model to use for chat |
historyLength | number | The number of recent messages to include without summarization |
historySummarizationModel | ModelName | The AI model to use for history summarization |
messageHistory | Message[] | The array of message objects representing the chat history |
Optional settings for the OpenAI API. Check out their documentation.
Property | Type | Description |
---|---|---|
temperature | number | The temperature for generating responses |
topP | number | The top_p value for nucleus sampling |
n | number | The number of responses to generate |
stream (broken) | boolean | Whether to use streaming mode. (Streaming does not work currently) |
stop | string | string[] | A string or array of strings to stop the response generation |
maxTokens | number | The maximum number of tokens for the generated response |
presencePenalty | number | The presence penalty for the generated response |
frequencyPenalty | number | The frequency penalty for the generated response |
logitBias | { [token: string]: number } | An object of token strings and their biases |
user | string | A user identifier to associate with this chat completion |
A: You can use any of the models available in the OpenAI API, such as GPT-4, GPT-4-32K, and GPT-3.5-Turbo. You can refer to the ModelName enum for a complete list of supported models.
A: You can provide context by passing an array of context strings to the chat() function. This will include the context messages in the conversation, making it easier for the AI to understand the context.
A: The message history summarization feature helps to condense long conversations into a shorter, summarized form. This allows the AI to focus on the most relevant information and provide better responses. The summarization is done using the AI model specified in the ChatConfiguration object.
FAQs
A powerful wrapper around the OpenAI API, providing additional features and making it easier to interact with AI models. Seamlessly chat with your AI assistant, include context strings, and manage conversation history.
The npm package conversation-engine receives a total of 6 weekly downloads. As such, conversation-engine popularity was classified as not popular.
We found that conversation-engine demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.