-
Notifications
You must be signed in to change notification settings - Fork 468
Removing OAuth from tuning for REST #579
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
Merged
MarkDaoust
merged 3 commits into
google-gemini:main
from
shilpakancharla:remove_oauth_tuning
Oct 1, 2024
Merged
Changes from 1 commit
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 hidden or 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 |
---|---|---|
@@ -1,14 +1,11 @@ | ||
set -eu | ||
|
||
access_token=$(gcloud auth application-default print-access-token) | ||
|
||
GOOGLE_API_KEY=AIzaSyB1bw8ghsEm65evO_Yn9CeorYEh2oDEw-M | ||
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. Revert this line. Use environment variables to avoid this. Put:
In your |
||
|
||
echo "[START tuned_models_create]" | ||
# [START tuned_models_create] | ||
curl -X POST https://generativelanguage.googleapis.com/v1beta/tunedModels \ | ||
curl -X POST "https://generativelanguage.googleapis.com/v1beta/tunedModels?key=$GOOGLE_API_KEY" \ | ||
-H 'Content-Type: application/json' \ | ||
-H "Authorization: Bearer ${access_token}" \ | ||
-H "x-goog-user-project: ${project_id}" \ | ||
-d ' | ||
{ | ||
"display_name": "number generator model", | ||
|
@@ -82,10 +79,8 @@ tuning_done=false | |
while [[ "$tuning_done" != "true" ]]; | ||
do | ||
sleep 5 | ||
curl -X GET https://generativelanguage.googleapis.com/v1/${operation} \ | ||
-H 'Content-Type: application/json' \ | ||
-H "Authorization: Bearer ${access_token}" \ | ||
-H "x-goog-user-project: ${project_id}" 2> /dev/null > tuning_operation.json | ||
curl -X GET "https://generativelanguage.googleapis.com/v1/${operation}?key=$GOOGLE_API_KEY" \ | ||
-H 'Content-Type: application/json' \ 2> /dev/null > tuning_operation.json | ||
|
||
complete=$(jq .metadata.completedPercent < tuning_operation.json) | ||
tput cuu1 | ||
|
@@ -96,21 +91,17 @@ done | |
|
||
# Or get the TunedModel and check it's state. The model is ready to use if the state is active. | ||
modelname=$(cat tunemodel.json | jq ".metadata.tunedModel" | tr -d '"') | ||
curl -X GET https://generativelanguage.googleapis.com/v1beta/${modelname} \ | ||
-H 'Content-Type: application/json' \ | ||
-H "Authorization: Bearer ${access_token}" \ | ||
-H "x-goog-user-project: ${project_id}" > tuned_model.json | ||
curl -X GET https://generativelanguage.googleapis.com/v1beta/${modelname}?key=$GOOGLE_API_KEY \ | ||
-H 'Content-Type: application/json' > tuned_model.json | ||
|
||
cat tuned_model.json | jq ".state" | ||
# [END tuned_models_create] | ||
|
||
|
||
echo "[START tuned_models_generate_content]" | ||
# [START tuned_models_generate_content] | ||
curl -X POST https://generativelanguage.googleapis.com/v1beta/$modelname:generateContent \ | ||
curl -X POST https://generativelanguage.googleapis.com/v1beta/$modelname:generateContent?key=$GOOGLE_API_KEY \ | ||
-H 'Content-Type: application/json' \ | ||
-H "Authorization: Bearer ${access_token}" \ | ||
-H "x-goog-user-project: ${project_id}" \ | ||
-d '{ | ||
"contents": [{ | ||
"parts": [{ | ||
|
@@ -122,10 +113,8 @@ curl -X POST https://generativelanguage.googleapis.com/v1beta/$modelname:generat | |
|
||
echo "[START tuned_models_get]" | ||
# [START tuned_models_get] | ||
curl -X GET https://generativelanguage.googleapis.com/v1beta/${modelname} \ | ||
-H 'Content-Type: application/json' \ | ||
-H "Authorization: Bearer ${access_token}" \ | ||
-H "x-goog-user-project: ${project_id}" | grep state | ||
curl -X GET https://generativelanguage.googleapis.com/v1beta/${modelname}?key=$GOOGLE_API_KEY \ | ||
-H 'Content-Type: application/json' | grep state | ||
# [END tuned_models_get] | ||
|
||
echo "[START tuned_models_list]" | ||
|
@@ -142,18 +131,14 @@ jq .tunedModels[].name < tuned_models.json | |
page_token=$(jq .nextPageToken < tuned_models.json | tr -d '"') | ||
|
||
if [[ "$page_token" != "null"" ]]; then | ||
curl -X GET https://generativelanguage.googleapis.com/v1beta/tunedModels?page_size=5\&page_token=${page_token} \ | ||
-H "Content-Type: application/json" \ | ||
-H "Authorization: Bearer ${access_token}" \ | ||
-H "x-goog-user-project: ${project_id}" > tuned_models2.json | ||
curl -X GET https://generativelanguage.googleapis.com/v1beta/tunedModels?page_size=5\&page_token=${page_token}?key=$GOOGLE_API_KEY \ | ||
-H "Content-Type: application/json" > tuned_models2.json | ||
jq .tunedModels[].name < tuned_models.json | ||
fi | ||
# [END tuned_models_list] | ||
|
||
echo "[START tuned_models_delete]" | ||
# [START tuned_models_delete] | ||
curl -X DELETE https://generativelanguage.googleapis.com/v1beta/${modelname} \ | ||
-H 'Content-Type: application/json' \ | ||
-H "Authorization: Bearer ${access_token}" \ | ||
-H "x-goog-user-project: ${project_id}" | ||
curl -X DELETE https://generativelanguage.googleapis.com/v1beta/${modelname}?key=$GOOGLE_API_KEY \ | ||
-H 'Content-Type: application/json' | ||
# [END tuned_models_delete] |
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.
Uh oh!
There was an error while loading. Please reload this page.