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
After setting up your dependencies, you can build the
27
+
project, itself.
28
+
29
+
### 1. Set up your project {:#setup-project}
30
+
31
+
1. Create a directory structure and a file to hold
32
+
your source code.
18
33
19
34
```shell
20
-
mkdir chat-with-a-pdf
21
-
cd chat-with-a-pdf
35
+
$ mkdir -p chat-with-a-pdf/src && \
36
+
cd chat-with-a-pdf/src && \
37
+
touch index.ts
22
38
```
23
39
24
40
1. Initialize a new TypeScript project.
25
41
26
42
```shell
27
-
npm init -y
43
+
$ npm init -y
28
44
```
29
45
46
+
1. Install the pdf-parse module:
30
47
31
-
## Install Genkit
48
+
```shell
49
+
$ npm i pdf-parse
50
+
```
32
51
33
-
Install the following Genkit dependencies to use Genkit in your project:
52
+
1. Install the following Genkit dependencies to use Genkit in your project:
34
53
35
-
-`genkit` provides Genkit core capabilities.
36
-
-`@genkit-ai/googleai` provides access to the Google AI Gemini models.
54
+
```shell
55
+
$ npm install genkit @genkit-ai/googleai
56
+
```
37
57
38
-
```shell
39
-
npm install genkit @genkit-ai/googleai
40
-
```
58
+
*`genkit` provides Genkit core capabilities.
59
+
*`@genkit-ai/googleai` provides access to the Google AI Gemini models.
41
60
42
-
## Configure your model API key
61
+
5. Get and configure
62
+
your model API key {:#configure-your-model-api-key}
43
63
44
-
For this guide, we’ll show you how to use the Gemini API, which provides a
45
-
generous free-of-charge tier and does not require a credit card to get
46
-
started. To use the Gemini API, you'll need an API key. If you don't
47
-
already have one, create a key in Google AI Studio.
64
+
<ul style="list-style-type:none;">
48
65
49
-
[Get an API key from Google AI Studio](https://makersuite.google.com/app/apikey)
66
+
To use the Gemini API, which this codelab uses, you must first
67
+
configure an API key. If you don't already have one,
68
+
<a href="https://makersuite.google.com/app/apikey" target="_blank">create a
69
+
key</a> in Google AI Studio.
50
70
51
-
After you’ve created an API key, set the `GOOGLE_GENAI_API_KEY` environment
52
-
variable to your key with the following command:
71
+
The Gemini API provides a generous free-of-charge tier and does not require a
72
+
credit card to get started.
53
73
54
-
```shell
55
-
export GOOGLE_GENAI_API_KEY=<your API key>
56
-
```
74
+
After creating your API key, set the <code>GOOGLE_GENAI_API_KEY`</code>
75
+
environment variable to your key with the following command:
76
+
77
+
<pre class="prettyprint lang-shell">
78
+
$ export GOOGLE_GENAI_API_KEY=<your API key>
79
+
</pre>
80
+
81
+
</ul>
82
+
<br>
57
83
58
-
> **Note:**While this tutorial uses the Gemini API from AI Studio, Genkit
84
+
**Note:** Although this tutorial uses the Gemini API from AI Studio, Genkit
59
85
supports a wide variety of model providers, including:
60
-
> *[Gemini from Vertex AI](https://firebase.google.com/docs/genkit/plugins/vertex-ai#generative_ai_models)
61
-
> * Anthropic’s Claude 3 models and Llama 3.1 through the [Vertex AI Model Garden](https://firebase.google.com/docs/genkit/plugins/vertex-ai#anthropic_claude_3_on_vertex_ai_model_garden)
62
-
> * Open source models through [Ollama](https://firebase.google.com/docs/genkit/plugins/ollama)
63
-
> *[Community-supported providers](https://firebase.google.com/docs/genkit/models#models-supported) such as OpenAI and Cohere.
64
86
65
-
## Import and initialise Genkit
87
+
* [Gemini from Vertex AI](https://firebase.google.com/docs/genkit/plugins/vertex-ai#generative_ai_models).
88
+
* Anthropic's Claude 3 models and Llama 3.1 through the
89
+
[Vertex AI Model Garden](https://firebase.google.com/docs/genkit/plugins/vertex-ai#anthropic_claude_3_on_vertex_ai_model_garden),
0 commit comments