Documentation says messages is of type: Array(Struct(role: String, content: String))
However, if I don't add a "name" field and populate it with the deployment name, completion.transform(df) crashes because it can't find the "name" field.
Code to reproduce issue
import synapse.ml.cognitive.openai.OpenAIChatCompletion as OpenAIChatCompletion
from synapse.ml.core.platform import find_secret
import pyspark.sql.types as T
but if I do that it fails with cryptic error; "name" (deployment) is needed
msg_works = [
{"role": "system", "content": "You can only answer with 'yes' or 'no'.", "name": deployment_name},
{"role": "assistant", "content": "Can you read this?", "name": deployment_name}
]
msg_fails = [
{"role": "system", "content": "You can only answer with 'yes' or 'no'."},
{"role": "assistant", "content": "Can you read this?"}
]
Hey @EPMSFT :wave:!
Thank you so much for reporting the issue/feature request :rotating_light:.
Someone from SynapseML Team will be looking to triage this issue soon.
We appreciate your patience.
SynapseML version
0.11.2-spark3.3
System information
Describe the problem
Referring to: https://github.com/microsoft/SynapseML/blob/0836e40efd9c48424e91aa10c8aa3fbf0de39f31/cognitive/src/main/scala/com/microsoft/azure/synapse/ml/cognitive/openai/OpenAIChatCompletion.scala#L31
Documentation says messages is of type: Array(Struct(role: String, content: String))
However, if I don't add a "name" field and populate it with the deployment name, completion.transform(df) crashes because it can't find the "name" field.
Code to reproduce issue
import synapse.ml.cognitive.openai.OpenAIChatCompletion as OpenAIChatCompletion from synapse.ml.core.platform import find_secret import pyspark.sql.types as T
key = find_secret(...) deployment_name = "openai-xxx-gpt-4-xxx" service_name = "openai-xxx" user = "xxx"
Documentation says: Array(Struct(role: String, content: String)),
but if I do that it fails with cryptic error; "name" (deployment) is needed
msg_works = [ {"role": "system", "content": "You can only answer with 'yes' or 'no'.", "name": deployment_name}, {"role": "assistant", "content": "Can you read this?", "name": deployment_name} ] msg_fails = [ {"role": "system", "content": "You can only answer with 'yes' or 'no'."}, {"role": "assistant", "content": "Can you read this?"} ]
df = sc.parallelize([[msg_fails]], 1).toDF( T.StructType([ T.StructField("messages", T.ArrayType( T.StructType([ T.StructField("role", T.StringType(), False), T.StructField("content", T.StringType(), False),
T.StructField("name", T.StringType(), False) # add to make it work
)
completion = ( OpenAIChatCompletion() .setSubscriptionKey(key) .setDeploymentName(deployment_name) .setUrl(f"https://{service_name}.openai.azure.com/") .setMessagesCol("messages") .setMaxTokens(100) .setTemperature(0.25) .setFrequencyPenalty(0.0) .setPresencePenalty(0.0) .setUser(user) .setErrorCol("error") .setOutputCol("response") )
response = completion.transform(df) display(response)
Other info / logs
No response
What component(s) does this bug affect?
area/cognitive
: Cognitive projectarea/core
: Core projectarea/deep-learning
: DeepLearning projectarea/lightgbm
: Lightgbm projectarea/opencv
: Opencv projectarea/vw
: VW projectarea/website
: Websitearea/build
: Project build systemarea/notebooks
: Samples under notebooks folderarea/docker
: Docker usagearea/models
: models related issueWhat language(s) does this bug affect?
language/scala
: Scala source codelanguage/python
: Pyspark APIslanguage/r
: R APIslanguage/csharp
: .NET APIslanguage/new
: Proposals for new client languagesWhat integration(s) does this bug affect?
integrations/synapse
: Azure Synapse integrationsintegrations/azureml
: Azure ML integrationsintegrations/databricks
: Databricks integrations