Skip to content

Commit

Permalink
Merge branch 'hfapi-tools' into fix-hflocalchat-msg-conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
anakin87 committed Dec 19, 2024
2 parents 0aad128 + 6832e31 commit 3f0746f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions haystack/components/generators/chat/hugging_face_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,15 @@ def _run_non_streaming(
)
tool_calls.append(tool_call)

meta = {
"model": self._client.model,
"finish_reason": choice.finish_reason,
"index": choice.index,
"usage": {
meta = {"model": self._client.model, "finish_reason": choice.finish_reason, "index": choice.index}

usage = {"prompt_tokens": 0, "completion_tokens": 0}
if api_chat_output.usage:
usage = {
"prompt_tokens": api_chat_output.usage.prompt_tokens,
"completion_tokens": api_chat_output.usage.completion_tokens,
},
}
}
meta["usage"] = usage

message = ChatMessage.from_assistant(text=text, tool_calls=tool_calls, meta=meta)
return {"replies": [message]}
2 changes: 1 addition & 1 deletion haystack/dataclasses/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def _remove_title_from_schema(schema: Dict[str, Any]):

def _check_duplicate_tool_names(tools: List[Tool]) -> None:
"""
Check for duplicate tool names.
Check for duplicate tool names and raises a ValueError if they are found.
:param tools: The list of tools to check.
:raises ValueError: If duplicate tool names are found.
Expand Down

0 comments on commit 3f0746f

Please sign in to comment.