Release Notes - useLLM v0.13.0
Introducing registerAgent, callAgentFunction and useChat functionalities
We are excited to bring to you useLLM@0.13.0.
In this version, we've enhanced the useLLM library by introducing the registerAgent
method and useChat
React hook. These features empower you to manage chat state, register new agents, and interact with language models more efficiently.
What's New
registerAgent Method
The registerAgent
method allows you to register a new agent with the LLM service, defining a model, initial messages, and set of callable functions for the agent. This new addition enhances your ability to leverage function calling with OpenAI's APIs.
Here's a sneak peek at how to use this feature:
llmService.registerAgent("agent-name", {
model: "model-id",
messages: [
{
role: "system",
content: "Initial message",
},
],
functions: [
{
call: (options) => { /* function body */ },
schema: { /* function schema */ },
},
],
});
Find out more about this method here.
callAgentFunction Method
The latest release also includes the callAgentFunction
method. This function enables the client-side to call a registered agent's function directly, thus making agent interaction more seamless.
Check out how to utilize this new feature:
const output = await llm.callAgentFunction({
agent: "github-qna",
function: name,
arguments: args,
});
useChat Hook
Version 0.13.0 also brings in the useChat React Hook. This Hook is designed to streamline your interaction with OpenAI's language models, encapsulating chat-specific actions and providing effortless chat state management.
The useChat Hook, extending the functionalities of useLLM Hook, furnishes an easy-to-navigate interface for managing chat operations. With its simple and intuitive structure, you can leverage useChat to manage chat state, send messages, and call functions. Its configuration, based on the UseChatOptions interface, allows customization according to your application's needs.
Here’s how to utilize this new functionality:
const {
isLoading,
messages,
sendMessage,
callFunction,
sendFunctionOutput,
input,
setInput,
} = useChat(options);
Example:
const { input, setInput, messages, sendMessage } = useChat({
stream: true,
initialMessages: [
{
role: "assistant",
content:
"I'm a chatbot powered by the ChatGPT API and developed using useLLM. Ask me anything!",
},
],
});
Learn more about this method here
Updated API Reference Docs
As always, we've updated our comprehensive API reference documentation. It now includes examples and usage scenarios for the new registerAgent, callAgentFunction
method and useChat
hook. We strive to help you navigate the package, understand each feature deeply, and integrate useLLM into your applications effectively.
Check out the updated docs to learn more: https://usellm.org/docs.