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

Use secret store for rag sample app. #1602

Merged
merged 1 commit into from
Dec 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
18 changes: 17 additions & 1 deletion retrieval-augmented-generation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ have created a tenant at
tenant name, it will be used in the next steps. For more information, see the
Vespa Cloud [getting started](https://cloud.vespa.ai/en/getting-started) guide.

Add your OpenAI API key to the Vespa secret store as described in
[Secret Management](https://cloud.vespa.ai/en/security/secret-store.html#secret-management).
Create a new vault, unless you already have one, and add your OpenAI API key
as a secret.

The `services.xml` file must refer to the newly added secret in the secret store.
Replace `<my-vault-name>` and `<my-secret-name>` below with your own values:
<pre>
&lt;secrets&gt;
&lt;openai-api-key vault="&lt;my-vault-name&gt;" name="&lt;my-secret-name&gt;"/&gt;
&lt;/secrets&gt;
</pre>

Configure the vespa client. Replace `tenant-name` below with your tenant name.
We use the application name `rag-app` here, but you are free to choose your own
application name:
Expand Down Expand Up @@ -171,6 +184,10 @@ $ vespa query \
traceLevel=1
</pre>

On Vespa cloud, just skip the `--header` parameter, as the API key is already
set up in the services.xml file, and will be retrieved from the Vespa secret
store.

Here, we specifically set the search chain to `openai`. This calls the
`RAGSearcher` which is set up to use the `OpenAI` client. Note that this
requires an OpenAI API key, which is sent in the header. We also add a timeout
Expand Down Expand Up @@ -228,4 +245,3 @@ To remove the application from Vespa Cloud:
<pre>
$ vespa destroy
</pre>

10 changes: 9 additions & 1 deletion retrieval-augmented-generation/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@

<document-api/>

<secrets>
<openai-api-key vault="<my-vault-name>" name="<my-secret-name>"/>
</secrets>

<!-- Setup the client to OpenAI -->
<component id="openai" class="ai.vespa.llm.clients.OpenAI" />
<component id="openai" class="ai.vespa.llm.clients.OpenAI">
<config name = "ai.vespa.llm.clients.llm-client">
<apiKeySecretName>openai-api-key</apiKeySecretName>
</config>
</component>

<!-- Setup a local inference on a small Llama 3.2 text model -->
<!-- Comment out this component to avoid downloading the model file during startup -->
Expand Down
Loading