#How to get openAi to read a text document?

5 messages · Page 1 of 1 (latest)

mild thunder
#

I've been trying to get Chat Gpt to read the prompt and read the document to summize it here is the code (also the api key works i've just blanked it out)

import os 

# Check if the file exists
file_path = "C:\\Users\\hayde\\OneDrive\\Desktop\\Test.txt"
if os.path.exists(file_path):
    print("The file exists!")
else:
    print("The file does not exist.") 
    
openai.api_key = "API-KEY"

with open("C:\\Users\\hayde\\OneDrive\\Desktop\\Test.txt", "r") as file:
    prompt = file.read() 

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

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

Right now the prompt is just the document but idk how to make it that it can read a prompt i give it and the document after it

inland pollen
#

Does your text contain something along the lines that it should summarize the text? maybe your 100 Tokens-Limit is too low. idk

tame imp
#

You need to prompt the model to summarize the text

#

prompt = f'Please summarize the following text: {text}'