diff --git a/genai/client.go b/genai/client.go index 82c0efa..607d49f 100644 --- a/genai/client.go +++ b/genai/client.go @@ -12,23 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -// For the following go:generate line to work, do the following: -// Install the protoveener tool: +// For the following go:generate line to work, install the protoveener tool: // git clone https://github.com/googleapis/google-cloud-go // cd google-cloud-go // go install ./internal/protoveneer/cmd/protoveneer // -// Set the environment variable GOOGLE_CLOUD_GO to the path to the above repo on your machine. -// For example: -// export GOOGLE_CLOUD_GO=$HOME/repos/google-cloud-go -// -// Ensure that the working directory of that repo is at the version of cloud.google.com/go/ai in -// this repo's go.mod file. For example, if the go.mod contains -// cloud.google.com/go/ai v0.6.0 -// then from the root of the google-cloud-go repo, run -// git switch -d ai/v0.6.0 - -//go:generate protoveneer -license license.txt config.yaml $GOOGLE_CLOUD_GO/ai/generativelanguage/apiv1beta/generativelanguagepb +//go:generate ./generate.sh package genai diff --git a/genai/generate.sh b/genai/generate.sh new file mode 100755 index 0000000..7be31e0 --- /dev/null +++ b/genai/generate.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +version=$(awk '$1 == "cloud.google.com/go/ai" {print $2}' ../go.mod) + +if [[ $version = '' ]]; then + echo >&2 "could not get version of cloud.google.com/go/ai from ../go.mod" + exit 1 +fi + +dir=~/go/pkg/mod/cloud.google.com/go/ai@$version/generativelanguage/apiv1beta/generativelanguagepb + +if [[ ! -d $dir ]]; then + echo >&2 "$dir does not exist or is not a directory" + exit 1 +fi + +echo "generating from $dir" +protoveneer -license license.txt config.yaml $dir +