-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial VertexAI API surface (#1179)
* Initial VertexAI API surface * Comment out IAsyncEnumerable for now * Add missing guids
- Loading branch information
Showing
16 changed files
with
846 additions
and
2 deletions.
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.