Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/palm/python/DELETEME

This file was deleted.

26 changes: 26 additions & 0 deletions examples/palm/python/permissions/sharing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Sample functions illustrating how to share models using the permission service."""
import google.generativeai as palm
import google.ai.generativelanguage as glm
from google.ai.generativelanguage_v1beta3 import types
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still correct with the latest SDK updates?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be necessary. the current default (v1beta) is a superset of this old one so glm is all you need.


client_config = {
# Add any client config here, e.g. credentials=... for service accounts.
}
perm_client = glm.PermissionServiceClient(**client_config)

# Listing existing permissions on a tuned model.
model_name = 'tunedModels/...'
list_response = perm_client.list_permissions(parent=model_name)
print(list_response)

# Sharing a model with another user (e.g. service account), or "adding a permission"
new_user = "[email protected]"
perm = types.Permission(
grantee_type=types.Permission.GranteeType.USER,
role=types.Permission.Role.READER,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

email_address=new_user,
)

model_name = 'tunedModels/...'
new_perm_response = perm_client.create_permission(permission=perm, parent=model_name)
print(new_perm_response)
Loading