Skip to content

Commit

Permalink
BREAKING CHANGE: major refactor done, bump genkit version to 0.9 (#81)
Browse files Browse the repository at this point in the history
* refactor: major refactor done, bump genkit version to 0.9. Change Pluing API

* feat: update README

* fix: remove CandidateData

* fix: licenses

* fix: license

* fix: index is not needed

* fix: license

* fix: licenses

* fix: use message

* fix: prettier

* fix: license

* fix: license

* fix: bump azure version

* feat: update readme

* chore(deps-dev): bump typescript-eslint from 8.13.0 to 8.14.0 (#83)

Bumps [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint) from 8.13.0 to 8.14.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.14.0/packages/typescript-eslint)

---
updated-dependencies:
- dependency-name: typescript-eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Xavier Portilla Edo <xavi_tb@hotmail.com>

* feat: final version

* fix: fix json output

* chore(deps-dev): bump typescript-eslint from 8.13.0 to 8.14.0 (#84)

Bumps [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint) from 8.13.0 to 8.14.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.14.0/packages/typescript-eslint)

---
updated-dependencies:
- dependency-name: typescript-eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Xavier Portilla Edo <xavi_tb@hotmail.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
xavidop and dependabot[bot] authored Nov 14, 2024
1 parent 585b533 commit 6863b72
Show file tree
Hide file tree
Showing 7 changed files with 368 additions and 181 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/depsreview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/dependency-review-action@v4
- uses: actions/dependency-review-action@v4.3.3
with:
allow-licenses: BSD-2-Clause, BSD-3-Clause, MIT, Apache-2.0, MPL-2.0, ISC, LGPL-3.0, 0BSD
allow-licenses: BSD-2-Clause, MIT, Apache-2.0, MPL-2.0, ISC, LGPL-3.0, 0BSD, BSD-3-Clause, BSD-3-Clause AND BSD-3-Clause-Clear
46 changes: 25 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,37 +33,43 @@ Install the plugin in your project with your favorite package manager:
- `npm install genkitx-github`
- `pnpm add genkitx-github`

### Versions

if you are using Genkit version `<v0.9.0` or lower, please use the plugin version `v1.9.0`. If you are using Genkit `>=v0.9.0`, please use the plugin version `v2.0.0`.

## Usage

### Configuration

To use the plugin, you need to configure it with your GitHub Token key. You can do this by calling the `configureGenkit` function:
To use the plugin, you need to configure it with your GitHub Token key. You can do this by calling the `genkit` function:

```typescript
import { genkit, z } from 'genkit';
import {github, openAIGpt4o} from "genkitx-github";

configureGenkit({
const ai = genkit({
plugins: [
github({
githubToken: '<my-github-token>',
}),
],
logLevel: "debug",
enableTracingAndMetrics: true,
model: openAIGpt4o,
]
});
```

You can also intialize the plugin in this way if you have set the `GITHUB_TOKEN` environment variable:

```typescript
import { genkit, z } from 'genkit';
import {github, openAIGpt4o} from "genkitx-github";

configureGenkit({
const ai = genkit({
plugins: [
github({}),
],
logLevel: "debug",
enableTracingAndMetrics: true,
github({
githubToken: '<my-github-token>',
}),
model: openAIGpt4o,
]
});
```

Expand All @@ -72,35 +78,34 @@ configureGenkit({
The simplest way to call the text generation model is by using the helper function `generate`:

```typescript
import { genkit, z } from 'genkit';
import {github, openAIGpt4o} from "genkitx-github";

// Basic usage of an LLM
const response = await generate({
model: openAIGpt4o, // model imported from genkitx-github
const response = await ai.generate({
prompt: 'Tell me a joke.',
});

console.log(await response.text());
console.log(await response.text);
```

### Within a flow

```typescript
// ...configure Genkit (as shown above)...

export const myFlow = defineFlow(
export const myFlow = ai.defineFlow(
{
name: 'menuSuggestionFlow',
inputSchema: z.string(),
outputSchema: z.string(),
},
async (subject) => {
const llmResponse = await generate({
const llmResponse = await ai.generate({
prompt: `Suggest an item for the menu of a ${subject} themed restaurant`,
model: openAIGpt4o,
});

return llmResponse.text();
return llmResponse.text;
}
);
```
Expand All @@ -111,7 +116,7 @@ export const myFlow = defineFlow(
// ...configure Genkit (as shown above)...

const specialToolInputSchema = z.object({ meal: z.enum(["breakfast", "lunch", "dinner"]) });
const specialTool = defineTool(
const specialTool = ai.defineTool(
{
name: "specialTool",
description: "Retrieves today's special for the given meal",
Expand All @@ -125,13 +130,12 @@ const specialTool = defineTool(
}
);

const result = generate({
model: openAIGpt4o,
const result = ai.generate({
tools: [specialTool],
prompt: "What's for breakfast?",
});

console.log(result.then((res) => res.text()));
console.log(result.then((res) => res.text));
```

For more detailed examples and the explanation of other functionalities, refer to the [official Genkit documentation](https://firebase.google.com/docs/genkit/get-started).
Expand Down
Loading

0 comments on commit 6863b72

Please sign in to comment.