You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: solana-openai/nodejs/README.md
+11-9Lines changed: 11 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,22 +7,24 @@ This code example demonstrates how an OpenAI API key can be used to generate a r
7
7
-**An Ethereum private key**
8
8
- This private key will be used to:
9
9
- Own the PKP we mint. The minted PKP will be used to create new Wrapped Keys.
10
-
- In order to pay for this, the corresponding Ethereum account must have Lit Test Tokens. If you do not have any, you can get some from [the faucet](https://chronicle-yellowstone-faucet.getlit.dev/)
10
+
- In order to pay for this, the corresponding Ethereum account must have Lit Test Tokens. If you do not have any, you can get some from [the faucet](https://chronicle-yellowstone-faucet.getlit.dev/).
11
11
-**An OpenAI API key**
12
12
- We will use this to make a request to OpenAI with our query to generate a response.
13
-
- This example currently uses the GPT-4o-mini model, please enable this model on your API key or change it in the code if needed
13
+
- This example currently uses the GPT-4o-mini model, please enable this model on your API key or change it in the code if needed.
14
14
-**Node.js and Yarn**
15
-
- Please have these installed before running the example
15
+
- Please have these installed before running the example.
16
16
17
17
## Installation and Setup
18
18
19
19
1. Clone the repository
20
20
2.`cd` into the code example directory: `cd solana-openai/nodejs`
21
21
3. Install the dependencies: `yarn`
22
22
4. Create and fill in the `.env` file: `cp .env.example .env`
23
-
-`ETHEREUM_PRIVATE_KEY`: **Required** This is the Ethereum private key that will be used to mint a PKP if one is not provided
24
-
-`OPENAI_API_KEY`: **Required** This is the OpenAI API key that will be used to make a request within our Lit Action
25
-
-`LIT_PKP_PUBLIC_KEY`: **Optional** You can also provide your own PKP for this example, but please make sure the PKP is owned by the provided Ethereum wallet
23
+
-**Required**:
24
+
-`ETHEREUM_PRIVATE_KEY`: This is the Ethereum private key that will be used to mint a PKP if one is not provided
25
+
-`OPENAI_API_KEY`: This is the OpenAI API key that will be used to make a request within our Lit Action
26
+
-**Optional**:
27
+
-`LIT_PKP_PUBLIC_KEY`: You can also provide your own PKP for this example, but please make sure the PKP is owned by the provided Ethereum wallet
26
28
5. Test the example: `yarn test`
27
29
28
30
## Executing the Example
@@ -34,12 +36,12 @@ Here's an overview of how the code example works:
34
36
1. Using an imported Ethereum private key, connect the wallet to the Lit RPC endpoint `Chronicle Yellowstone`
35
37
2. Connect to the Lit network using the `LitNodeClient` on the `datil-dev` network
36
38
3. Connect the `LitContracts` client to the Lit network (`datil-dev` in this case)
37
-
4.**If PKP idnot provided in the .env file**: Mint a new PKP.
39
+
4.**If a PKP is not provided in the .env file**: Mint a new PKP.
38
40
5. Use your Ethereum wallet to create an AuthMethod.
39
41
6. Use the created AuthMethod for authentication in generating session signatures for our PKP.
40
42
7. Generate a new Solana Wrapped Key.
41
-
8. Retrieve the encrypted metadata of our Wrapped Key.
42
-
9. Set up Access Control Conditions (ACCs) to encrypt our OpenAI API key. This ensures it is not revealed at any point. The ACCs are the same ones used to encrypt the Wrapped Key metadata.
43
+
8. Retrieve the encrypted private key of our Wrapped Key.
44
+
9. Set up Access Control Conditions (ACCs) to encrypt our OpenAI API key. This ensures it is not revealed at any point. The ACCs are the same ones that were used to encrypt the Wrapped Key.
43
45
10. Write a simple prompt for the AI to answer.
44
46
11. Run the Lit Action, providing our encrypted Solana Wrapped Key and OpenAI API key metadata, as well as our prompt.
0 commit comments