This project features a sample implementation of Hume's Empathic Voice Interface using Hume's React SDK. Here, we have a simple EVI that calls a function to get the weather for a given location.
See the Tool Use guide for a detailed explanation of the code in this project.
-
Create a tool with the following payload:
{ "name": "get_current_weather", "description": "This tool is for getting the current weather.", "parameters": "{ \"type\": \"object\", \"properties\": { \"location\": { \"type\": \"string\", \"description\": \"The city and state, e.g. San Francisco, CA\" }, \"format\": { \"type\": \"string\", \"enum\": [\"celsius\", \"fahrenheit\"], \"description\": \"The temperature unit to use. Infer this from the users location.\" } }, \"required\": [\"location\", \"format\"] }" }
-
Create a configuration equipped with that tool:
{ "name": "Weather Assistant Config", "language_model": { "model_provider": "ANTHROPIC", "model_resource": "claude-3-5-sonnet-20240620" }, "tools": [ { "id": "<YOUR_TOOL_ID>", "version": 0 } ] }
-
Clone this examples repository:
git clone https://github.com/humeai/hume-api-examples cd hume-api-examples/evi/evi-next-js-function-calling
-
Install dependencies:
pnpm install
-
Set up your API key and Secret key:
In order to make an authenticated connection we will first need to generate an access token. Doing so will require your API key and Secret key. These keys can be obtained by logging into the Hume AI Platform and visiting the API keys page. For detailed instructions, see our documentation on getting your api keys.
Place your
HUME_API_KEY
andHUME_SECRET_KEY
in a.env
file at the root of your project.echo "HUME_API_KEY=your_api_key_here" > .env echo "HUME_SECRET_KEY=your_secret_key_here" >> .env
You can copy the
.env.example
file to use as a template. -
Add your Config ID to the
.env
file. This ID is from the EVI configuration you created earlier that includes your weather tool.echo "NEXT_PUBLIC_HUME_CONFIG_ID=your_config_id_here" >> .env
-
Add the Geocoding API key to the
.env
file. You can obtain it for free from geocode.maps.co.echo "GEOCODING_API_KEY=your_geocoding_api_key_here" >> .env
-
Run the project:
pnpm run dev
This will start the Next.js development server, and you can access the application at
http://localhost:3000
.
Here's an example of how you might interact with the EVI to get weather information:
User: "What's the weather like in New York City?"
EVI: (Uses the get_current_weather tool to fetch data) "Currently in New York City, it's 72°F (22°C) and partly cloudy. The forecast calls for a high of 78°F (26°C) and a low of 65°F (18°C) today."
This project is licensed under the MIT License - see the LICENSE.md file for details.