feat(snowflake): add function calling support for Snowflake Cortex REST API #15221
+573
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds function calling (tools) support for Snowflake Cortex REST API, enabling tool use with models like Claude 3.5 Sonnet.
Changes
Implementation (
litellm/llms/snowflake/chat/transformation.py
)tools
andtool_choice
to supported OpenAI parameterstool_spec
formatcontent_list
→ OpenAItool_calls
tool_choice
transformation to Snowflake's array formatTesting
tests/test_litellm/llms/snowflake/chat/test_snowflake_chat_transformation.py
)tests/llm_translation/test_snowflake.py
)Technical Details
Request Transformations
Tools:
OpenAI format → Snowflake tool_spec
Tool Choice:
OpenAI nested → Snowflake array
Response Transformations
Parses Snowflake's unique format:
Converts to OpenAI format:
Verification
Tested with real Snowflake Cortex API (account: XXXXXX):
tool_choice
(forced tool use)completion()
andresponses()
APIsExample output:
Context
Test Plan
Unit tests (run automatically in CI):
Integration test (requires Snowflake credentials - marked as skip):
Breaking Changes
None - This is purely additive functionality.
🤖 Generated with Claude Code