llamaai
v1.0.4
Published
node package for llama api
Downloads
1,002
Readme
LlamaAPI Node.js Library
How to Use
Follow these steps to use the LlamaAPI library:
Install the library via npm:
npm install llamaai
Bring the library into your project:
import LlamaAI from 'llamaai';
Instantiate the LlamaAPI class, providing your API token:
const apiToken = 'INSERT_YOUR_API_TOKEN_HERE'; const llamaAPI = new LlamaAI(apiToken);
Execute API requests using the
run
method:const apiRequestJson = { "messages": [ {"role": "user", "content": "What is the weather like in Boston?"}, ], "functions": [ { "name": "get_current_weather", "description": "Get the current weather in a given location", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g. San Francisco, CA", }, "days": { "type": "number", "description": "for how many days ahead you wants the forecast", }, "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}, }, }, "required": ["location", "days"], } ], "stream": false, "function_call": "get_current_weather", }; llamaAPI.run(apiRequestJson) .then(response => { // Process the API response here }) .catch(error => { // Handle any errors here });
And that's all! You can now utilize the LlamaAPI library in your project to communicate with the Llama API.
For additional details, please refer to the API documentation.