-
Notifications
You must be signed in to change notification settings - Fork 135
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
[Go] move most of genkit package into core #244
Conversation
This PR greatly simplifies the genkit package, limiting it to the symbols that Genkit app developers, as exemplified by the programs in the "samples" directory, would need. To accomplish this, it moves most of the code to a new package, named core. The core package, rather than the genkit package, is now imported by the ai package and plugins. End-user applications should not normally require it. This overlapped with #229, so unfortunately those (minor) changes are incorporated here as well, in a slightly different form.
Here is the output of package genkit // import "github.com/firebase/genkit/go/genkit" Package genkit provides Genkit functionality for application developers. FUNCTIONS func DefineFlow[I, O, S any](name string, fn core.Func[I, O, S]) *core.Flow[I, O, S] func NewFlowServeMux() *http.ServeMux
func Run[T any](ctx context.Context, name string, f func() (T, error)) (T, error)
func RunFlow[I, O, S any](ctx context.Context, flow *core.Flow[I, O, S], input I) (O, error) func StartFlowServer(addr string) error
func StreamFlow[I, O, S any](ctx context.Context, flow *core.Flow[I, O, S], input I) func(func(*StreamFlowValue[O, S], error) bool)
TYPES type NoStream = core.NoStream type StreamFlowValue[O, S any] struct { |
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// Package core implements Genkit actions, flows and other essential machinery. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also add something like "This package is primarily intended for genkit internals and for plugins. Applications using genkit should use the genkit package."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
go/genkit/genkit.go
Outdated
) | ||
|
||
// DefineFlow creates a Flow that runs fn, and registers it as an action. | ||
func DefineFlow[I, O, S any](name string, fn core.Func[I, O, S]) *core.Flow[I, O, S] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should define the type of fn
in this package as an alias to func(...)
, so that people looking at the godoc will more clearly understand what to pass. We can make core.Func
also a type alias and just duplicate the definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I inlined core.Func
at that point. Bit of a mouthful, but I agree it's ultimately clearer.
I can't make core.Func
a type alias because it has generic parameters, but it worked to insert a cast.
This PR greatly simplifies the genkit package, limiting it to
the symbols that Genkit app developers, as exemplified by
the programs in the "samples" directory, would need.
To accomplish this, it moves most of the code to a new package, named
core. The core package, rather than the genkit package, is now imported
by the ai package and plugins. End-user applications should not normally
require it.
This overlapped with #229, so unfortunately those (minor) changes
are incorporated here as well, in a slightly different form.