Skip to content

Commit 55d4fce

Browse files
committed
fix imports
1 parent 1e9984e commit 55d4fce

File tree

5 files changed

+27
-9
lines changed

5 files changed

+27
-9
lines changed

google/generativeai/types/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
from google.generativeai.types.discuss_types import *
1818
from google.generativeai.types.model_types import *
1919
from google.generativeai.types.text_types import *
20+
from google.generativeai.types.citation_types import *
21+
from google.generativeai.types.safety_types import *
2022

2123
del discuss_types
2224
del model_types
25+
del text_types
26+
del citation_types
27+
del safety_types

google/generativeai/types/citation_types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15+
from typing import Optional, List
1516

1617
from google.ai import generativelanguage as glm
1718
from google.generativeai import docstring_utils

google/generativeai/types/discuss_types.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import google.ai.generativelanguage as glm
2222
from google.generativeai.types import safety_types
23+
from google.generativeai.types import citation_types
2324

2425
__all__ = [
2526
"MessageDict",
@@ -155,17 +156,17 @@ class ChatResponse(abc.ABC):
155156
model: str
156157
context: str
157158
examples: List[ExampleDict]
158-
messages: List[MessageDict]
159+
messages: List[Optional[MessageDict]]
159160
temperature: Optional[float]
160161
candidate_count: Optional[int]
161162
candidates: List[MessageDict]
162163
top_p: Optional[float] = None
163164
top_k: Optional[float] = None
164-
filters: List[safety.ContentFilter]
165+
filters: List[safety_types.ContentFilter]
165166

166167
@property
167168
@abc.abstractmethod
168-
def last(self) -> str:
169+
def last(self) -> Optional[str]:
169170
"""A settable property that provides simple access to the last response string
170171
171172
A shortcut for `response.messages[0]['content']`.

google/generativeai/types/safety_types.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import enum
1717
from google.ai import generativelanguage as glm
18+
from google.generativeai import docstring_utils
1819
from typing import TypedDict
1920

2021
__all__ = [
@@ -31,7 +32,7 @@
3132
# These are basic python enums, it's okay to expose them
3233
HarmCategory = glm.HarmCategory
3334
HarmProbability = glm.SafetyRating.HarmProbability
34-
HarmBlockThreshold = glm.SafetySetting
35+
HarmBlockThreshold = glm.SafetySetting.HarmBlockThreshold
3536
BlockReason = glm.ContentFilter.BlockedReason
3637

3738

google/generativeai/types/text_types.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,38 @@
1717
import dataclasses
1818
from typing import Any, Dict, Optional, List, Iterator, TypedDict
1919

20-
__all__ = ["Completion"]
20+
from google.generativeai.types import safety_types
21+
from google.generativeai.types import citation_types
2122

2223

23-
class TextCandidate(TypedDict, total=False):
24+
__all__ = ["TextResponse"]
25+
26+
27+
class TextCompletion(TypedDict, total=False):
2428
output: str
29+
safety_ratings: Optional[List[safety_types.SafetyRatingDict]]
30+
citation_metadata: Optional[citation_types.CitationMetadataDict]
2531

2632

2733
@dataclasses.dataclass(init=False)
28-
class Completion(abc.ABC):
34+
class TextResponse(abc.ABC):
2935
"""A text completion given a prompt from the model.
3036
31-
* Use `completion.candidates` to access all of the text completion options generated by the model.
37+
Use `GenerateTextResponse.candidates` to access all the completions generated by the model.
3238
3339
Attributes:
3440
candidates: A list of candidate text completions generated by the model.
3541
"""
3642

37-
candidates: List[TextCandidate]
43+
candidates: List[TextCompletion]
3844
result: Optional[str]
45+
filters: Optional[list[safety_types.ContentFilter]]
46+
safety_feedback: Optional[list[safety_types.SafetyFeedbackDict]]
3947

4048
def to_dict(self) -> Dict[str, Any]:
4149
result = {
4250
"candidates": self.candidates,
51+
"filters": self.filters,
52+
"safety_feedback": self.safety_feedback,
4353
}
4454
return result

0 commit comments

Comments
 (0)