Skip to content
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
wants to merge 101 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
be507f9
init
russellwheatley Jan 7, 2025
bbef576
update README
russellwheatley Jan 7, 2025
3c9eef3
.npmignore
russellwheatley Jan 7, 2025
304c194
license
russellwheatley Jan 7, 2025
d713b4e
initial port over of vertexAI from firebase-js-sdk
russellwheatley Jan 8, 2025
0b2cd55
react-native-builder-bob
russellwheatley Jan 8, 2025
3bfdcdb
package.json updates
russellwheatley Jan 8, 2025
91e2091
fix: format & fix TS type warnings
russellwheatley Jan 9, 2025
af1db1f
chore: format stream-reader file
russellwheatley Jan 9, 2025
0908588
initial attempt at polyfilling stream
russellwheatley Jan 9, 2025
b12d240
fix: polyfill stream for react native
russellwheatley Jan 10, 2025
a91d3a2
chore: remove verbatimModuleSyntax
russellwheatley Jan 10, 2025
c889d14
chore: use module dist and update version for TS
russellwheatley Jan 10, 2025
8495c61
chore: check in version.ts
russellwheatley Jan 10, 2025
200d860
get version from version.ts
russellwheatley Jan 10, 2025
68e502c
fix: RN specific stream
russellwheatley Jan 10, 2025
30b673d
feat: allow auth and app check to be passed in
russellwheatley Jan 16, 2025
7d385b0
test: write first test file
russellwheatley Jan 16, 2025
08b3ce1
test: chat session
russellwheatley Jan 17, 2025
788a667
initial count token
russellwheatley Jan 17, 2025
76ae3af
test utils
russellwheatley Jan 17, 2025
b4a868b
ignore vertex test data
russellwheatley Jan 17, 2025
1c5a1f8
convert mocks
russellwheatley Jan 17, 2025
8c0bc5e
test: grab vertex mock responses
russellwheatley Jan 17, 2025
4c205b7
setup jest for vertex
russellwheatley Jan 17, 2025
99e6179
fix vertex script
russellwheatley Jan 17, 2025
4df40ac
test: fix count token to use jest
russellwheatley Jan 17, 2025
e76e4c4
yarn.lock
russellwheatley Jan 17, 2025
5740233
revert jest config
russellwheatley Jan 17, 2025
f29f85b
test: port over generate content test
russellwheatley Jan 17, 2025
b754196
test: fix generate content
russellwheatley Jan 17, 2025
6d50eca
format mock response
russellwheatley Jan 17, 2025
13a85be
port over generative model test
russellwheatley Jan 17, 2025
128d840
test: generative model
russellwheatley Jan 17, 2025
419c3db
port over request helpers tests
russellwheatley Jan 17, 2025
09bc959
test: request helpers using jest
russellwheatley Jan 17, 2025
852b44e
port over request tests
russellwheatley Jan 17, 2025
ab460e7
test: request tests
russellwheatley Jan 17, 2025
58e19c5
test: request tests
russellwheatley Jan 20, 2025
ce69d52
port over response helpers
russellwheatley Jan 20, 2025
22816ec
test: response headers
russellwheatley Jan 20, 2025
a37c29b
port over schema builder
russellwheatley Jan 20, 2025
90b5324
test: scheme builder
russellwheatley Jan 20, 2025
8a84f82
test: stream reader
russellwheatley Jan 20, 2025
3f9b29e
port over api tests
russellwheatley Jan 20, 2025
89c34fd
test: update chat session helper
russellwheatley Jan 20, 2025
6ce27e1
rm dead code
russellwheatley Jan 20, 2025
0c49ca1
test: api tests
russellwheatley Jan 20, 2025
70bf9c2
test: service test
russellwheatley Jan 20, 2025
41aa55c
Merge branch 'main' into vertexai
russellwheatley Jan 20, 2025
223e40a
chore: move vertex mock script to scripts/
russellwheatley Jan 20, 2025
af911c9
chore: update license headers
russellwheatley Jan 20, 2025
59c6aaa
chore: make note on API versions
russellwheatley Jan 20, 2025
6137aba
fix: pin `web-streams-polyfill` dependency
russellwheatley Jan 20, 2025
1802399
chore: remove version.ts from git
russellwheatley Jan 20, 2025
ffa1141
fix: mock-response types
russellwheatley Jan 20, 2025
b95c2ab
chore: update genversion script
russellwheatley Jan 20, 2025
185ac48
chore: move logger to app
russellwheatley Jan 21, 2025
f699ea9
fix: wire up `onLog()` & `setLogLevel()` for VertexAI
russellwheatley Jan 21, 2025
5bbcd8f
chore: rm unneeded TS declaration
russellwheatley Jan 21, 2025
c60e043
chore: remove FirebaseService class
russellwheatley Jan 21, 2025
c5d34fd
chore: update yarn.lock
russellwheatley Jan 21, 2025
3e07cd8
test: make vertex response scripts only checkout repo if not existing
russellwheatley Jan 22, 2025
ca51da3
chore: move script call into vertex prepare
russellwheatley Jan 22, 2025
673de9c
chore: move to start
russellwheatley Jan 22, 2025
6ce04ad
fix: Logger internals, make it private
russellwheatley Jan 22, 2025
cf9bfa3
fix: try ignoring TS build issue
russellwheatley Jan 22, 2025
4d049d4
test: remove e2e test for onLog and add unit test
russellwheatley Jan 22, 2025
45d9bcb
chore: remove onLog e2e test
russellwheatley Jan 22, 2025
b2a0e74
Merge branch 'main' into vertexai
russellwheatley Jan 24, 2025
d489116
chore: eslint update
russellwheatley Jan 24, 2025
a898894
chore: fix lint issues
russellwheatley Jan 24, 2025
bb66d56
fix: fetch API issue with global polyfill. not needed
russellwheatley Jan 27, 2025
354d28f
fix: stream now global polyfill has been removed
russellwheatley Jan 27, 2025
256697c
chore: update yarn.lock
russellwheatley Jan 27, 2025
411ba71
docs: vertexAI documentation
russellwheatley Jan 27, 2025
10ce574
docs: vertexAI improvement
russellwheatley Jan 27, 2025
f4ea8ff
chore: format docs
russellwheatley Jan 27, 2025
94838dc
chore: update spellcheck
russellwheatley Jan 27, 2025
cc20f84
chore: bump web-streams-polyfill version
russellwheatley Jan 28, 2025
5e283f7
chore: update yarn.lock
russellwheatley Jan 28, 2025
e3847dd
test: rm unused files
russellwheatley Jan 28, 2025
fe76fdf
chore: update types to use RNFB
russellwheatley Jan 28, 2025
bf43693
test: add vertexAI to test runner
russellwheatley Jan 28, 2025
fa07a0d
chore: vertexAI e2e emulator functions
russellwheatley Jan 29, 2025
637eb30
test: export vertex functions for testing
russellwheatley Jan 29, 2025
66e0ab6
test: e2e test fetch/stream responses
russellwheatley Jan 29, 2025
1b46450
test: reduce stream latency
russellwheatley Jan 29, 2025
8e8a2c6
test: setup test environment
russellwheatley Jan 29, 2025
d0afb73
test: add env var for test setup
russellwheatley Jan 29, 2025
0c9f687
chore: update app check and auth types
russellwheatley Jan 29, 2025
e82eb51
chore: update type comments
russellwheatley Jan 29, 2025
f4f9d2a
docs(vertexai): getting ready for production
russellwheatley Jan 29, 2025
a163b39
chore: update script to rm dist/
russellwheatley Jan 29, 2025
6e2b630
chore: make explicit that it is a type
russellwheatley Jan 29, 2025
30b2b0e
fix: TS build issue on CI
russellwheatley Jan 29, 2025
d48511e
test: fix jest tests
russellwheatley Jan 29, 2025
d378aee
test: use different tsconfig for jest. the use of RNFB app module cau…
russellwheatley Jan 30, 2025
9f9c6f2
docs: fix sidebar hyperlink
russellwheatley Jan 30, 2025
10bcb29
test: fix android e2e, point to correct host
russellwheatley Jan 31, 2025
3514416
chore: use correct types for auth and app check
russellwheatley Jan 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ docs
packages/template/project/**
app.playground.js
type-test.ts
packages/**/modular/dist/**
packages/**/modular/dist/**
packages/vertexai/__tests__/test-utils
packages/vertexai/dist
2 changes: 2 additions & 0 deletions .github/workflows/scripts/functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ export { testFunctionDefaultRegionV2 } from './testFunctionDefaultRegion';
export { testFunctionRemoteConfigUpdateV2 } from './testFunctionRemoteConfigUpdate';
export { fetchAppCheckTokenV2 } from './fetchAppCheckToken';
export { sendFCM } from './sendFCM';

export { testFetchStream, testFetch } from './vertexaiFunctions';
62 changes: 62 additions & 0 deletions .github/workflows/scripts/functions/src/vertexaiFunctions.ts
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);
});
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ Pods/*
**/Pods/**
**/dist/
packages/**/version.js
packages/**/version.ts
typedoc.raw.json
tests/ios/Firebase
tests/ios/resetXcode.sh
Expand Down Expand Up @@ -579,3 +580,7 @@ website/public

# Typescript items
*.tsbuildinfo

# vertexai test data
vertexai-sdk-test-data
mocks-lookup.ts
2 changes: 2 additions & 0 deletions .spellcheck.dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ firebase-js-sdk
FirebaseApp
firestore
Firestore
freeform
GDPR
GDPR-compliant
getIdToken
Expand Down Expand Up @@ -214,6 +215,7 @@ v6
v7
v9
Ventura
VertexAI
VPN
VSCode
Wix
Expand Down
4 changes: 4 additions & 0 deletions docs/sidebar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@
- - KY Integration
- '/perf/ky-integration'
- '//static.invertase.io/assets/firebase/performance-monitoring.svg'
- - VertexAi
- - - Usage
- '/vertexai/usage'
- '//static.invertase.io/assets/social/firebase-logo.png'
- - Legacy docs
- - - Migrating to v6
- '/migrating-to-v6'
Expand Down
Loading
Loading