diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 9ac0bff8c26d9..873a8fad1e1e2 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -52,11 +52,13 @@ 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 @@ -64,8 +66,9 @@ jobs: 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} diff --git a/llama-index-integrations/llms/llama-index-llms-openai/llama_index/llms/openai/base.py b/llama-index-integrations/llms/llama-index-llms-openai/llama_index/llms/openai/base.py index d1a8bcf92aa13..3bf3b2b1d50f8 100644 --- a/llama-index-integrations/llms/llama-index-llms-openai/llama_index/llms/openai/base.py +++ b/llama-index-integrations/llms/llama-index-llms-openai/llama_index/llms/openai/base.py @@ -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( @@ -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( diff --git a/llama-index-integrations/llms/llama-index-llms-openai/llama_index/llms/openai/utils.py b/llama-index-integrations/llms/llama-index-llms-openai/llama_index/llms/openai/utils.py index a076a9ffc6014..f43e8f4180d0a 100644 --- a/llama-index-integrations/llms/llama-index-llms-openai/llama_index/llms/openai/utils.py +++ b/llama-index-integrations/llms/llama-index-llms-openai/llama_index/llms/openai/utils.py @@ -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) diff --git a/llama-index-integrations/llms/llama-index-llms-openai/pyproject.toml b/llama-index-integrations/llms/llama-index-llms-openai/pyproject.toml index d207e8437a53f..ccba47ea29e4f 100644 --- a/llama-index-integrations/llms/llama-index-llms-openai/pyproject.toml +++ b/llama-index-integrations/llms/llama-index-llms-openai/pyproject.toml @@ -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"