Initial commit
This commit is contained in:
20
templates/classification/README.md
Normal file
20
templates/classification/README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Classification Templates
|
||||
|
||||
Templates for classification patterns (sentiment, intent, category, etc.)
|
||||
|
||||
## Pattern Structure
|
||||
|
||||
Each classification template includes:
|
||||
- Input types (usually text)
|
||||
- Enum definitions for categories
|
||||
- Classification function with confidence
|
||||
- Reasoning capture
|
||||
- Example test cases
|
||||
|
||||
## Common Use Cases
|
||||
|
||||
- Sentiment analysis
|
||||
- Intent detection
|
||||
- Category assignment
|
||||
- Priority classification
|
||||
- Topic identification
|
||||
35
templates/classification/sentiment_classification.baml
Normal file
35
templates/classification/sentiment_classification.baml
Normal file
@@ -0,0 +1,35 @@
|
||||
// Example: Sentiment Classification Pattern
|
||||
|
||||
enum Sentiment {
|
||||
Positive @description("Positive sentiment")
|
||||
Negative @description("Negative sentiment")
|
||||
Neutral @description("Neutral sentiment")
|
||||
}
|
||||
|
||||
class SentimentResult {
|
||||
sentiment Sentiment
|
||||
confidence float @description("Confidence score 0-1")
|
||||
reasoning string @description("Explanation for classification")
|
||||
}
|
||||
|
||||
client FastModel {
|
||||
provider "openai"
|
||||
options {
|
||||
model "gpt-4o-mini"
|
||||
temperature 0.1
|
||||
}
|
||||
}
|
||||
|
||||
function ClassifySentiment(text: string) -> SentimentResult {
|
||||
client FastModel
|
||||
|
||||
prompt #"
|
||||
Classify the sentiment of the following text:
|
||||
|
||||
{{ text }}
|
||||
|
||||
Provide confidence score and reasoning.
|
||||
|
||||
{{ ctx.output_format }}
|
||||
"#
|
||||
}
|
||||
Reference in New Issue
Block a user