Skip to content

Commit

Permalink
chore(generative_ai): cleanup unused sample (#12015)
Browse files Browse the repository at this point in the history
  • Loading branch information
msampathkumar authored Jul 10, 2024
1 parent a50e316 commit cd0a78e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ def test_config_response_schema4() -> None:
assert response


def test_config_response_schema5() -> None:
response = response_schema.generate_content5(PROJECT_ID)
assert response


def test_config_response_schema6() -> None:
response = response_schema.generate_content6(PROJECT_ID)
assert response
74 changes: 0 additions & 74 deletions generative_ai/controlled_generation/response_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,80 +221,6 @@ def generate_content4(project_id: str) -> str:
return response.text


def generate_content5(project_id: str) -> str:
# [START generativeaionvertexai_gemini_controlled_generation_response_schema_5]
import vertexai

from vertexai.generative_models import GenerationConfig, GenerativeModel

# TODO(developer): Update and un-comment below line
# project_id = "PROJECT_ID"
vertexai.init(project=project_id, location="us-central1")

response_schema = {
"type": "ARRAY",
"items": {
"type": "OBJECT",
"properties": {
"Announcement_Date": {"type": "STRING", "nullable": 1},
"Author(s)": {
"type": "ARRAY",
"nullable": 1,
"items": {"type": "STRING"},
},
"Journal_Ref": {"type": "STRING", "nullable": 1},
"Keyword(s)": {
"type": "ARRAY",
"nullable": 1,
"items": {"type": "STRING"},
},
"Subject(s)": {
"type": "ARRAY",
"nullable": 1,
"items": {"type": "STRING"},
},
"Submission_Date": {"type": "STRING", "nullable": 1},
"Title": {"type": "STRING", "nullable": 1},
"Version": {
"type": "STRING",
"nullable": 1,
"enum": [
"Dungeons & Dragons",
"Duel Masters",
"G.I. Joe",
"Jem and The Holograms",
"Littlest Pet Shop",
"Magic: The Gathering",
"Monopoly",
"My Little Pony",
"Nerf",
],
},
},
},
}

prompt = """
Cymbal stock slid 5.2% following a double-downgrade to “underperform” from “buy” at Bank of Anthos.
Bank of Anthos conducted a “deep dive” on trading card game. Bank of Anthos said Cymbal has been
overprinting cards and destroying the long-term value of the business.
"""

model = GenerativeModel("gemini-1.5-pro-001")

response = model.generate_content(
prompt,
generation_config=GenerationConfig(
response_mime_type="application/json", response_schema=response_schema
),
)

print(response.text)
# [END generativeaionvertexai_gemini_controlled_generation_response_schema_5]

return response.text


def generate_content6(project_id: str) -> str:
# [START generativeaionvertexai_gemini_controlled_generation_response_schema_6]
import vertexai
Expand Down

0 comments on commit cd0a78e

Please sign in to comment.