File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed
Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change 33client = OpenAI ()
44
55text_response = client .responses .create (
6- model = "gpt-5" ,
7- input = "Tell me a joke about Python programming"
6+ model = "gpt-5" , input = "Tell me a joke about Python programming"
87)
98
109print (f"Joke:\n { text_response .output_text } " )
Original file line number Diff line number Diff line change 33
44client = OpenAI ()
55
6+
67class CodeOutput (BaseModel ):
78 function_name : str
89 code : str
910 explanation : str
1011 example_usage : str
1112
13+
1214code_response = client .responses .parse (
1315 model = "gpt-5" ,
1416 input = [
1517 {
1618 "role" : "developer" ,
17- "content" : ("You are a coding assistant. Generate clean,"
18- "well-documented Python code."
19- )
19+ "content" : (
20+ "You are a coding assistant. Generate clean,"
21+ "well-documented Python code."
22+ ),
2023 },
2124 {
2225 "role" : "user" ,
23- "content" : "Write a simple Python function to add two numbers"
24- }
26+ "content" : "Write a simple Python function to add two numbers" ,
27+ },
2528 ],
2629 text_format = CodeOutput ,
2730)
You can’t perform that action at this time.
0 commit comments