I guess something related to WSL. I closed the terminal, open a new one, and all now works. Very strange.
Anyhow, thanks for all the help!
I guess something related to WSL. I closed the terminal, open a new one, and all now works. Very strange.
Anyhow, thanks for all the help!
Need to pass deployment_id.
EMBEDDINGS = OpenAIEmbeddings(model_kwargs={“deployment_id”: “text-embedding-ada-002”}
It might help! Don’t forget to import required libraries.
client = OpenAI(api_key = “Your_OPENAI_Key”)
model_list = client.models.list()
data =
for model in model_list:
created_date = datetime.fromtimestamp(model.created, timezone.utc).strftime(‘%Y-%m-%d %H:%M:%S’)
data.append({
‘Model Name’: model.id,
‘Created Date’: created_date,
‘Object’: model.object,
‘Owned By’: model.owned_by
})
df = pd.DataFrame(data).sort_values(by=‘Created Date’, ascending=False, ignore_index=True)
The crux of this thread was the difference in endpoints that OpenAI offers, and what services Microsoft offers and methods in Azure to see your model deployments.
Here’s a more productive OpenAI script. In this case, employing a “starts with” and banned phrases to return only chat models by name in a list:
from openai import OpenAI
client = OpenAI()
starts_with = ["gpt", "ft:gpt"]
blacklist = ["instruct"]
try:
model_obj = client.models.list() # API call
except Exception as err:
raise ValueError(f"Model listing API call failed: {err}") from None
model_dict = model_obj.model_dump().get('data', [])
model_list = sorted([model['id'] for model in model_dict])
def starts_with_any(model_name, starts_with_list):
for prefix in starts_with_list:
if model_name.startswith(prefix):
return True
return False
def contains_blacklisted(model_name, blacklist):
for blacklisted in blacklist:
if blacklisted in model_name:
return True
return False
filtered_models = [model for model in model_list
if starts_with_any(model, starts_with)
and not contains_blacklisted(model, blacklist)]
print("\n".join(filtered_models))
You can proceed from there to amending the models with their metadata, or populating the user’s interface in your chatbot GUI with available models…