You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm trying to use "Mscc.Generative AI" library with APIkey work well, but win OAuth2 doesn't work.
I always get the exception on the CreateTunedModel call.
System.Net.Http.HttpRequestException
HResult=0x80131500
Message=Request failed
Request failed with Status Code: Unauthorized
{
"error": {
"code": 401,
"message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
Source=Mscc.GenerativeAI
StackTrace:
at Mscc.GenerativeAI.GenerativeAIExtensions.d__17.MoveNext()
at Mscc.GenerativeAI.GenerativeModel.d__46.MoveNext()
at Program.<
$>d__0.MoveNext() in C:\Users\david\Desktop\Progetti\ResponderIA\ResponderIA\Program.cs:line 32
This is my code:
using System.Reflection;
using Mscc.GenerativeAI;
using System.Collections.Generic;
// I tried different codes:
// gcloud auth application-default print-access-token
// client secret code
var googleAI = new GoogleAI(apiKey: null,"");
var model = googleAI.GenerativeModel(model: Model.Gemini10Pro001);
model.ProjectId = "gen-lang-client-0860587592";
var parameters = new HyperParameters() { BatchSize = 2, LearningRate = 0.001f, EpochCount = 3 };
var dataset = new List
{
new() { TextInput = "What's magi number?", Output = "200" },
};
var request = new CreateTunedModelRequest(
Model.Gemini10Pro001,
"My Test Model",
dataset,
parameters);
var response = await model.CreateTunedModel(request);
Regards Davide
The text was updated successfully, but these errors were encountered:
Thanks for the response and sample code to understand the issue better.
Referring to the README, you need to have gcloud CLI command line tool installed on the system running your C# code. Then one needs to enable and use OAuth for the Google AI as described here - https://ai.google.dev/gemini-api/docs/oauth - first. This provides the necessary scopes for the library to access the resources to tune a model.
Google AI with OAuth. Use gcloud auth application-default print-access-token to get the access token.
using Mscc.GenerativeAI;
// Google AI with OAuth. Use `gcloud auth application-default print-access-token` to get the access token.
var googleAi = new GoogleAI(accessToken: "<your value>");
var model = googleAi.GenerativeModel(model: Model.Gemini10Pro001);
...
Your code var googleAI = new GoogleAI(apiKey: null,""); does not provide the access token and therefore your call is unauthenticated and returned as an HTTP 401. You have to specify an access token not an empty string.
Also, see the Troubleshooting section at the end of the README file.
Hi, I'm trying to use "Mscc.Generative AI" library with APIkey work well, but win OAuth2 doesn't work.
I always get the exception on the CreateTunedModel call.
System.Net.Http.HttpRequestException
HResult=0x80131500
Message=Request failed
Request failed with Status Code: Unauthorized
{
"error": {
"code": 401,
"message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
Source=Mscc.GenerativeAI
$>d__0.MoveNext() in C:\Users\david\Desktop\Progetti\ResponderIA\ResponderIA\Program.cs:line 32StackTrace:
at Mscc.GenerativeAI.GenerativeAIExtensions.d__17.MoveNext()
at Mscc.GenerativeAI.GenerativeModel.d__46.MoveNext()
at Program.<
This is my code:
using System.Reflection;
using Mscc.GenerativeAI;
using System.Collections.Generic;
// I tried different codes:
// gcloud auth application-default print-access-token
// client secret code
var googleAI = new GoogleAI(apiKey: null,"");
var model = googleAI.GenerativeModel(model: Model.Gemini10Pro001);
model.ProjectId = "gen-lang-client-0860587592";
var parameters = new HyperParameters() { BatchSize = 2, LearningRate = 0.001f, EpochCount = 3 };
var dataset = new List
{
new() { TextInput = "What's magi number?", Output = "200" },
};
var request = new CreateTunedModelRequest(
Model.Gemini10Pro001,
"My Test Model",
dataset,
parameters);
var response = await model.CreateTunedModel(request);
Regards Davide
The text was updated successfully, but these errors were encountered: