From 6baf609b04e26aec762dcfc3343453e7567817ed Mon Sep 17 00:00:00 2001 From: Jonathan Amsterdam Date: Fri, 24 May 2024 15:51:15 -0400 Subject: [PATCH] [Go] make core the home of codegen Move the go:generate lines into core/core.go Make core the default package for codegen. Delete genkit/gen.go; no generated types live there. --- go/core/core.go | 7 +++++++ go/{genkit => core}/schemas.config | 2 -- go/genkit/gen.go | 17 ----------------- go/genkit/genkit.go | 7 ------- 4 files changed, 7 insertions(+), 26 deletions(-) rename go/{genkit => core}/schemas.config (99%) delete mode 100644 go/genkit/gen.go diff --git a/go/core/core.go b/go/core/core.go index 41f086b32..b77300c48 100644 --- a/go/core/core.go +++ b/go/core/core.go @@ -12,6 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +// Run the npm script that generates JSON Schemas from the zod types +// in the *.ts files. It writes the result to genkit-tools/genkit-schema.json +//go:generate npm --prefix ../../genkit-tools run export:schemas + +// Run the Go code generator on the file just created. +//go:generate go run ../internal/cmd/jsonschemagen -outdir .. -config schemas.config ../../genkit-tools/genkit-schema.json core + // Package core implements Genkit actions, flows and other essential machinery. // This package is primarily intended for genkit internals and for plugins. // Applications using genkit should use the genkit package. diff --git a/go/genkit/schemas.config b/go/core/schemas.config similarity index 99% rename from go/genkit/schemas.config rename to go/core/schemas.config index 079233d71..c7c402875 100644 --- a/go/genkit/schemas.config +++ b/go/core/schemas.config @@ -67,12 +67,10 @@ FlowInvokeEnvelopeMessageRunScheduled omit Operation omit FlowStateExecution name flowExecution -FlowStateExecution pkg core FlowStateExecution.startTime type gtime.Milliseconds FlowStateExecution.endTime type gtime.Milliseconds FlowError name flowError -FlowError pkg core GenerateRequest.messages doc Messages is a list of messages to pass to the model. The first n-1 Messages diff --git a/go/genkit/gen.go b/go/genkit/gen.go deleted file mode 100644 index 8686b47fa..000000000 --- a/go/genkit/gen.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2024 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. - -// This file was generated by jsonschemagen. DO NOT EDIT. - -package genkit diff --git a/go/genkit/genkit.go b/go/genkit/genkit.go index dafa91958..e13c8b2e4 100644 --- a/go/genkit/genkit.go +++ b/go/genkit/genkit.go @@ -12,13 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Run the npm script that generates JSON Schemas from the zod types -// in the *.ts files. It writes the result to genkit-tools/genkit-schema.json -//go:generate npm --prefix ../../genkit-tools run export:schemas - -// Run the Go code generator on the file just created. -//go:generate go run ../internal/cmd/jsonschemagen -outdir .. -config schemas.config ../../genkit-tools/genkit-schema.json genkit - // Package genkit provides Genkit functionality for application developers. package genkit