Switched from file-tuning to simply sending file

This commit is contained in:
Mark Goltsman
2024-10-20 12:21:22 -04:00
parent 496b7b1492
commit 139ca3f235
2 changed files with 28 additions and 11 deletions

34
main.py
View File

@@ -1,22 +1,34 @@
from config import API_KEY
from openai import OpenAI
from fileFormatConverter import convert_file
client = OpenAI(api_key=API_KEY)
def main():
inputFileName = input("enter input file name with extension (supported types: pdf, docx): ")
outputFileName = input("enter output file name without extension:")
convert_file(inputFileName, outputFileName)
#inputFileName = input("enter input file name with extension (supported types: pdf, docx): ")
# outputFileName = input("enter output file name without extension:")
with open(f'{outputFileName}.jsonl', 'rb') as file:
file_response = client.files.create(
file=file,
purpose="fine-tune"
)
inputFileName = "HW07.pdf"
outputFileName = "demo"
convert_file(inputFileName, outputFileName)
client = OpenAI(api_key=API_KEY)
with open(f'{outputFileName}.jsonl', 'r') as file:
# file_response = client.files.create(
# file=file,
# purpose="fine-tune"
# )
# fine_tuned_model = client.fine_tuning.jobs.create(
# training_file=file_response.id,
# model="gpt-4o-mini-2024-07-18"
# )
homework = file.read()
stream = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Give me an estimation how long this homework will take me"}],
model="gpt-4o-mini-2024-07-18",
messages=[{"role": "user", "content": f"""
This is my homework: {homework}
If this homework consists of several separate problems, split them.
For each problem give me problem number, problem name, and problem text"""}],
stream=True,
)
for chunk in stream: