#OpenAI api can't do math questions step-by-step

2 messages · Page 1 of 1 (latest)

solar sail
#

Im trying to make it so it does the first 3 math problems and does them step by step and shows the answer but whenever I run the script it gives a diffent answer everytime sometimes it just shows the questions and nothing else its werid heres the code: ``` import openai
import os

from summathkey import apikey
from summathkey import path

openai.api_key = apikey

Set the directory you want to read from

directory = path

Get a list of all the files in the directory

files = os.listdir(directory)

Iterate through the list of files

for file in files:

Check if the file is a .txt file

if file.endswith('.txt') and "math" in file:
# Open the file and read the contents
with open(os.path.join(directory, file), 'r') as f:
data = f.read().replace('\n', '')

  prompt = "Solve first three math problems step by step like microsoft math solver would"

  request_body = f"{prompt}\n{data}"

  response = openai.Completion.create(
      engine="text-davinci-002",
      prompt=request_body,
      temperature=0.4,
      max_tokens=500
  )

  # Print the text from the response
  print(response["choices"][0]["text"]) ```
twin saddle