Hi all,
I am referencing an asst_ ID in my code, which extracts data from an Excel sheet, passes it into my Assistant, and returns the response to write into a new column in the spreadsheet.
Whenever referencing my asst_ in my python code I get an error: An error occurred: The model asst_EXAMPLE
does not exist or you do not have access to it.
When referencing the same asst_ in a test call to GET /v1/assistants/listassistants I am able to see the asst_ in the response.
Here is my code(with keys and references removed):
import pandas as pd
import openai
openai.api_key = 'xxx'
def query_openai_assistant(description):
try:
response = openai.ChatCompletion.create(
model='asst_EXAMPLE',
messages=[
{"role": "user", "content": description}
]
)
generated text
if response.choices:
return response.choices[0].message['content'].strip()
else:
return "No response generated."
except Exception as e:
print(f"An error occurred: {e}")
return ""
file_path = r'C:\Users\...'
sheet_name = 'Sheet1'
df = pd.read_excel(file_path, sheet_name=sheet_name)
if "Website Description and Bullets" not in df.columns:
raise ValueError("The specified column does not exist in the spreadsheet.")
df['Assistant Response'] = df['Website Description and Bullets'].apply(query_openai_assistant)
with pd.ExcelWriter(file_path, engine='openpyxl', mode='a', if_sheet_exists='replace') as writer:
df.to_excel(writer, sheet_name=sheet_name + ' Updated', index=False)
print("The spreadsheet has been updated with Assistant responses in a new sheet.")
Any ideas?