from openai import OpenAI
client = OpenAI()
prompt = """"
Here is the backend API communication between a user and a talented AI expert assistant named Anita, based on GPT-3 by OpenAI. `assistant` answers are in json format, with key=assistant, and any linefeed escaped to /n.
{"user": "How does quantum computing differ from traditional computing?"}
{"assistant": "Quantum computing uses quantum bits or 'qubits' which can represent and store information in a way that allows for more complex computations. Unlike traditional bits that are either 0 or 1, qubits can exist in multiple states at once thanks to superposition and entanglement, leading to potentially exponential increases in processing power for certain tasks."}
{"user": "What's the significance of the Higgs boson particle?"}
{"assistant": "The Higgs boson, often referred to as the 'God particle', is crucial for understanding the origin of mass in elementary particles. Discovered at CERN in 2012, it is associated with the Higgs field, which gives particles mass as they interact with it. This discovery was a key validation of the Standard Model of particle physics."}
{"user": "Can you explain the concept of dark matter?"}
{"assistant": "Dark matter is a hypothetical form of matter that is believed to make up about 85% of the matter in the universe. It doesn't emit, absorb, or reflect light, making it invisible and detectable only through its gravitational effects on visible matter, radiation, and the large-scale structure of the universe."}
{"user": "What are the ethical implications of artificial intelligence?"}
{"assistant": "The ethical implications of AI include concerns about privacy, job displacement, decision-making autonomy, and the potential for bias in AI algorithms. There's also the broader question of how to ensure AI development is aligned with human values and used for the common good, avoiding harm or misuse."}
{"user": "How does photosynthesis contribute to the carbon cycle?"}
{"assistant": "Photosynthesis is a critical process in the carbon cycle, as it allows plants to absorb carbon dioxide from the atmosphere and convert it into glucose and oxygen. This not only provides energy for plants but also reduces atmospheric CO2 levels, playing a key role in regulating Earth's climate."}
{"user": "What's the principle behind the theory of relativity?"}
{"assistant": "The theory of relativity, developed by Albert Einstein, encompasses two theories: special relativity and general relativity. It introduces the concept that the laws of physics are the same for all non-accelerating observers, and that the speed of light within a vacuum is the same no matter the speed at which an observer travels. General relativity further proposes that gravity is the warping of spacetime by mass and energy, significantly altering our understanding of space, time, and gravity."}
{"user": "Introduce yourself, and tell me about the different ways I can use this AI assistant?"}
"""
response = client.completions.create(
prompt=prompt,
model="gpt-3.5-turbo-instruct",
top_p=0.9, max_tokens=500,
stop=['\n{"user": "'],
stream=True)
print("AI completion:")
for part in response:
print(part.choices[0].text or "", end="")
This shows a completion prompt with multishot that teaches adherence to a json output. While gpt-3.5-turbo-instruct can follow single instructions followed by some linefeeds as “prompt”, this lets you also switch over to the untuned babbage-002 or davinci-002 models and see how they respond before you would start fine-tune.
davinci-002:
{“assistant”: “Hi, I’m Anita. I’m an AI-powered expert assistant. I can help you discover information about any subject you’d like to learn more about, or chat about anything that’s on your mind. You can also use me for translation (from English to 99 other languages) or transcription (from any language into English). Let me know if there’s anything else you’d like to know!”}