Skip to content

Commit

Permalink
Vertex LLM: Remove manual setting of message content to `Function Cal…
Browse files Browse the repository at this point in the history
…ling` (#15586)
  • Loading branch information
punkt2 authored Aug 23, 2024
1 parent 93fc38b commit 46d3c16
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 9 deletions.
7 changes: 0 additions & 7 deletions llama-index-core/llama_index/core/utilities/gemini_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@ def merge_neighboring_same_role_messages(
content="\n".join([str(msg_content) for msg_content in merged_content]),
additional_kwargs=current_message.additional_kwargs,
)
# When making function calling, 'assistant->model' response does not contain text.
# Gemini chat takes 'user', 'model' message alternately.
# https://github.com/GoogleCloudPlatform/generative-ai/blob/main/gemini/getting-started/intro_gemini_chat.ipynb
# It cannot skip empty 'model' content.
# It will cause "empty text parameter" issue, the following code can avoid it.
if merged_message.content == "" and merged_message.role == MessageRole.MODEL:
merged_message.content = "Function Calling"

merged_messages.append(merged_message)
i += 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _convert_gemini_part_to_prompt(part: Union[str, Dict]) -> Part:
raise ValueError("Only text and image_url types are supported!")
return Part.from_image(image)

if message.content == "Function Calling":
if message.content == "" and "tool_calls" in message.additional_kwargs:
tool_calls = message.additional_kwargs["tool_calls"]
parts = [
Part._from_gapic(raw_part=gapic_content_types.Part(function_call=tool_call))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ exclude = ["**/BUILD"]
license = "MIT"
name = "llama-index-llms-vertex"
readme = "README.md"
version = "0.3.2"
version = "0.3.3"

[tool.poetry.dependencies]
python = ">=3.8.1,<4.0"
Expand Down

0 comments on commit 46d3c16

Please sign in to comment.