HealthBOT / app.py
typesdigital's picture
Update app.py
ca7f113
raw
history blame
936 Bytes
import openai
# Set up the OpenAI API credentials
openai.api_key = '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'
def generate_response(prompt):
# Set up the OpenAI API parameters
model_engine = "text-davinci-002"
temperature = 0.7
max_tokens = 100
# Generate the response using the OpenAI API
response = openai.Completion.create(
engine=model_engine,
prompt=prompt,
temperature=temperature,
max_tokens=max_tokens
)
# Extract the generated text from the API response
generated_text = response.choices[0].text.strip()
return generated_text
def main():
while True:
# Prompt the user for input
prompt = input("Ask for a health tip or benefit: ")
# Generate a response using the OpenAI API
response = generate_response(prompt)
# Print the response
print(response)
if __name__ == '__main__':
main()