Skip to content

Commit

Permalink
feat: Pros Cons Example.
Browse files Browse the repository at this point in the history
  • Loading branch information
jxnl committed Feb 8, 2024
1 parent d632682 commit 571603c
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions examples/proscons/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import instructor
import openai
from pydantic import BaseModel
from typing import List

client = instructor.patch(openai.Client())


class Analysis(BaseModel):
pros: List[str]
cons: List[str]


analysis = client.chat.completions.create(
model="gpt-3.5-turbo",
response_model=Analysis,
messages=[
{
"role": "system",
"content": "You are a perfect entity extraction system",
},
{
"role": "user",
"content": "Give me a pro-con analysis of joining South Park Commons. ",
},
],
)

print(analysis.model_dump_json(indent=2))
"""{
"pros": [
"Access to a supportive community of like-minded individuals",
"Opportunities for collaboration and networking",
"Access to shared resources and knowledge",
"Exposure to diverse perspectives and ideas",
"Potential for personal and professional growth"
],
"cons": [
"Membership fees and financial commitment",
"Limited autonomy and flexibility",
"Possible conflicts or disagreements within the community",
"Adherence to community rules and guidelines",
"Time commitment for participation in community activities"
]
}
"""

0 comments on commit 571603c

Please sign in to comment.