Skip to content

Commit

Permalink
Merge branch 'main' into haguirre/changeStreamFlowSSE
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoaguirre authored Dec 11, 2024
2 parents 5d1846c + 009239b commit c768dd3
Show file tree
Hide file tree
Showing 314 changed files with 12,227 additions and 5,126 deletions.
9 changes: 6 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Description here...
Description here... Help the reviewer by:
- linking to an issue that includes more details
- if it's a new feature include samples of how to use the new feature
- (optional if issue link is provided) if you fixed a bug include basic bug details

Checklist (if applicable):
- [ ] PR title is following https://www.conventionalcommits.org/en/v1.0.0/
- [ ] Tested (manually, unit tested, etc.)
- [ ] Changelog updated
- [ ] Docs updated
- [ ] Docs updated (updated docs or a docs bug required)
11 changes: 11 additions & 0 deletions .github/workflows/bump-js-plugins-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,14 @@ jobs:
preid: ${{ inputs.preid }}
commit-message: 'chore: bump @genkit-ai/checks version to {{version}}'
tag-prefix: '@genkit-ai/checks@'
- name: 'js/plugins/mcp version bump'
uses: 'phips28/gh-action-bump-version@master'
env:
GITHUB_TOKEN: ${{ secrets.GENKIT_RELEASER_GITHUB_TOKEN }}
PACKAGEJSON_DIR: js/plugins/mcp
with:
default: ${{ inputs.releaseType }}
version-type: ${{ inputs.releaseType }}
preid: ${{ inputs.preid }}
commit-message: 'chore: bump genkitx-mcp version to {{version}}'
tag-prefix: 'genkitx-mcp@'
71 changes: 71 additions & 0 deletions .github/workflows/bump-package-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# 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.

name: Bump Version for a package

on:
workflow_dispatch:
inputs:
packageDir:
description: Package dir (ex. js/foo)
type: string
required: true
packageName:
description: Package name (ex. @genkit-ai/foo)
type: string
required: true
releaseType:
description: Release type
type: choice
default: patch
required: true
options:
- patch
- minor
- major
- prerelease
- premajor
- preminor
- prepatch
preid:
description: Prerelease identifier
type: string
default: rc
required: true

jobs:
build:
name: Version bump
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GENKIT_RELEASER_GITHUB_TOKEN }}
- uses: pnpm/action-setup@v3
- name: Set up node v20
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'pnpm'
- name: 'version bump'
uses: 'phips28/gh-action-bump-version@master'
env:
GITHUB_TOKEN: ${{ secrets.GENKIT_RELEASER_GITHUB_TOKEN }}
PACKAGEJSON_DIR: ${{ inputs.packageDir }}
with:
default: ${{ inputs.releaseType }}
version-type: ${{ inputs.releaseType }}
preid: ${{ inputs.preid }}
commit-message: 'chore: bump ${{ inputs.packageName }} version to {{version}}'
tag-prefix: '${{ inputs.packageName }}@'
49 changes: 49 additions & 0 deletions .github/workflows/release_js_main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 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.

name: Release Genkit JS (latest)

on:
workflow_dispatch:

jobs:
build:
name: Run build tasks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v3
- name: Set up node v21
uses: actions/setup-node@v4
with:
node-version: 21.x
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Run build script
run: pnpm build
- name: Run js tests
run: pnpm test:js
- name: Validate working directory is clean
run: .github/workflows/scripts/ensure-clean-working-tree.sh
- name: Set up node v21
uses: actions/setup-node@v4
with:
node-version: 21.x
cache: 'pnpm'
registry-url: 'https://wombat-dressing-room.appspot.com/'
- name: release script
run: scripts/release_main.sh
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dist
package-lock.json
.angular
*.tgz
.pnpm-store
# version file (autogenerated by CLI)
genkit-tools/cli/src/utils/version.ts

