Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zg/update api credential name #63

Merged
merged 7 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion evi-next-js-app-router/.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
HUME_API_KEY="<YOUR API KEY>"
HUME_CLIENT_SECRET="<YOUR CLIENT SECRET>"
HUME_SECRET_KEY="<YOUR SECRET KEY>"
4 changes: 2 additions & 2 deletions evi-next-js-app-router/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ This project features a sample implementation of Hume's [Empathic Voice Interfac

Click the button below to deploy this example project with Vercel:

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fhumeai%2Fhume-api-examples%2Ftree%2Fmain%2Fevi-next-js-app-router&env=HUME_API_KEY,HUME_CLIENT_SECRET)
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fhumeai%2Fhume-api-examples%2Ftree%2Fmain%2Fevi-next-js-app-router&env=HUME_API_KEY,HUME_SECRET_KEY)

Below are the steps to completing deployment:

1. Create a Git Repository for your project.
2. Provide the required environment variables. To get your API key and Client Secret key, log into the portal and visit the [API keys page](https://beta.hume.ai/settings/keys).
2. Provide the required environment variables. To get your API key and Secret key, log into the portal and visit the [API keys page](https://beta.hume.ai/settings/keys).
4 changes: 2 additions & 2 deletions evi-next-js-app-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"lint": "next lint"
},
"dependencies": {
"@humeai/voice": "^0.1.2",
"@humeai/voice-react": "^0.1.2",
"@humeai/voice": "^0.1.7",
"@humeai/voice-react": "^0.1.7",
"next": "14.2.3",
"react": "^18",
"react-dom": "^18"
Expand Down
6 changes: 3 additions & 3 deletions evi-next-js-app-router/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// ./app/page.tsx
import ClientComponent from "@/components/ClientComponent";
import { fetchAccessToken } from "@humeai/voice";
import ClientComponent from '@/components/ClientComponent';
import { fetchAccessToken } from '@humeai/voice';

export default async function Page() {
const accessToken = await fetchAccessToken({
apiKey: String(process.env.HUME_API_KEY),
clientSecret: String(process.env.HUME_CLIENT_SECRET),
secretKey: String(process.env.HUME_SECRET_KEY),
});

if (!accessToken) {
Expand Down
2 changes: 1 addition & 1 deletion evi-next-js-function-calling/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NEXT_PUBLIC_HUME_API_KEY=""
NEXT_PUBLIC_HUME_CLIENT_SECRET=""
NEXT_PUBLIC_HUME_SECRET_KEY=""
NEXT_PUBLIC_HUME_VOICE_WEATHER_CONFIG_ID=""
NEXT_PUBLIC_GEOCODING_API_KEY=""
4 changes: 2 additions & 2 deletions evi-next-js-function-calling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ This project is an example of how to call functions in a Next.js application usi

## EVI setup

1. Create a .env file and add your [API Key and your Client Secret](https://beta.hume.ai/settings/keys):
1. Create a .env file and add your [API Key and your Secret Key](https://beta.hume.ai/settings/keys):

```bash
echo "NEXT_PUBLIC_HUME_API_KEY = <YOUR_HUME_API_KEY>" >> .env
echo "NEXT_PUBLIC_HUME_CLIENT_SECRET = <YOUR_HUME_CLIENT_SECRET>" >> .env
echo "NEXT_PUBLIC_HUME_SECRET_KEY = <YOUR_HUME_SECRET_KEY>" >> .env
```

2. [Create a tool](https://dev.hume.ai/docs/empathic-voice-interface-evi/tool-use#create-a-tool) with the following payload:
Expand Down
4 changes: 2 additions & 2 deletions evi-next-js-function-calling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"lint": "next lint"
},
"dependencies": {
"@humeai/voice": "^0.1.3",
"@humeai/voice-react": "^0.1.3",
"@humeai/voice": "^0.1.7",
"@humeai/voice-react": "^0.1.7",
"next": "14.2.3",
"react": "^18.3.1",
"react-dom": "^18.3.1"
Expand Down
10 changes: 5 additions & 5 deletions evi-next-js-function-calling/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// ./app/page.tsx
import ClientComponent from "@/components/ClientComponent";
import { fetchAccessToken } from "@humeai/voice";
import ClientComponent from '@/components/ClientComponent';
import { fetchAccessToken } from '@humeai/voice';

export default async function Page() {
console.log(process.env.NEXT_PUBLIC_HUME_API_KEY);
console.log(process.env.NEXT_PUBLIC_HUME_CLIENT_SECRET);
console.log(process.env.NEXT_PUBLIC_HUME_SECRET_KEY);

const accessToken = await fetchAccessToken({
apiKey: String(process.env.NEXT_PUBLIC_HUME_API_KEY),
clientSecret: String(process.env.NEXT_PUBLIC_HUME_CLIENT_SECRET),
secretKey: String(process.env.NEXT_PUBLIC_HUME_SECRET_KEY),
});

if (!accessToken) {
Expand Down
2 changes: 1 addition & 1 deletion evi-next-js-pages-router/.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
HUME_API_KEY="<YOUR API KEY>"
HUME_CLIENT_SECRET="<YOUR CLIENT SECRET>"
HUME_SECRET_KEY="<YOUR SECRET KEY>"
4 changes: 2 additions & 2 deletions evi-next-js-pages-router/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ This project features a sample implementation of Hume's [Empathic Voice Interfac

Click the button below to deploy this example project with Vercel:

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fhumeai%2Fhume-api-examples%2Ftree%2Fmain%2Fevi-next-js-pages-router&env=HUME_API_KEY,HUME_CLIENT_SECRET)
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fhumeai%2Fhume-api-examples%2Ftree%2Fmain%2Fevi-next-js-pages-router&env=HUME_API_KEY,HUME_SECRET_KEY)

Below are the steps to completing deployment:

1. Create a Git Repository for your project.
2. Provide the required environment variables. To get your API key and Client Secret key, log into the portal and visit the [API keys page](https://beta.hume.ai/settings/keys).
2. Provide the required environment variables. To get your API key and Secret key, log into the portal and visit the [API keys page](https://beta.hume.ai/settings/keys).
4 changes: 2 additions & 2 deletions evi-next-js-pages-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"lint": "next lint"
},
"dependencies": {
"@humeai/voice": "^0.1.2",
"@humeai/voice-react": "^0.1.2",
"@humeai/voice": "^0.1.7",
"@humeai/voice-react": "^0.1.7",
"next": "14.2.3",
"react": "^18",
"react-dom": "^18"
Expand Down
16 changes: 8 additions & 8 deletions evi-next-js-pages-router/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
// ./pages/index.tsx

import Controls from "@/components/Controls";
import Messages from "@/components/Messages";
import { fetchAccessToken } from "@humeai/voice";
import { VoiceProvider } from "@humeai/voice-react";
import { InferGetServerSidePropsType } from "next";
import Controls from '@/components/Controls';
import Messages from '@/components/Messages';
import { fetchAccessToken } from '@humeai/voice';
import { VoiceProvider } from '@humeai/voice-react';
import { InferGetServerSidePropsType } from 'next';

export const getServerSideProps = async () => {
const accessToken = await fetchAccessToken({
apiKey: String(process.env.HUME_API_KEY),
clientSecret: String(process.env.HUME_CLIENT_SECRET),
secretKey: String(process.env.HUME_SECRET_KEY),
});

if (!accessToken) {
return {
redirect: {
destination: "/error",
destination: '/error',
permanent: false,
},
};
Expand All @@ -32,7 +32,7 @@ type PageProps = InferGetServerSidePropsType<typeof getServerSideProps>;

export default function Page({ accessToken }: PageProps) {
return (
<VoiceProvider auth={{ type: "accessToken", value: accessToken }}>
<VoiceProvider auth={{ type: 'accessToken', value: accessToken }}>
<Messages />
<Controls />
</VoiceProvider>
Expand Down
17 changes: 8 additions & 9 deletions evi-python-api-example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,31 @@ In order to run it, you need to install the `requirements.txt` using `pip`:
### Mac

```bash
pip install -r requirements_mac.txt
pip install -r requirements_mac.txt
```

### Linux

```bash
pip install -r requirements_linux.txt
pip install -r requirements_linux.txt
```

## Environment variables

Either create a `.env` file or set environment variables for HUME_API_KEY and HUME_CLIENT_SECRET.
Either create a `.env` file or set environment variables for HUME_API_KEY and HUME_SECRET_KEY.

Example `.env` file:

```bash
HUME_API_KEY="autj04acqK3jpfERQJpkg7829AATGUEvlAR7SYmmOB5ZZVbZD"
HUME_CLIENT_SECRET="gnxftyfpcagTyB1hgffGis2zHgkUiQZN3Fo46Tj9vMchBBupgAXhM8pamd2Aw9Qd"
HUME_API_KEY="<YOUR API KEY>"
HUME_SECRET_KEY="<YOUR SECRET KEY>"
```

Example terminal commands to set environment variables manually:

```bash
export HUME_API_KEY="autj04acqK3jpfERQJpkg7829AATGUEvlAR7SYmmOB5ZZVbZD"
export HUME_CLIENT_SECRET="gnxftyfpcagTyB1hgffGis2zHgkUiQZN3Fo46Tj9vMchBBupgAXhM8pamd2Aw9Qd"
export HUME_API_KEY="<YOUR API KEY>"
export HUME_SECRET_KEY="<YOUR SECRET KEY>"
```

## Usage
Expand All @@ -64,5 +65,3 @@ export HUME_CLIENT_SECRET="gnxftyfpcagTyB1hgffGis2zHgkUiQZN3Fo46Tj9vMchBBupgAXhM
cd src
python main.py
```


12 changes: 6 additions & 6 deletions evi-python-api-example/src/authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ class Authenticator:

Attributes:
api_key (str): The API key provided by Hume AI.
client_secret (str): The client secret provided by Hume AI.
secret_key (str): The secret key provided by Hume AI.
host (str): The host URL of the API (default is "test-api.hume.ai").
"""

def __init__(self, api_key: str, client_secret: str, host: str = "test-api.hume.ai"):
def __init__(self, api_key: str, secret_key: str, host: str = "test-api.hume.ai"):
"""
Initialize the Authenticator with the provided API key, client secret, and host.
Initialize the Authenticator with the provided API key, Secret key, and host.

Args:
api_key (str): The API key provided by Hume AI.
client_secret (str): The client secret provided by Hume AI.
secret_key (str): The Secret key provided by Hume AI.
host (str, optional): The host URL of the API. Defaults to "test-api.hume.ai".
"""
self.api_key = api_key
self.client_secret = client_secret
self.secret_key = secret_key
self.host = host

def fetch_access_token(self) -> str:
Expand All @@ -42,7 +42,7 @@ def fetch_access_token(self) -> str:
ValueError: If the access token is not found in the response.
"""
# Prepare the authorization string
auth_string = f"{self.api_key}:{self.client_secret}"
auth_string = f"{self.api_key}:{self.secret_key}"
encoded = base64.b64encode(auth_string.encode()).decode()

# Set up the headers
Expand Down
16 changes: 8 additions & 8 deletions evi-python-api-example/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,23 @@ def get_access_token() -> str:
str: The access token.

Raises:
SystemExit: If API key or client secret are not set.
SystemExit: If API key or Secret key are not set.
"""
load_dotenv()

# Attempt to retrieve API key and client secret from environment variables
# Attempt to retrieve API key and Secret key from environment variables
HUME_API_KEY = os.getenv("HUME_API_KEY")
HUME_CLIENT_SECRET = os.getenv("HUME_CLIENT_SECRET")
HUME_SECRET_KEY = os.getenv("HUME_SECRET_KEY")

# Ensure API key and client secret are set
if HUME_API_KEY is None or HUME_CLIENT_SECRET is None:
# Ensure API key and Secret key are set
if HUME_API_KEY is None or HUME_SECRET_KEY is None:
print(
"Error: HUME_API_KEY and HUME_CLIENT_SECRET must be set either in a .env file or as environment variables."
"Error: HUME_API_KEY and HUME_SECRET_KEY must be set either in a .env file or as environment variables."
)
exit()

# Create an instance of Authenticator with the API key and client secret
authenticator = Authenticator(HUME_API_KEY, HUME_CLIENT_SECRET)
# Create an instance of Authenticator with the API key and Secret key
authenticator = Authenticator(HUME_API_KEY, HUME_SECRET_KEY)

# Fetch the access token
access_token = authenticator.fetch_access_token()
Expand Down
2 changes: 1 addition & 1 deletion evi-typescript-example/.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VITE_HUME_API_KEY="YOUR_API_KEY"
VITE_HUME_CLIENT_SECRET="YOUR_CLIENT_SECRET"
VITE_HUME_SECRET_KEY="YOUR_SECRET_KEY"
5 changes: 3 additions & 2 deletions evi-typescript-example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,19 @@ This command will show the version of `pnpm` that is installed, like `8.10.0`.

If you haven't installed these tools yet, running these commands will result in a message indicating that the command was not found. In that case, you would need to install them first. Node.js can be installed from its official website or via a package manager like Homebrew, and `pnpm` can be installed via npm (which comes with Node.js) by running `npm install -g pnpm` in the terminal.

Next you'll need to set your environment variables necessary for authentication. You'll need your API key and client secret which are accessible from the portal. See our documentation on [getting your api keys](https://hume.docs.buildwithfern.com/docs/introduction/getting-your-api-key).
Next you'll need to set your environment variables necessary for authentication. You'll need your API key and Secret key which are accessible from the portal. See our documentation on [getting your api keys](https://hume.docs.buildwithfern.com/docs/introduction/getting-your-api-key).

After obtaining your API keys, you need to set them as environment variables. A quick way to do this is to run the following commands, however the variables will be lost when the terminal window is closed or the computer is rebooted.

Note the `VITE` prefix to the environment variables. This prefix is required for vite to expose the environment variable to the client. For more information, see the [vite documentation](https://vitejs.dev/guide/env-and-mode) on environment variables and modes.

```sh
export VITE_HUME_API_KEY=<YOUR_API_KEY>
export VITE_HUME_CLIENT_SECRET=<YOUR_CLIENT_SECRET>
export VITE_HUME_SECRET_KEY=<YOUR_SECRET_KEY>
```

You can make these environment variables persistent by adding them to a file named `.env` in the root folder of the repo.

> There is an example file called [`.env.example`](https://github.com/HumeAI/hume-api-examples/blob/main/evi-typescript-example/.env.example) with placeholder values, which you can simply rename to `.env`.

## Serve project
Expand Down
2 changes: 1 addition & 1 deletion evi-typescript-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"preview": "vite preview"
},
"dependencies": {
"hume": "^0.6.2"
"hume": "^0.7.0"
},
"devDependencies": {
"typescript": "^5.2.2",
Expand Down
8 changes: 4 additions & 4 deletions evi-typescript-example/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions evi-typescript-example/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ import {
if (!client) {
client = new HumeClient({
apiKey: import.meta.env.VITE_HUME_API_KEY || '',
clientSecret: import.meta.env.VITE_HUME_CLIENT_SECRET || '',
secretKey: import.meta.env.VITE_HUME_SECRET_KEY || '',
});
}

Expand Down Expand Up @@ -114,7 +114,7 @@ import {
connected = false;

// reset chatGroupId so a new conversation is started when reconnecting
chatGroupId = undefined;
chatGroupId = undefined;

// closed the Web Socket connection
socket?.close();
Expand Down
8 changes: 4 additions & 4 deletions meld/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Description

This example project showcases the use of Hume AI's Empathic Voice Interface (EVI) to boost brainstorming sessions through a React-based application.
This example project showcases the use of Hume AI's Empathic Voice Interface (EVI) to boost brainstorming sessions through a React-based application.

Utilizing a unique system prompt, EVI can adopt three distinct personas, providing diverse insights tailored to your topics. With our [System Prompt](https://github.com/HumeAI/meld/blob/main/src/system_prompt.txt) we define three distinct personas EVI will take to provide insights our topic.

Expand All @@ -23,11 +23,11 @@ This project leverages [Hume's React SDK](https://github.com/HumeAI/empathic-voi

### Configuring Environment Variables

Start by setting up your environment variables. Create a .env file and add your [API Key and your Client Secret](https://beta.hume.ai/settings/keys):
Start by setting up your environment variables. Create a .env file and add your [API Key and your Secret Key](https://beta.hume.ai/settings/keys):

```bash
echo "VITE_HUME_API_KEY= <YOUR HUME API KEY>" >> .env
echo "VITE_HUME_CLIENT_SECRET = <YOUR HUME CLIENT SECRET>" >> .env
echo "VITE_HUME_SECRET_KEY = <YOUR HUME SECRET KEY>" >> .env
```

### Installing Dependencies
Expand Down Expand Up @@ -58,4 +58,4 @@ Visit [http://localhost:5173/](http://localhost:5173/) in your browser to intera

## License

This project is licensed under the [MIT License](LICENSE).
This project is licensed under the [MIT License](LICENSE).
4 changes: 2 additions & 2 deletions meld/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"preview": "vite preview"
},
"dependencies": {
"@humeai/voice": "^0.1.6",
"@humeai/voice-react": "^0.1.6",
"@humeai/voice": "^0.1.7",
"@humeai/voice-react": "^0.1.7",
"@react-spring/web": "^9.7.3",
"axios": "^1.6.8",
"clsx": "^2.1.0",
Expand Down
Loading