File tree Expand file tree Collapse file tree 1 file changed +11
-11
lines changed
Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -77,20 +77,20 @@ backgroundImage: url('https://marp.app/assets/hero-background.jpg')
7777# プログラミング言語Python
7878
7979``` python
80- import tkinter as tk
81- from datetime import datetime as dt
80+ import openai
8281
83- root = tk.Tk()
84- clock = tk.StringVar()
85- label = tk.Label(textvariable = clock)
86- label.pack()
82+ openai.api_key = " *****"
8783
88- def update ():
89- clock.set(dt.now().strftime(' %H:%M:%S' ))
90- root.after(1000 , update)
84+ def answer (question : str ) -> str :
85+ """ Return an answer of the question by GPT-3.5."""
86+ response = openai.ChatCompletion.create(
87+ model = " gpt-3.5-turbo" ,
88+ messages = [{" role" : " user" , " content" : question}],
89+ )
90+ return response[" choices" ][0 ][" message" ][" content" ]
9191
92- update()
93- root.mainloop( )
92+
93+ print (answer( " Pythonを学ぶには? " ) )
9494```
9595
9696---
You can’t perform that action at this time.
0 commit comments