|
45 | 45 | from vertexai.language_models import (
|
46 | 46 | _language_models as tunable_models,
|
47 | 47 | )
|
| 48 | +from google.protobuf import json_format |
48 | 49 | import warnings
|
49 | 50 |
|
50 | 51 | try:
|
@@ -1377,9 +1378,8 @@ def _from_gapic(
|
1377 | 1378 |
|
1378 | 1379 | @classmethod
|
1379 | 1380 | def from_dict(cls, response_dict: Dict[str, Any]) -> "GenerationResponse":
|
1380 |
| - raw_response = gapic_prediction_service_types.GenerateContentResponse( |
1381 |
| - response_dict |
1382 |
| - ) |
| 1381 | + raw_response = gapic_prediction_service_types.GenerateContentResponse() |
| 1382 | + json_format.ParseDict(response_dict, raw_response._pb) |
1383 | 1383 | return cls._from_gapic(raw_response=raw_response)
|
1384 | 1384 |
|
1385 | 1385 | def to_dict(self) -> Dict[str, Any]:
|
@@ -1418,7 +1418,8 @@ def _from_gapic(cls, raw_candidate: gapic_content_types.Candidate) -> "Candidate
|
1418 | 1418 |
|
1419 | 1419 | @classmethod
|
1420 | 1420 | def from_dict(cls, candidate_dict: Dict[str, Any]) -> "Candidate":
|
1421 |
| - raw_candidate = gapic_content_types.Candidate(candidate_dict) |
| 1421 | + raw_candidate = gapic_content_types.Candidate() |
| 1422 | + json_format.ParseDict(candidate_dict, raw_candidate._pb) |
1422 | 1423 | return cls._from_gapic(raw_candidate=raw_candidate)
|
1423 | 1424 |
|
1424 | 1425 | def to_dict(self) -> Dict[str, Any]:
|
@@ -1497,7 +1498,8 @@ def _from_gapic(cls, raw_content: gapic_content_types.Content) -> "Content":
|
1497 | 1498 |
|
1498 | 1499 | @classmethod
|
1499 | 1500 | def from_dict(cls, content_dict: Dict[str, Any]) -> "Content":
|
1500 |
| - raw_content = gapic_content_types.Content(content_dict) |
| 1501 | + raw_content = gapic_content_types.Content() |
| 1502 | + json_format.ParseDict(content_dict, raw_content._pb) |
1501 | 1503 | return cls._from_gapic(raw_content=raw_content)
|
1502 | 1504 |
|
1503 | 1505 | def to_dict(self) -> Dict[str, Any]:
|
@@ -1563,7 +1565,8 @@ def _from_gapic(cls, raw_part: gapic_content_types.Part) -> "Part":
|
1563 | 1565 |
|
1564 | 1566 | @classmethod
|
1565 | 1567 | def from_dict(cls, part_dict: Dict[str, Any]) -> "Part":
|
1566 |
| - raw_part = gapic_content_types.Part(part_dict) |
| 1568 | + raw_part = gapic_content_types.Part() |
| 1569 | + json_format.ParseDict(part_dict, raw_part._pb) |
1567 | 1570 | return cls._from_gapic(raw_part=raw_part)
|
1568 | 1571 |
|
1569 | 1572 | def __repr__(self):
|
|
0 commit comments