Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't include tool calls if there was none #16408

Merged
merged 3 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,23 @@ jobs:
CHANGED_FILES=$(pants list --changed-since=origin/main)

# Find which roots contain changed files
CHANGED_ROOTS=""
FILTER_PATTERNS="["
for file in $CHANGED_FILES; do
root=$(echo "$file" | cut -d'/' -f1,2,3)
if [[ ! "$FILTER_PATTERNS" =~ "$root" ]]; then
FILTER_PATTERNS="${FILTER_PATTERNS}'${root}',"
CHANGED_ROOTS="${CHANGED_ROOTS} ${root}/::"
fi
done

# remove the last comma and close the bracket
FILTER_PATTERNS="${FILTER_PATTERNS%,}]"

echo "Coverage filter patterns: $FILTER_PATTERNS"
echo "Changed roots: $CHANGED_ROOTS"

pants --level=error --no-local-cache test \
pants --no-local-cache test \
--test-use-coverage \
--changed-since=origin/main \
--coverage-py-filter="$FILTER_PATTERNS"
--coverage-py-filter="${FILTER_PATTERNS}" \
${CHANGED_ROOTS}
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,8 @@ def gen() -> ChatResponseGen:
additional_kwargs = {}
if is_function:
tool_calls = update_tool_calls(tool_calls, delta.tool_calls)
additional_kwargs["tool_calls"] = tool_calls
if tool_calls:
additional_kwargs["tool_calls"] = tool_calls

yield ChatResponse(
message=ChatMessage(
Expand Down Expand Up @@ -738,7 +739,8 @@ async def gen() -> ChatResponseAsyncGen:
additional_kwargs = {}
if is_function:
tool_calls = update_tool_calls(tool_calls, delta.tool_calls)
additional_kwargs["tool_calls"] = tool_calls
if tool_calls:
additional_kwargs["tool_calls"] = tool_calls

yield ChatResponse(
message=ChatMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def from_openai_message(openai_message: ChatCompletionMessage) -> ChatMessage:
# function_call = None # deprecated in OpenAI v 1.1.0

additional_kwargs: Dict[str, Any] = {}
if openai_message.tool_calls is not None:
if openai_message.tool_calls:
tool_calls: List[ChatCompletionMessageToolCall] = openai_message.tool_calls
additional_kwargs.update(tool_calls=tool_calls)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ exclude = ["**/BUILD"]
license = "MIT"
name = "llama-index-llms-openai"
readme = "README.md"
version = "0.2.11"
version = "0.2.12"

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