YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
import openai
Replace with your OpenAI API key
openai.api_key = 'YOUR_OPENAI_API_KEY'
def chat_with_scientist(prompt): """ This function takes a user's input and returns a response from the generative AI, pretending to be a science scientist. """ response = openai.Completion.create( engine="text-davinci-003", # GPT-3.5 or change to "gpt-4" for GPT-4 model prompt=prompt, max_tokens=150, n=1, stop=None, temperature=0.7, # Higher value for more creative responses ) return response.choices[0].text.strip()
def start_chat(): print("AI Scientist: Hello! I am a scientist. Ask me any science-related questions.") while True: user_input = input("You: ") if user_input.lower() in ["exit", "quit"]: print("AI Scientist: Goodbye!") break prompt = f"You are a knowledgeable scientist. Answer the following science question in detail: {user_input}" reply = chat_with_scientist(prompt) print(f"AI Scientist: {reply}\n")
if name == "main": start_chat()