Skip to content

[BUG] Fabric python docs code doesn't run #2563

@jxu

Description

@jxu

SynapseML version

1.1.1

System information

  • Language version (e.g. python 3.8, scala 2.12):
  • Spark Version (e.g. 3.2.3): 3.5
  • Spark Platform (e.g. Synapse, Databricks): Fabric runtime 1.3

Describe the problem

Error running the provided example code due to setPromptCol

Code to reproduce issue

https://learn.microsoft.com/en-us/fabric/data-science/ai-services/how-to-use-openai-synapse-ml

from synapse.ml.services.openai import OpenAIPrompt

# Create a DataFrame with prompts
df = spark.createDataFrame([
    ("Explain quantum computing in simple terms.",),
    ("What are the benefits of exercise?",),
    ("Describe the water cycle.",)
]).toDF("prompt")

# Configure OpenAIPrompt with chat_completions API
prompt_completion = (
    OpenAIPrompt()
    .setDeploymentName("gpt-4.1")
    .setApiType("chat_completions")  # Accepts "chat_completions" or "responses"
    .setPromptCol("prompt")
    .setUsageCol("usage")  # Track token usage
    .setOutputCol("completions")
)

# Transform and display results
display(prompt_completion.transform(df).select("prompt", "completions", "usage"))

Other info / logs

'OpenAIPrompt' object has no attribute 'setPromptCol'

What component(s) does this bug affect?

  • area/cognitive: Cognitive project
  • area/core: Core project
  • area/deep-learning: DeepLearning project
  • area/lightgbm: Lightgbm project
  • area/opencv: Opencv project
  • area/vw: VW project
  • area/website: Website
  • area/build: Project build system
  • area/notebooks: Samples under notebooks folder
  • area/docker: Docker usage
  • area/models: models related issue

What language(s) does this bug affect?

  • language/scala: Scala source code
  • language/python: Pyspark APIs
  • language/r: R APIs
  • language/csharp: .NET APIs
  • language/new: Proposals for new client languages

What integration(s) does this bug affect?

  • integrations/synapse: Azure Synapse integrations
  • integrations/azureml: Azure ML integrations
  • integrations/databricks: Databricks integrations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions