PromptDesk Logo

Python

Classification - Python SDK

Classification

PromptDesk facilitates the output of classification LLM models.

By default, the LLM classifies generated strings 'yes' and 'true' as True, and 'no' and 'false' as False. LLM output is case-insensitive.

text = "I am happy"

isHappy = pd.generate("is-happy", {
    "text": text
})

print(isHappy)

Custom Classification

We can assign generated output to custom classes.

text = "I am happy"

isHappy = pd.generate("is_positive", {
    "text": text
}, classification={
    True: ["positive", "happy"],
    False: ["negative", "sad"],
    None: ["neutral"]
})

print(isHappy)

We can assign generated output to string-based classes.

text = "I am happy"

isHappy = pd.generate("is_positive", {
    "text": text
}, classification={
    "positive": ["positive", "happy"],
    "negative": ["negative", "sad"],
    "neutral": ["neutral"]
})

print(isHappy)
Previous
Variables