Hello guys, I have been created a code where I will ask for the AI to convert some sql scripts, for help the AI in this work I upload a file with the ddl of my base, and I get the file id.
Here my problem, where could I link the file id and how?
Its in assistant or thread or message? Because I had tryed all them and I got errors like file_ids dont exist or file_input dont exist, so or I put the file in wrong object or my attribute name is incorret, someone could help me please.
#file create - ok
file = openai.files.create(
file=open('test/test.txt','rb'),
purpose='assistants'
)
#{'id': 'file-7xfcQtHYhTDdjfFYwHmocd', 'bytes': 97137506, 'created_at': 1741605217, 'filename': 'completeDdl.txt', 'object': 'file', 'purpose': 'assistants', 'status': 'processed', 'expires_at': None, 'status_details': None}
#assistant - ok, but if i try put file_ids = [{file.id}], error file_ids dont exist show me
assistant = openai.beta.assistants.create(
instructions = "You are a SQL Server DBA",
name="SQL Server DBA",
model="o3-mini"
)
#thread - ok, , but if i try put file_ids = [{file.id}], error file_ids dont exist show me
thread = openai.beta.threads.create()
#message - ok, but if i try put file_ids = [{file.id}], error file_ids dont exist show me
openai.beta.threads.messages.create(
thread_id= thread.id,
assistant_id = assistant .id,
content = "my prompt"
)
#run-ok, but if i try put file_ids = [{file.id}], error file_ids dont exist show me
run = openai.beta.threads.run.create(
thread_id= thread.id,
assistant_id = assistant .id
)
#wait some seconds to finalize the run
while ....
#get return message
message_returne = openai.beta.threads.messages.list(thread_id = thread.id)
return message_returne.data[0].text.value