Skip to content

Commit

Permalink
Merge pull request #2766 from rockwotj/vertex
Browse files Browse the repository at this point in the history
gcp: add a vertex AI processor
  • Loading branch information
rockwotj authored Aug 21, 2024
2 parents 6c98dc4 + 6376851 commit 4b7906b
Show file tree
Hide file tree
Showing 4 changed files with 554 additions and 0 deletions.
224 changes: 224 additions & 0 deletions docs/modules/components/pages/processors/gcp_vertex_ai_chat.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
= gcp_vertex_ai_chat
:type: processor
:status: experimental
:categories: ["AI"]



////
THIS FILE IS AUTOGENERATED!

To make changes, edit the corresponding source file under:

https://github.com/redpanda-data/connect/tree/main/internal/impl/<provider>.

And:

https://github.com/redpanda-data/connect/tree/main/cmd/tools/docs_gen/templates/plugin.adoc.tmpl
////
// © 2024 Redpanda Data Inc.
component_type_dropdown::[]
Generates responses to messages in a chat conversation, using the Vertex AI API.
Introduced in version 4.34.0.
[tabs]
======
Common::
+
--
```yml
# Common config fields, showing default values
label: ""
gcp_vertex_ai_chat:
project: "" # No default (required)
credentials_json: "" # No default (optional)
location: us-central1 # No default (optional)
model: gemini-1.5-pro-001 # No default (required)
prompt: "" # No default (optional)
temperature: 0 # No default (optional)
max_tokens: 0 # No default (optional)
response_format: text
```
--
Advanced::
+
--
```yml
# All config fields, showing default values
label: ""
gcp_vertex_ai_chat:
project: "" # No default (required)
credentials_json: "" # No default (optional)
location: us-central1 # No default (optional)
model: gemini-1.5-pro-001 # No default (required)
prompt: "" # No default (optional)
system_prompt: "" # No default (optional)
temperature: 0 # No default (optional)
max_tokens: 0 # No default (optional)
response_format: text
top_p: 0 # No default (optional)
top_k: 0 # No default (optional)
stop: [] # No default (optional)
presence_penalty: 0 # No default (optional)
frequency_penalty: 0 # No default (optional)
```
--
======
This processor sends prompts to your chosen large language model (LLM) and generates text from the responses, using the Vertex AI API.
For more information, see the https://cloud.google.com/vertex-ai/docs[Vertex AI documentation^].
== Fields
=== `project`
GCP project ID to use
*Type*: `string`
=== `credentials_json`
An optional field to set google Service Account Credentials json.
[CAUTION]
====
This field contains sensitive information that usually shouldn't be added to a config directly, read our xref:configuration:secrets.adoc[secrets page for more info].
====
*Type*: `string`
=== `location`
The location of the model if using a fined tune model. For base models this can be omitted
*Type*: `string`
```yml
# Examples
location: us-central1
```
=== `model`
The name of the LLM to use. For a full list of models, see the https://console.cloud.google.com/vertex-ai/model-garden[Vertex AI Model Garden].
*Type*: `string`
```yml
# Examples
model: gemini-1.5-pro-001
model: gemini-1.5-flash-001
```
=== `prompt`
The prompt you want to generate a response for. By default, the processor submits the entire payload as a string.
This field supports xref:configuration:interpolation.adoc#bloblang-queries[interpolation functions].
*Type*: `string`
=== `system_prompt`
The system prompt to submit to the Vertex AI LLM.
This field supports xref:configuration:interpolation.adoc#bloblang-queries[interpolation functions].
*Type*: `string`
=== `temperature`
Controls the randomness of predications.
*Type*: `float`
=== `max_tokens`
The maximum number of output tokens to generate per message.
*Type*: `int`
=== `response_format`
The response format of generated type, the model must also be prompted to output the appropriate response type.
*Type*: `string`
*Default*: `"text"`
Options:
`text`
, `json`
.
=== `top_p`
If specified, nucleus sampling will be used.
*Type*: `float`
=== `top_k`
If specified top-k sampling will be used.
*Type*: `int`
=== `stop`
Stop sequences to when the model will stop generating further tokens.
*Type*: `array`
=== `presence_penalty`
Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.
*Type*: `float`
=== `frequency_penalty`
Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.
*Type*: `float`
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
cloud.google.com/go/bigquery v1.62.0
cloud.google.com/go/pubsub v1.40.0
cloud.google.com/go/storage v1.42.0
cloud.google.com/go/vertexai v0.12.0
github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai v0.6.0
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0
Expand Down Expand Up @@ -135,6 +136,8 @@ require (
)

