-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
feat: vertexAI package support #8236
Open
russellwheatley
wants to merge
105
commits into
main
Choose a base branch
from
vertexai
base: main
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
Show all changes
105 commits
Select commit
Hold shift + click to select a range
be507f9
init
russellwheatley bbef576
update README
russellwheatley 3c9eef3
.npmignore
russellwheatley 304c194
license
russellwheatley d713b4e
initial port over of vertexAI from firebase-js-sdk
russellwheatley 0b2cd55
react-native-builder-bob
russellwheatley 3bfdcdb
package.json updates
russellwheatley 91e2091
fix: format & fix TS type warnings
russellwheatley af1db1f
chore: format stream-reader file
russellwheatley 0908588
initial attempt at polyfilling stream
russellwheatley b12d240
fix: polyfill stream for react native
russellwheatley a91d3a2
chore: remove verbatimModuleSyntax
russellwheatley c889d14
chore: use module dist and update version for TS
russellwheatley 8495c61
chore: check in version.ts
russellwheatley 200d860
get version from version.ts
russellwheatley 68e502c
fix: RN specific stream
russellwheatley 30b673d
feat: allow auth and app check to be passed in
russellwheatley 7d385b0
test: write first test file
russellwheatley 08b3ce1
test: chat session
russellwheatley 788a667
initial count token
russellwheatley 76ae3af
test utils
russellwheatley b4a868b
ignore vertex test data
russellwheatley 1c5a1f8
convert mocks
russellwheatley 8c0bc5e
test: grab vertex mock responses
russellwheatley 4c205b7
setup jest for vertex
russellwheatley 99e6179
fix vertex script
russellwheatley 4df40ac
test: fix count token to use jest
russellwheatley e76e4c4
yarn.lock
russellwheatley 5740233
revert jest config
russellwheatley f29f85b
test: port over generate content test
russellwheatley b754196
test: fix generate content
russellwheatley 6d50eca
format mock response
russellwheatley 13a85be
port over generative model test
russellwheatley 128d840
test: generative model
russellwheatley 419c3db
port over request helpers tests
russellwheatley 09bc959
test: request helpers using jest
russellwheatley 852b44e
port over request tests
russellwheatley ab460e7
test: request tests
russellwheatley 58e19c5
test: request tests
russellwheatley ce69d52
port over response helpers
russellwheatley 22816ec
test: response headers
russellwheatley a37c29b
port over schema builder
russellwheatley 90b5324
test: scheme builder
russellwheatley 8a84f82
test: stream reader
russellwheatley 3f9b29e
port over api tests
russellwheatley 89c34fd
test: update chat session helper
russellwheatley 6ce27e1
rm dead code
russellwheatley 0c49ca1
test: api tests
russellwheatley 70bf9c2
test: service test
russellwheatley 41aa55c
Merge branch 'main' into vertexai
russellwheatley 223e40a
chore: move vertex mock script to scripts/
russellwheatley af911c9
chore: update license headers
russellwheatley 59c6aaa
chore: make note on API versions
russellwheatley 6137aba
fix: pin `web-streams-polyfill` dependency
russellwheatley 1802399
chore: remove version.ts from git
russellwheatley ffa1141
fix: mock-response types
russellwheatley b95c2ab
chore: update genversion script
russellwheatley 185ac48
chore: move logger to app
russellwheatley f699ea9
fix: wire up `onLog()` & `setLogLevel()` for VertexAI
russellwheatley 5bbcd8f
chore: rm unneeded TS declaration
russellwheatley c60e043
chore: remove FirebaseService class
russellwheatley c5d34fd
chore: update yarn.lock
russellwheatley 3e07cd8
test: make vertex response scripts only checkout repo if not existing
russellwheatley ca51da3
chore: move script call into vertex prepare
russellwheatley 673de9c
chore: move to start
russellwheatley 6ce04ad
fix: Logger internals, make it private
russellwheatley cf9bfa3
fix: try ignoring TS build issue
russellwheatley 4d049d4
test: remove e2e test for onLog and add unit test
russellwheatley 45d9bcb
chore: remove onLog e2e test
russellwheatley b2a0e74
Merge branch 'main' into vertexai
russellwheatley d489116
chore: eslint update
russellwheatley a898894
chore: fix lint issues
russellwheatley bb66d56
fix: fetch API issue with global polyfill. not needed
russellwheatley 354d28f
fix: stream now global polyfill has been removed
russellwheatley 256697c
chore: update yarn.lock
russellwheatley 411ba71
docs: vertexAI documentation
russellwheatley 10ce574
docs: vertexAI improvement
russellwheatley f4ea8ff
chore: format docs
russellwheatley 94838dc
chore: update spellcheck
russellwheatley cc20f84
chore: bump web-streams-polyfill version
russellwheatley 5e283f7
chore: update yarn.lock
russellwheatley e3847dd
test: rm unused files
russellwheatley fe76fdf
chore: update types to use RNFB
russellwheatley bf43693
test: add vertexAI to test runner
russellwheatley fa07a0d
chore: vertexAI e2e emulator functions
russellwheatley 637eb30
test: export vertex functions for testing
russellwheatley 66e0ab6
test: e2e test fetch/stream responses
russellwheatley 1b46450
test: reduce stream latency
russellwheatley 8e8a2c6
test: setup test environment
russellwheatley d0afb73
test: add env var for test setup
russellwheatley 0c9f687
chore: update app check and auth types
russellwheatley e82eb51
chore: update type comments
russellwheatley f4f9d2a
docs(vertexai): getting ready for production
russellwheatley a163b39
chore: update script to rm dist/
russellwheatley 6e2b630
chore: make explicit that it is a type
russellwheatley 30b2b0e
fix: TS build issue on CI
russellwheatley d48511e
test: fix jest tests
russellwheatley d378aee
test: use different tsconfig for jest. the use of RNFB app module cau…
russellwheatley 9f9c6f2
docs: fix sidebar hyperlink
russellwheatley 10bcb29
test: fix android e2e, point to correct host
russellwheatley 3514416
chore: use correct types for auth and app check
russellwheatley 3ceb58d
chore: update initialization of vertexai
russellwheatley 33f2fa6
Merge branch 'main' into vertexai
russellwheatley 001928b
Merge branch 'main' into vertexai
russellwheatley 5bd949d
chore: updates stringToEnum object
russellwheatley 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
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
62 changes: 62 additions & 0 deletions
62
.github/workflows/scripts/functions/src/vertexaiFunctions.ts
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,62 @@ | ||
import * as functions from 'firebase-functions/v2'; | ||
|
||
const poem = [ | ||
'The wind whispers secrets through the trees,', | ||
'Rustling leaves in a gentle breeze.', | ||
'Sunlight dances on the grass,', | ||
'A fleeting moment, sure to pass.', | ||
'Birdsong fills the air so bright,', | ||
'A symphony of pure delight.', | ||
'Time stands still, a peaceful pause,', | ||
"In nature's beauty, no flaws.", | ||
]; | ||
|
||
const response = { | ||
candidates: [ | ||
{ | ||
content: { | ||
parts: [ | ||
{ | ||
text: 'Google\'s mission is to "organize the world\'s information and make it universally accessible and useful."', | ||
}, | ||
], | ||
role: 'model', | ||
}, | ||
finishReason: 'STOP', | ||
index: 0, | ||
safetyRatings: [ | ||
{ category: 'HARM_CATEGORY_SEXUALLY_EXPLICIT', probability: 'NEGLIGIBLE' }, | ||
{ category: 'HARM_CATEGORY_HATE_SPEECH', probability: 'NEGLIGIBLE' }, | ||
{ category: 'HARM_CATEGORY_HARASSMENT', probability: 'NEGLIGIBLE' }, | ||
{ category: 'HARM_CATEGORY_DANGEROUS_CONTENT', probability: 'NEGLIGIBLE' }, | ||
], | ||
}, | ||
], | ||
promptFeedback: { | ||
safetyRatings: [ | ||
{ category: 'HARM_CATEGORY_SEXUALLY_EXPLICIT', probability: 'NEGLIGIBLE' }, | ||
{ category: 'HARM_CATEGORY_HATE_SPEECH', probability: 'NEGLIGIBLE' }, | ||
{ category: 'HARM_CATEGORY_HARASSMENT', probability: 'NEGLIGIBLE' }, | ||
{ category: 'HARM_CATEGORY_DANGEROUS_CONTENT', probability: 'NEGLIGIBLE' }, | ||
], | ||
}, | ||
}; | ||
|
||
export const testFetchStream = functions.https.onRequest(async (req, res) => { | ||
res.setHeader('Content-Type', 'text/event-stream'); | ||
res.setHeader('Cache-Control', 'no-cache'); | ||
res.setHeader('Connection', 'keep-alive'); | ||
|
||
const updatedResponse = { ...response }; | ||
|
||
for (let i = 0; i < poem.length; i++) { | ||
updatedResponse.candidates[0].content.parts[0].text = poem[i]; | ||
res.write(`data: ${JSON.stringify(updatedResponse)}\n\n`); | ||
await new Promise(resolve => setTimeout(resolve, 100)); | ||
} | ||
res.end(); | ||
}); | ||
|
||
export const testFetch = functions.https.onRequest(async (req, res) => { | ||
res.json(response); | ||
}); |
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
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
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
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.
the .eslintignore file has a non-trivial conflict from #8262 - the file is completely gone as eslint config changed completely across major versions. You add new ignores to the new .eslint.mjs file following pattern there
note the glob / regex style changed just a bit but the pattern is easy to follow
https://github.com/invertase/react-native-firebase/blob/main/eslint.config.mjs#L17-L39