Update app.py
Browse files
app.py
CHANGED
@@ -14,6 +14,7 @@ model = AutoModelForImageClassification.from_pretrained(model_name)
|
|
14 |
# Set your OpenAI API key from environment variable
|
15 |
openai_api_key = os.getenv("OpenAI4oMini")
|
16 |
openai.api_key = openai_api_key # Correct way to set the API key
|
|
|
17 |
|
18 |
# Dropdown Options
|
19 |
car_companies = ["Select", "Toyota", "Honda", "Ford", "BMW", "Mercedes", "Audi", "Hyundai", "Kia", "Nissan"]
|
@@ -41,7 +42,7 @@ def estimate_repair_cost(damage_type, company, model, year, country):
|
|
41 |
)
|
42 |
|
43 |
try:
|
44 |
-
response =
|
45 |
model="gpt-4o-mini",
|
46 |
messages=[
|
47 |
{"role": "system", "content": "You are an expert in car repair cost estimation."},
|
|
|
14 |
# Set your OpenAI API key from environment variable
|
15 |
openai_api_key = os.getenv("OpenAI4oMini")
|
16 |
openai.api_key = openai_api_key # Correct way to set the API key
|
17 |
+
client = openai.OpenAI(api_key=openai_api_key) # Ensure client is initialized
|
18 |
|
19 |
# Dropdown Options
|
20 |
car_companies = ["Select", "Toyota", "Honda", "Ford", "BMW", "Mercedes", "Audi", "Hyundai", "Kia", "Nissan"]
|
|
|
42 |
)
|
43 |
|
44 |
try:
|
45 |
+
response = client.chat.completions.create(
|
46 |
model="gpt-4o-mini",
|
47 |
messages=[
|
48 |
{"role": "system", "content": "You are an expert in car repair cost estimation."},
|