-
Notifications
You must be signed in to change notification settings - Fork 955
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
Preparing for genkit 0.9.0 #7907
Conversation
src/init/features/genkit/index.ts
Outdated
if (semver.gte(genkitVersion, "1.0.0")) { | ||
// We don't know about this version. | ||
throw new FirebaseError( | ||
"Please update your firebase-tools. Alternatively you can set a GENKIT_DEV_VERSION environment variable to choose a genkit version < 1.0.0", | ||
); | ||
} else if (semver.gte(genkitVersion, "0.6.0")) { | ||
sampleVersion = "0.9.0"; | ||
useInit = false; | ||
} else { | ||
sampleVersion = ""; | ||
useInit = true; | ||
} |
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'm thinking instead of doing this we should just hardcode the version that firebase init genkit
installs to be ^0.9
. The template here is something we'll have to maintain, and update versions for each major release.
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.
The whole reason we're doing this PR is because we don't want things to break and have no solution.
With this setup, I can submit this PR now, people can update to it, and it will continue to allow them to install 0.5.17 (the latest) up until we release 0.9.0 and then it will install 0.9.0.
If I don't do this, then I can't submit this PR until sometime after we release 0.9.0 and there will be a period where it is just broken with no "just update to the latest firebase-tools" fix.
It would also not notify people to update their firebase-tools because a newer version (>=1.0.0) is available.
If we had this kind of logic in place from the beginning, then nothing would break when we release 0.9.0. So I'm a bit confused why you want me to remove it. People do not necessarily update their firebase-tools unless they have a reason to do so.
I wouldn't want them to be "stuck" getting firebase init genkit
installs for 0.9.0 when the latest version of genkit is 1.5.7 and there have been breaking change and the docs are for 1.5.7 and they just have a bad time trying to figure out what's going on and end up not liking genkit because it's "broken". I'd much rather have them getting a message saying "you need to update your firebase-tools, or explicitly pick an "old" version of genkit to install". If we do it this way then, we can remove support for older versions and add support for newer versions and not be coupled to the release of genkit versions without breaking anything. I feel very strongly that this is a good solution.
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.
supporting 0.5 is fine...
I'm more thinking about the semver.gte(genkitVersion, "1.0.0")
case. I think that if version is semver.gte(genkitVersion, "0.6.0")
we pin it to 0.9. until we update the firebase cli in the future.
src/init/features/genkit/index.ts
Outdated
plugin: "@genkit-ai/vertexai", | ||
package: `@genkit-ai/vertexai@${genkitVersion}`, | ||
}, | ||
ollama: { |
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.
please remove ollama as an option here -- it requires many more setup/deployment steps that we can't cover in this init flow.
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.
src/init/features/genkit/index.ts
Outdated
/** | ||
* Updates tsconfig.json with required flags for Genkit. | ||
*/ | ||
async function updateTsConfig(nonInteractive: boolean, projectDir: string) { |
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.
Please see if we can just add skipLibCheck: true
to https://github.com/firebase/firebase-tools/blob/master/templates/init/functions/typescript/tsconfig.json
This way we can drop the updateTsConfig
entirely here.
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.
In the interest of getting this submitted quickly because genkit 0.9.0 release is approaching, I could leave it like this for now because it works, and then in a second PR, we could look at having a discussion with the functions folks, and simplify the code if possible. Is that ok?
src/init/features/genkit/index.ts
Outdated
/** | ||
* Updates package.json with Genkit-expected fields. | ||
*/ | ||
async function updatePackageJson(nonInteractive: boolean, projectDir: string) { |
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 don't think this is necessary for firebase case... this can be dropped entirely.
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.
Recall that even with instructions, I had a bad time trying to figure out why the UI was "broken" and spent quite some time trying to fix "step 7" before moving on to "step 8". And the solution was "you need to run step 7, then not open the UI yet, then run step 8, then go back and open the UI from step 7". That's why I added package.json scripts like genkit:start
that runs step 7 and step 8 in order together, so there's no confusion. (and also genit:stop
which just stops the ui). That way people are not left in a "ok, it's installed, now what?" state, but rather they have an easy way to get everything going so they can focus on playing with a working genkit and not on trying to "fix a broken step 7" like I was.
logger.info("Start the Genkit developer experience by running:"); | ||
logger.info(` cd ${setup.functions.source} && npm run genkit:start`); |
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 need these... drop maybe?
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.
We absolutely need these. I know you know all the details about how to start genkit and get it running and the right order to do those things, but the genkit newbie does not (i.e. people like me who spent too much trying with a "broken" genkit trying to debug what was wrong.)
src/init/features/genkit/index.ts
Outdated
"genkit:start": "genkit ui:start && GENKIT_ENV=dev tsx --watch src/genkit-sample.ts", | ||
"genkit:stop": "genkit ui:stop", |
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.
"genkit:start": "genkit ui:start && GENKIT_ENV=dev tsx --watch src/genkit-sample.ts", | |
"genkit:stop": "genkit ui:stop", | |
"genkit:start": "genkit start -- tsx --watch src/genkit-sample.ts" |
|
||
// Handle the response from the model API. In this sample, we just | ||
// convert it to a string, but more complicated flows might coerce the | ||
// response into structured output or chain the response into another | ||
// LLM call, etc. | ||
return llmResponse.text; |
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.
// Handle the response from the model API. In this sample, we just | |
// convert it to a string, but more complicated flows might coerce the | |
// response into structured output or chain the response into another | |
// LLM call, etc. | |
return llmResponse.text; | |
// Handle the response from the model API. In this sample, we just | |
// convert it to a string, but more complicated flows might coerce the | |
// response into structured output or chain the response into another | |
// LLM call, etc. | |
return llmResponse.text; |
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'm not seeing that in the current version of the template. I might have fixed it along the way (possibly it was tabs before?)
// Import the Genkit core libraries and plugins. | ||
import {genkit} from 'genkit'; | ||
import {logger} from 'genkit/logging'; | ||
$GENKIT_CONFIG_IMPORTS | ||
$GENKIT_MODEL_IMPORT | ||
|
||
// From the Firebase plugin, import the functions needed to deploy flows using | ||
// Cloud Functions. | ||
import {firebaseAuth} from "@genkit-ai/firebase/auth"; | ||
import {onFlow} from "@genkit-ai/firebase/functions"; | ||
|
||
// Log debug output to tbe console. | ||
logger.setLogLevel("debug"); |
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.
// Import the Genkit core libraries and plugins. | |
import {genkit} from 'genkit'; | |
import {logger} from 'genkit/logging'; | |
$GENKIT_CONFIG_IMPORTS | |
$GENKIT_MODEL_IMPORT | |
// From the Firebase plugin, import the functions needed to deploy flows using | |
// Cloud Functions. | |
import {firebaseAuth} from "@genkit-ai/firebase/auth"; | |
import {onFlow} from "@genkit-ai/firebase/functions"; | |
// Log debug output to tbe console. | |
logger.setLogLevel("debug"); | |
// Import the Genkit core libraries and plugins. | |
import {genkit} from 'genkit'; | |
$GENKIT_CONFIG_IMPORTS | |
$GENKIT_MODEL_IMPORT | |
// From the Firebase plugin, import the functions needed to deploy flows using | |
// Cloud Functions. | |
import {firebaseAuth} from "@genkit-ai/firebase/auth"; | |
import {onFlow} from "@genkit-ai/firebase/functions"; | |
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
src/init/features/genkit/index.ts
Outdated
|
||
if (semver.gte(genkitVersion, "1.0.0")) { | ||
// We don't know about this version. | ||
throw new FirebaseError( |
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.
as discussed please change this to a warning
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
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #7907 +/- ##
=======================================
Coverage 51.36% 51.37%
=======================================
Files 422 422
Lines 29344 29344
Branches 5996 5996
=======================================
+ Hits 15074 15076 +2
+ Misses 12915 12914 -1
+ Partials 1355 1354 -1 ☔ View full report in Codecov by Sentry. |
preparing for genkit version 0.9.0+