Research
Recent Trends in Malicious Packages Targeting Discord
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
openai-threads
Advanced tools
Readme
OpenAI-Threads is a Node.js module designed to interact with OpenAI's Thread API. It provides a simple and intuitive interface for creating and managing conversation threads with OpenAI's AI assistants. This module allows you to create threads, send messages, run threads, handle tool functions, and monitor the status of thread runs.
npm install openai-threads
or using yarn
:
yarn add openai-threads
First, import the OpenAIThread
class from the openai-threads
package and instantiate it with the ID of your assistant.
import { OpenAIThread } from "openai-threads";
const thread = new OpenAIThread("your-assistant-id");
Register functions that can be called during the thread run. These must be the same function name as the function's added to the Assistant on the website or through other code.
thread.registerFunction("functionName", async ({ argument }) => {
// Your function implementation
return { success: true, data: "result" };
});
Register event handlers to listen for thread updates.
thread.registerEvent("event-name", (run) => {
// Your event handling logic
});
const events = [
'requires_action',
'queued',
'in_progress',
'completed',
'expired',
'cancelling',
'cancelled',
'failed'
];
Create a new conversation thread.
await thread.createThread();
Send a message from the user to the thread.
await thread.createUserMessage("Your message to the AI.");
Run the thread with specific instructions.
await thread.runThread("Your instructions for the AI.");
Run the thread with specific instructions.
await thread.runThreadAndWait("Your instructions for the AI.");
Retrieve the most recent response from the thread.
const response = await thread.getResponse();
Fetch all messages from the thread.
const messages = await thread.getMessages();
For more detailed information about the methods and their parameters, please refer to the OpenAI API documentation.
You can find an example script on how to use OpenAI-Threads in the examples
directory.
Contributions are welcome! Please feel free to submit a pull request.
This project is licensed under the MIT License - see the LICENSE.md
file for details.
If you need help or have any questions, please open an issue in the GitHub repository.
Remember to replace `"your-assistant-id"` with the actual assistant ID provided by OpenAI and adjust the examples as needed for your actual use case. You should also provide a `LICENSE.md` file if you reference it in the README.
Additionally, make sure you have the necessary permissions and rights to use OpenAI's API, follow their guidelines, and handle user data responsibly as per their policies and any relevant laws.
FAQs
This library is designed to facilitate the interaction with OpenAI's Assistant API through the concept of a `thread,` which represents a conversation with an OpenAI assistant.
We found that openai-threads demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
Security News
Socket CEO Feross Aboukhadijeh joins a16z partners to discuss how modern, sophisticated supply chain attacks require AI-driven defenses and explore the challenges and solutions in leveraging AI for threat detection early in the development life cycle.
Security News
NIST's new AI Risk Management Framework aims to enhance the security and reliability of generative AI systems and address the unique challenges of malicious AI exploits.