mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-27 09:08:14 +00:00
Merge branch 'lorenze/imp/native-tool-calling' into gl/feat/native-multimodal-files
This commit is contained in:
@@ -753,7 +753,7 @@ class GeminiCompletion(BaseLLM):
|
|||||||
if result is not None:
|
if result is not None:
|
||||||
return result
|
return result
|
||||||
|
|
||||||
content = response.text or ""
|
content = self._extract_text_from_response(response)
|
||||||
content = self._apply_stop_words(content)
|
content = self._apply_stop_words(content)
|
||||||
|
|
||||||
return self._finalize_completion_response(
|
return self._finalize_completion_response(
|
||||||
@@ -1136,6 +1136,35 @@ class GeminiCompletion(BaseLLM):
|
|||||||
}
|
}
|
||||||
return {"total_tokens": 0}
|
return {"total_tokens": 0}
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _extract_text_from_response(response: GenerateContentResponse) -> str:
|
||||||
|
"""Extract text content from Gemini response without triggering warnings.
|
||||||
|
|
||||||
|
This method directly accesses the response parts to extract text content,
|
||||||
|
avoiding the warning that occurs when using response.text on responses
|
||||||
|
containing non-text parts (e.g., 'thought_signature' from thinking models).
|
||||||
|
|
||||||
|
Args:
|
||||||
|
response: The Gemini API response
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Concatenated text content from all text parts
|
||||||
|
"""
|
||||||
|
if not response.candidates:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
candidate = response.candidates[0]
|
||||||
|
if not candidate.content or not candidate.content.parts:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
text_parts = [
|
||||||
|
part.text
|
||||||
|
for part in candidate.content.parts
|
||||||
|
if hasattr(part, "text") and part.text
|
||||||
|
]
|
||||||
|
|
||||||
|
return "".join(text_parts)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _convert_contents_to_dict(
|
def _convert_contents_to_dict(
|
||||||
contents: list[types.Content],
|
contents: list[types.Content],
|
||||||
|
|||||||
Reference in New Issue
Block a user