debian:~$ cat openai_examples_tldr_summary.py
import openai
import os
import json
openai.api_key = os.getenv("OPENAI_API_KEY")
#prompt="A neutron star is the collapsed core of a massive supergiant star, which had a total mass of between 10 and 25 solar masses, possibly more if the star was especially metal-rich.[1] Neutron stars are the smallest and densest stellar objects, excluding black holes and hypothetical white holes, quark stars, and strange stars.[2] Neutron stars have a radius on the order of 10 kilometres (6.2 mi) and a mass of about 1.4 solar masses.[3] They result from the supernova explosion of a massive star, combined with gravitational collapse, that compresses the core past white dwarf star density to that of atomic nuclei.\n\ntl;dr:",
prompt="ベイズの法則、最近ではベイズ・プライスの定理とは、ある事象に関連する可能性のある条件についての事前の知識に基づいて、その事象の確率を記述するものである。 例えば、健康問題の発生リスクが年齢とともに増加することが知られている場合、ベイズの定理により、ある年齢の個人のリスクを、単にその個人が集団全体の典型的な例であると仮定するよりも、(年齢を条件として)より正確に評価することができる。"
response = openai.Completion.create(
engine="davinci",
prompt=prompt,
temperature=0.3,
max_tokens=120,
top_p=1.0,
frequency_penalty=0.0,
presence_penalty=0.0
)
#print(prompt)
print(str(prompt))
print(" ")
print(response['choices'][0]['text'])
#print(str(response['choices'][0]['text']))
#print(json.dumps(response, ensure_ascii=False, indent=2))
debian:~$