Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 050a57b

Browse filesBrowse files
bug fix: fix the function call for Gen AI samples (GoogleCloudPlatform#11259)
* bug fix: fix the function call `interview` method call is missing inputs. * bug fix: update test cases update a test case to be more generic * chore: update the region tags region tags do not need to show how to execution * chore: update the test case Added a new issues to investigate `evaluate_model` 404 issue
1 parent a585e56 commit 050a57b
Copy full SHA for 050a57b
Expand file treeCollapse file tree

25 files changed

+35
-26
lines changed

‎generative_ai/chat.py

Copy file name to clipboardExpand all lines: generative_ai/chat.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ def science_tutoring(temperature: float = 0.2) -> None:
4545
return response
4646

4747

48+
# [END aiplatform_sdk_chat]
4849
if __name__ == "__main__":
4950
science_tutoring()
50-
# [END aiplatform_sdk_chat]

‎generative_ai/classify_news_items.py

Copy file name to clipboardExpand all lines: generative_ai/classify_news_items.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ def classify_news_items(temperature: float = 0.2) -> None:
6262
return response
6363

6464

65+
# [END aiplatform_sdk_classify_news_items]
6566
if __name__ == "__main__":
6667
classify_news_items()
67-
# [END aiplatform_sdk_classify_news_items]

‎generative_ai/classify_news_items_test.py

Copy file name to clipboardExpand all lines: generative_ai/classify_news_items_test.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
@backoff.on_exception(backoff.expo, ResourceExhausted, max_time=10)
2222
def test_classify_news_items() -> None:
2323
content = classify_news_items.classify_news_items(temperature=0).text
24-
assert content == "business"
24+
assert "business" in content

‎generative_ai/code_chat.py

Copy file name to clipboardExpand all lines: generative_ai/code_chat.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ def write_a_function(temperature: float = 0.5) -> object:
3636
return response
3737

3838

39+
# [END aiplatform_sdk_code_chat]
3940
if __name__ == "__main__":
4041
write_a_function()
41-
# [END aiplatform_sdk_code_chat]

‎generative_ai/code_completion_function.py

Copy file name to clipboardExpand all lines: generative_ai/code_completion_function.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ def complete_code_function(temperature: float = 0.2) -> object:
3535
return response
3636

3737

38+
# [END aiplatform_sdk_code_completion_comment]
3839
if __name__ == "__main__":
3940
complete_code_function()
40-
# [END aiplatform_sdk_code_completion_comment]

‎generative_ai/code_completion_test_function.py

Copy file name to clipboardExpand all lines: generative_ai/code_completion_test_function.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ def test_empty_input_string()""",
3838
return response
3939

4040

41+
# [END aiplatform_sdk_code_completion_test_function]
4142
if __name__ == "__main__":
4243
complete_test_function()
43-
# [END aiplatform_sdk_code_completion_test_function]

‎generative_ai/code_generation_function.py

Copy file name to clipboardExpand all lines: generative_ai/code_generation_function.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ def generate_a_function(temperature: float = 0.5) -> object:
3535
return response
3636

3737

38+
# [END aiplatform_sdk_code_generation_function]
3839
if __name__ == "__main__":
3940
generate_a_function()
40-
# [END aiplatform_sdk_code_generation_function]

‎generative_ai/distillation.py

Copy file name to clipboardExpand all lines: generative_ai/distillation.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ def distill_model(
6161
return distillation_job
6262

6363

64+
# [END aiplatform_sdk_distillation]
6465
if __name__ == "__main__":
6566
distill_model()
66-
# [END aiplatform_sdk_distillation]

‎generative_ai/embedding.py

Copy file name to clipboardExpand all lines: generative_ai/embedding.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ def text_embedding() -> list:
2626
return vector
2727

2828

29+
# [END aiplatform_sdk_embedding]
2930
if __name__ == "__main__":
3031
text_embedding()
31-
# [END aiplatform_sdk_embedding]

‎generative_ai/evaluate_model.py

Copy file name to clipboardExpand all lines: generative_ai/evaluate_model.py
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,5 @@ def evaluate_model(
5353

5454

5555
# [END aiplatform_evaluate_model]
56-
57-
5856
if __name__ == "__main__":
5957
evaluate_model()

‎generative_ai/evaluate_model_test.py

Copy file name to clipboardExpand all lines: generative_ai/evaluate_model_test.py
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,23 @@
1515
import os
1616

1717
import backoff
18+
1819
from google.api_core.exceptions import ResourceExhausted
1920

21+
import pytest
22+
2023
import evaluate_model
2124

2225

2326
_PROJECT_ID = os.getenv("GOOGLE_CLOUD_PROJECT")
2427
_LOCATION = "us-central1"
2528

2629

30+
@pytest.mark.skip(
31+
reason="Model is giving 404 Not found error."
32+
"Need to investigate. Created an issue tracker is at "
33+
"python-docs-samples/issues/11264"
34+
)
2735
@backoff.on_exception(backoff.expo, ResourceExhausted, max_time=10)
2836
def test_evaluate_model() -> None:
2937
eval_metrics = evaluate_model.evaluate_model(

‎generative_ai/extraction.py

Copy file name to clipboardExpand all lines: generative_ai/extraction.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,6 @@ def extractive_question_answering(
7777
return response.text
7878

7979

80+
# [END aiplatform_sdk_extraction]
8081
if __name__ == "__main__":
8182
extractive_question_answering()
82-
# [END aiplatform_sdk_extraction]

‎generative_ai/extraction_test.py

Copy file name to clipboardExpand all lines: generative_ai/extraction_test.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ def test_extractive_question_answering() -> None:
2929
content = extraction.extractive_question_answering(
3030
temperature=0, project_id=_PROJECT_ID, location=_LOCATION
3131
)
32-
assert content == "Reduced moist tropical vegetation cover in the basin."
32+
assert content.strip() == "Reduced moist tropical vegetation cover in the basin."

‎generative_ai/ideation.py

Copy file name to clipboardExpand all lines: generative_ai/ideation.py
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,4 @@ def interview(
4343
return response.text
4444

4545

46-
if __name__ == "__main__":
47-
interview()
4846
# [END aiplatform_sdk_ideation]

‎generative_ai/ideation_test.py

Copy file name to clipboardExpand all lines: generative_ai/ideation_test.py
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
_LOCATION = "us-central1"
2525

2626

27+
# example model response
2728
interview_expected_response = """1. What is your experience with project management?
2829
2. What is your process for managing a project?
2930
3. How do you handle unexpected challenges or roadblocks?
@@ -41,4 +42,8 @@ def test_interview() -> None:
4142
content = ideation.interview(
4243
temperature=0, project_id=_PROJECT_ID, location=_LOCATION
4344
)
44-
assert content == interview_expected_response
45+
# check if response is empty
46+
assert len(content) > 0
47+
# check if response has 10 points
48+
for i in range(1, 11):
49+
assert str(i) in content

‎generative_ai/list_tuned_code_generation_models.py

Copy file name to clipboardExpand all lines: generative_ai/list_tuned_code_generation_models.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ def list_tuned_code_generation_models(
3131
return tuned_model_names
3232

3333

34+
# [END aiplatform_sdk_list_tuned_code_generation_models]
3435
if __name__ == "__main__":
3536
list_tuned_code_generation_models()
36-
# [END aiplatform_sdk_list_tuned_code_generation_models]

‎generative_ai/list_tuned_models.py

Copy file name to clipboardExpand all lines: generative_ai/list_tuned_models.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ def list_tuned_models(
3232
return tuned_model_names
3333

3434

35+
# [END aiplatform_sdk_list_tuned_models]
3536
if __name__ == "__main__":
3637
list_tuned_models()
37-
# [END aiplatform_sdk_list_tuned_models]

‎generative_ai/sentiment_analysis.py

Copy file name to clipboardExpand all lines: generative_ai/sentiment_analysis.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,6 @@ def sentiment_analysis(
7979
return response.text
8080

8181

82+
# [END aiplatform_sdk_sentiment_analysis]
8283
if __name__ == "__main__":
8384
sentiment_analysis()
84-
# [END aiplatform_sdk_sentiment_analysis]

‎generative_ai/streaming_chat.py

Copy file name to clipboardExpand all lines: generative_ai/streaming_chat.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ def streaming_prediction(
6363
return results
6464

6565

66+
# [END aiplatform_streaming_chat]
6667
if __name__ == "__main__":
6768
streaming_prediction()
68-
# [END aiplatform_streaming_chat]

‎generative_ai/streaming_code.py

Copy file name to clipboardExpand all lines: generative_ai/streaming_code.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ def streaming_prediction(
4848
return results
4949

5050

51+
# [END aiplatform_streaming_code]
5152
if __name__ == "__main__":
5253
streaming_prediction()
53-
# [END aiplatform_streaming_code]

‎generative_ai/streaming_codechat.py

Copy file name to clipboardExpand all lines: generative_ai/streaming_codechat.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ def streaming_prediction(
4747
return results
4848

4949

50+
# [END aiplatform_streaming_codechat]
5051
if __name__ == "__main__":
5152
streaming_prediction()
52-
# [END aiplatform_streaming_codechat]

‎generative_ai/streaming_text.py

Copy file name to clipboardExpand all lines: generative_ai/streaming_text.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ def streaming_prediction(
5454
return results
5555

5656

57+
# [END aiplatform_streaming_text]
5758
if __name__ == "__main__":
5859
streaming_prediction()
59-
# [END aiplatform_streaming_text]

‎generative_ai/summarization.py

Copy file name to clipboardExpand all lines: generative_ai/summarization.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,6 @@ def text_summarization(
7373
return response.text
7474

7575

76+
# [END aiplatform_sdk_summarization]
7677
if __name__ == "__main__":
7778
text_summarization()
78-
# [END aiplatform_sdk_summarization]

‎generative_ai/tune_code_generation_model.py

Copy file name to clipboardExpand all lines: generative_ai/tune_code_generation_model.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,6 @@ def tune_code_generation_model(
8181
return model
8282

8383

84+
# [END aiplatform_sdk_tune_code_generation_model]
8485
if __name__ == "__main__":
8586
tune_code_generation_model()
86-
# [END aiplatform_sdk_tune_code_generation_model]

‎generative_ai/tuning.py

Copy file name to clipboardExpand all lines: generative_ai/tuning.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,6 @@ def tuning(
8686
return model
8787

8888

89+
# [END aiplatform_sdk_tuning]
8990
if __name__ == "__main__":
9091
tuning()
91-
# [END aiplatform_sdk_tuning]

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.