-
Notifications
You must be signed in to change notification settings - Fork 40
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
Initial VertexAI API surface #1179
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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,42 @@ | ||
/* | ||
* Copyright 2025 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. | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Firebase.VertexAI { | ||
|
||
public enum FinishReason { | ||
Unknown, | ||
Stop, | ||
MaxTokens, | ||
Safety, | ||
Recitation, | ||
Other, | ||
Blocklist, | ||
ProhibitedContent, | ||
SPII, | ||
MalformedFunctionCall, | ||
} | ||
|
||
public readonly struct Candidate { | ||
public ModelContent Content { get; } | ||
public IEnumerable<SafetyRating> SafetyRatings { get; } | ||
public FinishReason? FinishReason { get; } | ||
public CitationMetadata? CitationMetadata { get; } | ||
} | ||
|
||
} |
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,76 @@ | ||
/* | ||
* Copyright 2025 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. | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
namespace Firebase.VertexAI { | ||
|
||
public class Chat { | ||
|
||
public IEnumerable<ModelContent> History { get; } | ||
|
||
// Note: The generation functions are the same as the ones in GenerativeModel | ||
|
||
public Task<GenerateContentResponse> GenerateContentAsync( | ||
params ModelContent[] content) { | ||
throw new NotImplementedException(); | ||
} | ||
public Task<GenerateContentResponse> GenerateContentAsync( | ||
string text) { | ||
throw new NotImplementedException(); | ||
} | ||
public Task<GenerateContentResponse> GenerateContentAsync( | ||
IEnumerable<ModelContent> content) { | ||
throw new NotImplementedException(); | ||
} | ||
|
||
// The build logic isn't able to resolve IAsyncEnumerable for some reason, even | ||
// though it is usable in Unity 2021.3. Will need to investigate further. | ||
/* | ||
public IAsyncEnumerable<GenerateContentResponse> GenerateContentStreamAsync( | ||
params ModelContent[] content) { | ||
throw new NotImplementedException(); | ||
} | ||
public IAsyncEnumerable<GenerateContentResponse> GenerateContentStreamAsync( | ||
string text) { | ||
throw new NotImplementedException(); | ||
} | ||
public IAsyncEnumerable<GenerateContentResponse> GenerateContentStreamAsync( | ||
IEnumerable<ModelContent> content) { | ||
throw new NotImplementedException(); | ||
} | ||
*/ | ||
|
||
public Task<CountTokensResponse> CountTokensAsync( | ||
params ModelContent[] content) { | ||
throw new NotImplementedException(); | ||
} | ||
public Task<CountTokensResponse> CountTokensAsync( | ||
string text) { | ||
throw new NotImplementedException(); | ||
} | ||
public Task<CountTokensResponse> CountTokensAsync( | ||
IEnumerable<ModelContent> content) { | ||
throw new NotImplementedException(); | ||
} | ||
|
||
// Note: No public constructor, get one through GenerativeModel.StartChat | ||
|
||
} | ||
|
||
} |
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,38 @@ | ||
/* | ||
* Copyright 2025 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. | ||
*/ | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace Firebase.VertexAI { | ||
|
||
public readonly struct CitationMetadata { | ||
public IEnumerable<Citation> Citations { get; } | ||
|
||
// Hidden constructor, users don't need to make this | ||
} | ||
|
||
public readonly struct Citation { | ||
public int StartIndex { get; } | ||
public int EndIndex { get; } | ||
public System.Uri Uri { get; } | ||
public string Title { get; } | ||
public string License { get; } | ||
public System.DateTime? PublicationDate { get; } | ||
|
||
// Hidden constructor, users don't need to make this | ||
} | ||
|
||
} |
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,26 @@ | ||
/* | ||
* Copyright 2025 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. | ||
*/ | ||
|
||
namespace Firebase.VertexAI { | ||
|
||
public readonly struct CountTokensResponse { | ||
public int TotalTokens { get; } | ||
public int? TotalBillableCharacters { get; } | ||
|
||
// Hidden constructor, users don't need to make this | ||
} | ||
|
||
} |
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,70 @@ | ||
/* | ||
* Copyright 2025 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. | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Firebase.VertexAI { | ||
|
||
public readonly struct FunctionDeclaration { | ||
// No public properties, on purpose since it is meant for user input only | ||
|
||
public FunctionDeclaration(string name, string description, | ||
IDictionary<string, Schema> parameters, | ||
IEnumerable<string> optionalParameters = null) { | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
|
||
public readonly struct Tool { | ||
// No public properties, on purpose since it is meant for user input only | ||
|
||
public Tool(params FunctionDeclaration[] functionDeclarations) { | ||
throw new NotImplementedException(); | ||
} | ||
public Tool(IEnumerable<FunctionDeclaration> functionDeclarations) { | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
|
||
public readonly struct ToolConfig { | ||
// No public properties, on purpose since it is meant for user input only | ||
|
||
public ToolConfig(FunctionCallingConfig? functionCallingConfig = null) { | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
|
||
public readonly struct FunctionCallingConfig { | ||
// No public properties, on purpose since it is meant for user input only | ||
|
||
public static FunctionCallingConfig Auto() { | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public static FunctionCallingConfig Any(params string[] allowedFunctionNames) { | ||
throw new NotImplementedException(); | ||
} | ||
public static FunctionCallingConfig Any(IEnumerable<string> allowedFunctionNames) { | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public static FunctionCallingConfig None() { | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
|
||
} |
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,58 @@ | ||
/* | ||
* Copyright 2025 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. | ||
*/ | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace Firebase.VertexAI { | ||
|
||
public readonly struct GenerateContentResponse { | ||
public IEnumerable<Candidate> Candidates { get; } | ||
public PromptFeedback? PromptFeedback { get; } | ||
public UsageMetadata? UsageMetadata { get; } | ||
|
||
// Helper properties | ||
// The response's content as text, if it exists | ||
public string Text { get; } | ||
|
||
// Returns function calls found in any Parts of the first candidate of the response, if any. | ||
public IEnumerable<ModelContent.FunctionCallPart> FunctionCalls { get; } | ||
} | ||
|
||
public enum BlockReason { | ||
Unknown, | ||
Safety, | ||
Other, | ||
Blocklist, | ||
ProhibitedContent, | ||
} | ||
|
||
public readonly struct PromptFeedback { | ||
public BlockReason? BlockReason { get; } | ||
public string BlockReasonMessage { get; } | ||
public IEnumerable<SafetyRating> SafetyRatings { get; } | ||
|
||
// Hidden constructor, users don't need to make this | ||
} | ||
|
||
public readonly struct UsageMetadata { | ||
public int PromptTokenCount { get; } | ||
public int CandidatesTokenCount { get; } | ||
public int TotalTokenCount { get; } | ||
|
||
// Hidden constructor, users don't need to make this | ||
} | ||
|
||
} |
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,36 @@ | ||
/* | ||
* Copyright 2025 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. | ||
*/ | ||
|
||
using System; | ||
|
||
namespace Firebase.VertexAI { | ||
|
||
public readonly struct GenerationConfig { | ||
|
||
public GenerationConfig( | ||
float? temperature = null, | ||
float? topP = null, | ||
float? topK = null, | ||
int? candidateCount = null, | ||
int? maxOutputTokens = null, | ||
float? prescencePenalty = null, | ||
float? frequencyPenalty = null, | ||
string[] stopSequences = null, | ||
string responseMimeType = null, | ||
Schema responseSchema = null) { throw new NotImplementedException(); } | ||
} | ||
|
||
} |
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.
not blocking, maybe consider to add related modality token info similar to this PR as well? firebase/flutterfire#17065
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.
Yeah, I'll need to reorganize what my plans are for some of those based on the recent changes, but I'll wait until I'm doing the implementation of these parts, just to let the other platforms settle in on something for sure.