Skip to content
Merged
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
22 changes: 11 additions & 11 deletions src/snowflake/snowpark/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13062,7 +13062,7 @@ def ai_extract(
... col("text"),
... ai_extract(col("text"), [['name', 'What is the first name?'], ['city', 'What city do they work in?']]).alias("info")
... )
>>> extracted_df.show()
>>> extracted_df.sort(col("text")).show()
------------------------------------------------------------
|"TEXT" |"INFO" |
------------------------------------------------------------
Expand Down Expand Up @@ -13261,7 +13261,7 @@ def ai_filter(
... ai_filter(prompt("Is {0} in Europe?", col("country"))).as_("europe"),
... ai_filter(prompt("Is {0} in North America?", col("country"))).as_("north_america"),
... ai_filter(prompt("Is {0} in Central America?", col("country"))).as_("central_america"),
... ).show()
... ).sort("asia").show()
-----------------------------------------------------------
|"ASIA" |"EUROPE" |"NORTH_AMERICA" |"CENTRAL_AMERICA" |
-----------------------------------------------------------
Expand Down Expand Up @@ -14279,47 +14279,47 @@ def ai_sentiment(
... ["The food was delicious but the service was slow."],
... ["The movie was great, but the acting was terrible."]
... ], schema=["review"])
>>> df.select("review", ai_sentiment(col("review"), ['plot', 'visual effects', 'acting']).alias("sentiment")).show()
>>> df.select("review", ai_sentiment(col("review"), ['plot', 'visual effects', 'acting']).alias("sentiment")).sort("review").show()
----------------------------------------------------------------------------------------
|"REVIEW" |"SENTIMENT" |
----------------------------------------------------------------------------------------
|The movie had amazing visual effects but the pl... |{ |
|The food was delicious but the service was slow. |{ |
| | "categories": [ |
| | { |
| | "name": "overall", |
| | "sentiment": "mixed" |
| | }, |
| | { |
| | "name": "acting", |
| | "sentiment": "neutral" |
| | "sentiment": "unknown" |
| | }, |
| | { |
| | "name": "plot", |
| | "sentiment": "negative" |
| | "sentiment": "unknown" |
| | }, |
| | { |
| | "name": "visual effects", |
| | "sentiment": "positive" |
| | "sentiment": "unknown" |
| | } |
| | ] |
| |} |
|The food was delicious but the service was slow. |{ |
|The movie had amazing visual effects but the pl... |{ |
| | "categories": [ |
| | { |
| | "name": "overall", |
| | "sentiment": "mixed" |
| | }, |
| | { |
| | "name": "acting", |
| | "sentiment": "unknown" |
| | "sentiment": "neutral" |
| | }, |
| | { |
| | "name": "plot", |
| | "sentiment": "unknown" |
| | "sentiment": "negative" |
| | }, |
| | { |
| | "name": "visual effects", |
| | "sentiment": "unknown" |
| | "sentiment": "positive" |
| | } |
| | ] |
| |} |
Expand Down
Loading