Skip to content

Commit

Permalink
#6 Merge pull request from a-lab-nagoya/astropenguin/issue5
Browse files Browse the repository at this point in the history
Update example code
  • Loading branch information
astropenguin authored Apr 12, 2023
2 parents 927b07a + 4e9ab7e commit 0171396
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,20 @@ backgroundImage: url('https://marp.app/assets/hero-background.jpg')
# プログラミング言語Python

```python
import tkinter as tk
from datetime import datetime as dt
import openai

root = tk.Tk()
clock = tk.StringVar()
label = tk.Label(textvariable=clock)
label.pack()
openai.api_key = "*****"

def update():
clock.set(dt.now().strftime('%H:%M:%S'))
root.after(1000, update)
def answer(question: str) -> str:
"""Return an answer of the question by GPT-3.5."""
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": question}],
)
return response["choices"][0]["message"]["content"]

update()
root.mainloop()

print(answer("Pythonを学ぶには?"))
```

---
Expand Down

0 comments on commit 0171396

Please sign in to comment.