# Initialize the outputs list
outputs = []
# Iterate through each row in the DataFrame
for _, row in df.iterrows():
# Extract the 'instruction' and 'input' columns for each row
instruction = row["instruction"]
table = row["input"]
# Invoke the deployment for each row
generation = client.deployments.invoke(
key="text_to_SQL", # Replace with your actual deployment key
context={
"environments": []
},
inputs={
"table": table,
"instruction": instruction
},
metadata={
"custom-field-name": "custom-metadata-value"
}
)
# Append the model's output to the outputs list
outputs.append(generation.choices[0].message.content)
# Add the outputs as a new column in the DataFrame
df["output"] = outputs