-
Notifications
You must be signed in to change notification settings - Fork 115
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
Update flow-sample1 and README #1229
Open
Gustolandia
wants to merge
1
commit into
next
Choose a base branch
from
samplebranch-1
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"url": "http://localhost:4000", | ||
"timestamp": "2024-11-08T15:36:13.186Z" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,212 @@ | ||
# Flow Sample 1 | ||
|
||
A basic example project showcasing various Genkit flows. | ||
|
||
## Project Setup | ||
|
||
### Installation | ||
|
||
Ensure you have `pnpm` installed and run the following: | ||
|
||
```bash | ||
pnpm install | ||
``` | ||
|
||
### Build and Run | ||
|
||
To build and run the project, use: | ||
|
||
```bash | ||
pnpm build-and-run | ||
``` | ||
|
||
This compiles the TypeScript source code and runs the `index.js` file in the `lib` directory. | ||
|
||
--- | ||
|
||
## Available Flows | ||
|
||
### Basic Flow | ||
|
||
A simple flow that demonstrates the use of `run`. | ||
|
||
#### Command: | ||
|
||
```bash | ||
genkit flow:run basic '"test input"' | ||
``` | ||
|
||
#### Expected Output: | ||
|
||
```text | ||
"foo: subject: test input" | ||
``` | ||
|
||
--- | ||
|
||
### Parent Flow | ||
|
||
A flow that runs the `basic` flow and returns its output as a JSON string. | ||
|
||
#### Command: | ||
|
||
```bash | ||
genkit flow:run parent | ||
``` | ||
|
||
#### Expected Output: | ||
|
||
```text | ||
"\"foo: subject: foo\"" | ||
``` | ||
|
||
--- | ||
|
||
### Streamy Flow | ||
|
||
A streaming flow that emits incremental data based on the input number. | ||
|
||
#### Command: | ||
|
||
```bash | ||
genkit flow:run streamy 5 | ||
``` | ||
|
||
#### Expected Output: | ||
|
||
```text | ||
done: 5, streamed: 5 times | ||
``` | ||
|
||
The streamed content will also show intermediate outputs for each count. | ||
|
||
--- | ||
|
||
### StreamyThrowy Flow | ||
|
||
Similar to `streamy`, but throws an error when the count reaches 3. | ||
|
||
#### Command: | ||
|
||
```bash | ||
genkit flow:run streamyThrowy 5 | ||
``` | ||
|
||
#### Expected Output: | ||
|
||
Throws an error at count 3. | ||
|
||
--- | ||
|
||
### Throwy Flow | ||
|
||
Demonstrates error handling by throwing an error when a subject is provided. | ||
|
||
#### Command: | ||
|
||
```bash | ||
genkit flow:run throwy '"test input"' | ||
``` | ||
|
||
#### Expected Output: | ||
|
||
Throws an error with the message: | ||
|
||
```text | ||
test input | ||
``` | ||
|
||
--- | ||
|
||
### Throwy2 Flow | ||
|
||
Throws an error within the `run` function based on input. | ||
|
||
#### Command: | ||
|
||
```bash | ||
genkit flow:run throwy2 '"test input"' | ||
``` | ||
|
||
#### Expected Output: | ||
|
||
Throws an error with the message: | ||
|
||
```text | ||
test input | ||
``` | ||
|
||
--- | ||
|
||
### FlowMultiStepCaughtError | ||
|
||
A multi-step flow that catches errors and continues execution. | ||
|
||
#### Command: | ||
|
||
```bash | ||
genkit flow:run flowMultiStepCaughtError '"input data"' | ||
``` | ||
|
||
#### Expected Output: | ||
|
||
```text | ||
"input data, Step 1, , Step 3" | ||
``` | ||
|
||
A string indicating that Step 2 had an error, but the process continued. | ||
|
||
--- | ||
|
||
### MultiSteps Flow | ||
|
||
A flow demonstrating chaining multiple steps. | ||
|
||
#### Command: | ||
|
||
```bash | ||
genkit flow:run multiSteps '"sample input"' | ||
``` | ||
|
||
#### Expected Output: | ||
|
||
```text | ||
42 | ||
``` | ||
|
||
--- | ||
|
||
### LargeSteps Flow | ||
|
||
Processes large chunks of data across multiple steps. | ||
|
||
#### Command: | ||
|
||
```bash | ||
genkit flow:run largeSteps | ||
``` | ||
|
||
#### Expected Output: | ||
|
||
```text | ||
"Finished processing large data." | ||
``` | ||
|
||
--- | ||
|
||
## Running the Developer UI | ||
|
||
To visualize flows in the Developer UI, start the server: | ||
|
||
```bash | ||
genkit start | ||
``` | ||
|
||
Open your browser and navigate to `http://localhost:4000`. | ||
|
||
--- | ||
|
||
## Notes | ||
|
||
- This project requires `Node.js` version 20 or later. | ||
- All flows are designed for demonstration and testing purposes. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
should should not be checked in...