-
Notifications
You must be signed in to change notification settings - Fork 54
Add limited use tokens for ai logic #1454
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ public class TemplateGenerativeModel | |
| private readonly FirebaseApp _firebaseApp; | ||
| private readonly FirebaseAI.Backend _backend; | ||
| private readonly RequestOptions? _requestOptions; | ||
| private readonly bool _useLimitedUseAppCheckTokens; | ||
|
|
||
| private readonly HttpClient _httpClient; | ||
|
|
||
|
|
@@ -46,10 +47,12 @@ public class TemplateGenerativeModel | |
| /// </summary> | ||
| internal TemplateGenerativeModel(FirebaseApp firebaseApp, | ||
| FirebaseAI.Backend backend, | ||
| RequestOptions? requestOptions = null) | ||
| RequestOptions? requestOptions = null, | ||
| bool useLimitedUseAppCheckTokens = false) | ||
| { | ||
| _firebaseApp = firebaseApp; | ||
| _backend = backend; | ||
| _useLimitedUseAppCheckTokens = useLimitedUseAppCheckTokens; | ||
|
|
||
| // Create a HttpClient using the timeout requested, or the default one. | ||
| _httpClient = new HttpClient() | ||
|
|
@@ -148,7 +151,7 @@ private async Task<GenerateContentResponse> GenerateContentAsyncInternal( | |
| Firebase.AI.Internal.HttpHelpers.GetTemplateURL(_firebaseApp, _backend, templateId) + ":templateGenerateContent"); | ||
|
|
||
| // Set the request headers | ||
| await Firebase.Internal.HttpHelpers.SetRequestHeaders(request, _firebaseApp); | ||
| await Firebase.Internal.HttpHelpers.SetRequestHeaders(request, _firebaseApp, limitedUseAppCheckTokens: _useLimitedUseAppCheckTokens); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The await Firebase.Internal.FirebaseInterops.AddFirebaseTokensAsync(request, _firebaseApp, limitedUseAppCheckTokens: _useLimitedUseAppCheckTokens);
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has been added in with functions |
||
|
|
||
| // Set the content | ||
| string bodyJson = MakeGenerateContentRequest(inputs, chatHistory, tools, toolConfig); | ||
|
|
@@ -181,7 +184,7 @@ private async IAsyncEnumerable<GenerateContentResponse> GenerateContentStreamAsy | |
| Firebase.AI.Internal.HttpHelpers.GetTemplateURL(_firebaseApp, _backend, templateId) + ":templateStreamGenerateContent?alt=sse"); | ||
|
|
||
| // Set the request headers | ||
| await Firebase.Internal.HttpHelpers.SetRequestHeaders(request, _firebaseApp); | ||
| await Firebase.Internal.HttpHelpers.SetRequestHeaders(request, _firebaseApp, limitedUseAppCheckTokens: _useLimitedUseAppCheckTokens); | ||
|
AustinBenoit marked this conversation as resolved.
|
||
|
|
||
| // Set the content | ||
| string bodyJson = MakeGenerateContentRequest(inputs, chatHistory, tools, toolConfig); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.