Expand All @@ -29,13 +30,14 @@ firebase-debug.log
# RAG sample files
!js/testapps/rag/package.json
js/testapps/rag/*.json
js/testapps/cat-eval/__db*.json
js/testapps/evals/__db*.json
js/testapps/menu/rag/__db*.json

# Test files
last_recording.mp4

# auto-generated
/js/core/src/__codegen
/js/api-refs-js

!samples/chatbot/server/genkit-ai-vertexai-*.tgz
11 changes: 2 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,7 @@ Here's one that requires no setup:

```
cd js/testapps/flow-sample1
genkit flow:run basic "\"hello\""
```

### Run the Developer UI

```
cd js/testapps/flow-sample1
genkit start
genkit start -- tsx --watch src/index.ts
```

Point your browser to http://localhost:4000
Expand All @@ -109,7 +102,7 @@ To start, let's make sure we have some context to pull from the vector store.

```
cd js/testapps/rag
genkit start
genkit start -- tsx --watch src/index.ts
```

2. Click on the `indexPdf` flow in the left nav.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ Genkit provides a CLI and a local UI to streamline your AI development workflow.

### CLI

The Genkit CLI is the quickest way to start a new Genkit project. It also includes commands for running and evaluating your Genkit functions (flows).
The Genkit CLI includes commands for running and evaluating your Genkit functions (flows) and collecting telemetry and logs.

- **Install:** `npm i -g genkit`
- **Initialize a new project:** `genkit init`
- **Run a command, wrapped with telemetry, a interactive developer UI, etc:** `genkit start -- <command to run your code>`

### Developer UI

Expand Down
2 changes: 1 addition & 1 deletion docs-go/get-started-go.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ To get started with Genkit, install the Genkit CLI and run
1. Install the Genkit CLI by running the following command:
```posix-terminal
npm i -g genkit
npm i -g genkit-cli
```
This command installs the Genkit CLI into your Node installation directory
Expand Down
2 changes: 1 addition & 1 deletion docs/auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ alongside the native flows. You have two options:
}); // Registers the middleware
```

For more information about using Express, see the [Cloud Run](/genkit/express)
For more information about using Express, see the [Cloud Run](/genkit/cloud-run)
instructions.

Please note, if you go with (1), you the `middleware` configuration option will
Expand Down
2 changes: 1 addition & 1 deletion docs/chat.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const changeUserName = ai.defineTool(
await ai.currentSession<MyState>().updateState({
userName: input.newUserName,
});
return 'changed username to ${input.newUserName}';
return `changed username to ${input.newUserName}`;
}
);
```
Expand Down
2 changes: 1 addition & 1 deletion docs/cloud-run.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ chose:
The only secret you need to set up for this tutorial is for the model provider,
but in general, you must do something similar for each service your flow uses.

## 4. Deploy flows to Cloud Run
## 3. Deploy flows to Cloud Run

After you've prepared your project for deployment, you can deploy it using the
`gcloud` tool.
Expand Down
47 changes: 39 additions & 8 deletions docs/evaluation.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const ai = genkit({
```

**Note:** The configuration above requires installing the `genkit`,
`@genkit-ai/google-ai`, `@genkit-ai/evaluator` and `@genkit-ai/vertexai`
`@genkit-ai/googleai`, `@genkit-ai/evaluator` and `@genkit-ai/vertexai`
packages.

```posix-terminal
Expand All @@ -49,13 +49,39 @@ use to generate output for evaluation.
["Cheese", "Broccoli", "Spinach and Kale"]
```

If the evaluator requires a reference output for evaluating a flow, you can pass both
input and reference output using this format instead:

```json
{
"samples": [
{
"input": "What is the French word for Cheese?",
"reference": "Fromage"
},
{
"input": "What green vegetable looks like cauliflower?",
"reference": "Broccoli"
}
]
}
```

Note that you can use any JSON data type in the input JSON file. Genkit will pass them along with the same data type to your flow.

You can then use the `eval:flow` command to evaluate your flow against the test
cases provided in `testInputs.json`.

```posix-terminal
genkit eval:flow menuSuggestionFlow --input testInputs.json
```

If your flow requires auth, you may specify it using the `--auth` argument:

```posix-terminal
genkit eval:flow menuSuggestionFlow --input testInputs.json --auth "{\"email_verified\": true}"
```

You can then see evaluation results in the Developer UI by running:

```posix-terminal
Expand Down Expand Up @@ -87,13 +113,7 @@ you get started:

### Evaluator plugins

Genkit supports additional evaluators through plugins:

* VertexAI Rapid Evaluators via the [VertexAI
Plugin](http://plugins/vertex-ai#evaluation).
* [LangChain Criteria
Evaluation](https://python.langchain.com/docs/guides/productionization/evaluation/string/criteria_eval_chain/)
via the [LangChain plugin](http://plugins/langchain.md).
Genkit supports additional evaluators through plugins like the VertexAI Rapid Evaluators via the [VertexAI Plugin](./plugins/vertex-ai#evaluators).

## Advanced use

Expand Down Expand Up @@ -228,9 +248,18 @@ might be asking about it.
import { genkit, run, z } from "genkit";
import { googleAI, gemini15Flash } from "@genkit-ai/googleai";
import { chunk } from "llm-chunk";
import path from 'path';

const ai = genkit({ plugins: [googleAI()] });

const chunkingConfig = {
minLength: 1000, // number of minimum characters into chunk
maxLength: 2000, // number of maximum characters into chunk
splitter: 'sentence', // paragraph | sentence
overlap: 100, // number of overlap chracters
delimiters: '', // regex for base split method
} as any;

export const synthesizeQuestions = ai.defineFlow(
{
name: "synthesizeQuestions",
Expand All @@ -239,6 +268,8 @@ export const synthesizeQuestions = ai.defineFlow(
},
async (filePath) => {
filePath = path.resolve(filePath);
// `extractText` loads the PDF and extracts its contents as text.
// See our RAG documentation for more details.
const pdfTxt = await run("extract-text", () => extractText(filePath));

const chunks = await run("chunk-it", async () =>
Expand Down
21 changes: 12 additions & 9 deletions docs/firebase.md
Original file line number Diff line number Diff line change
Expand Up @@ -400,30 +400,33 @@ cd $PROJECT_ROOT/functions
npx genkit start -- npx tsx --watch src/index.ts
```

or

```posix-terminal
cd $PROJECT_ROOT/functions
npm run genkit:start
```

You can now navigate to the URL printed by the `genkit start` command to access.

## Optional: Developing using Firebase Local Emulator Suite

Firebase offers a
[suite of emulators for local development](/docs/emulator-suite), which you can
use with Genkit.

To use Genkit with the Firebase Emulator Suite, start the Firebase emulators
To use the Genkit Dev UI with the Firebase Emulator Suite, start the Firebase emulators
like this:

```posix-terminal
GENKIT_ENV=dev firebase emulators:start --inspect-functions
npx genkit start -- firebase emulators:start --inspect-functions
```

This will run your code in the emulator and run the Genkit framework in
development mode, which launches and exposes the Genkit reflection API (but not
the Dev UI).

Then, launch the Genkit Dev UI with the `--attach` option to connect it to your
code running inside the Firebase Emulator:

```posix-terminal
npx genkit start --attach http://localhost:3100 --port 4001
```

To see traces from Firestore in the Dev UI you can navigate to the Inspect tab
and toggle the "Dev/Prod" switch. When toggled to "prod" it will be loading
traces from firestore.
5 changes: 2 additions & 3 deletions docs/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,5 @@ with additional Genkit capabilities, see the following guides:
* [Creating flows](/docs/genkit/flows): Learn how to use special Genkit
functions, called flows, that provide end-to-end observability for workflows
and rich debugging from Genkit tooling.
* [Prompting models](/docs/genkit/prompts): Learn how Genkit lets you treat
prompt templates as functions, encapsulating model configurations and
input/output schema.
* [Managing prompts](/docs/genkit/dotprompt): Learn how Genkit helps you manage
your prompts and configuration together as code.
Loading

0 comments on commit c768dd3

Please sign in to comment.