require (
cloud.google.com/go/aiplatform v1.68.0 // indirect
cloud.google.com/go/longrunning v0.5.9 // indirect
github.com/hamba/avro/v2 v2.22.2-0.20240625062549-66aad10411d9 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO
cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M=
cloud.google.com/go v0.115.0 h1:CnFSK6Xo3lDYRoBKEcAtia6VSC837/ZkJuRduSFnr14=
cloud.google.com/go v0.115.0/go.mod h1:8jIM5vVgoAEoiVxQ/O4BFTfHqulPZgs/ufEzMcFMdWU=
cloud.google.com/go/aiplatform v1.68.0 h1:EPPqgHDJpBZKRvv+OsB3cr0jYz3EL2pZ+802rBPcG8U=
cloud.google.com/go/aiplatform v1.68.0/go.mod h1:105MFA3svHjC3Oazl7yjXAmIR89LKhRAeNdnDKJczME=
cloud.google.com/go/auth v0.7.0 h1:kf/x9B3WTbBUHkC+1VS8wwwli9TzhSt0vSTVBmMR8Ts=
cloud.google.com/go/auth v0.7.0/go.mod h1:D+WqdrpcjmiCgWrXmLLxOVq1GACoE36chW6KXoEvuIw=
cloud.google.com/go/auth/oauth2adapt v0.2.3 h1:MlxF+Pd3OmSudg/b1yZ5lJwoXCEaeedAguodky1PcKI=
Expand Down Expand Up @@ -47,6 +49,8 @@ cloud.google.com/go/storage v1.42.0 h1:4QtGpplCVt1wz6g5o1ifXd656P5z+yNgzdw1tVfp0
cloud.google.com/go/storage v1.42.0/go.mod h1:HjMXRFq65pGKFn6hxj6x3HCyR41uSB72Z0SO/Vn6JFQ=
cloud.google.com/go/trace v1.10.10 h1:eiIFoRp1qTh2tRemTd8HIE7qZ0Ok5l7dl9pYsNWoXjk=
cloud.google.com/go/trace v1.10.10/go.mod h1:5b1BiSYQO27KgGRevNFfoIQ8czwpVgnkKbTLb4wV+XM=
cloud.google.com/go/vertexai v0.12.0 h1:zTadEo/CtsoyRXNx3uGCncoWAP1H2HakGqwznt+iMo8=
cloud.google.com/go/vertexai v0.12.0/go.mod h1:8u+d0TsvBfAAd2x5R6GMgbYhsLgo3J7lmP4bR8g2ig8=
cuelabs.dev/go/oci/ociregistry v0.0.0-20240404174027-a39bec0462d2 h1:BnG6pr9TTr6CYlrJznYUDj6V7xldD1W+1iXPum0wT/w=
cuelabs.dev/go/oci/ociregistry v0.0.0-20240404174027-a39bec0462d2/go.mod h1:pK23AUVXuNzzTpfMCA06sxZGeVQ/75FdVtW249de9Uo=
cuelang.org/go v0.9.2 h1:pfNiry2PdRBr02G/aKm5k2vhzmqbAOoaB4WurmEbWvs=
Expand Down
Loading

0 comments on commit 4b7906b

Please sign in to comment.