mirror of
https://github.com/kennethreitz/simplemind.git
synced 2026-06-05 06:46:18 +00:00
Add sentiment_analysis.py example for analyzing sentiment of text
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
from _context import sm
|
||||
|
||||
from pydantic import BaseModel
|
||||
from typing import Literal
|
||||
|
||||
|
||||
class SentimentAnalysis(BaseModel):
|
||||
sentiment: Literal["positive", "negative", "neutral"]
|
||||
confidence: float
|
||||
|
||||
|
||||
print(
|
||||
sm.generate_data(
|
||||
prompt="Analyze the sentiment of the following text:\n\n'The product arrived late and was broken. Worst purchase ever!'",
|
||||
llm_provider="openai",
|
||||
llm_model="gpt-4o",
|
||||
response_model=SentimentAnalysis,
|
||||
)
|
||||
)
|
||||
Reference in New Issue
Block a user