nagasurendra commited on
Commit
f0f32b9
verified
1 Parent(s): 92379b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -55
app.py CHANGED
@@ -129,9 +129,6 @@ def generate_custom_dish():
129
  if not dish_name or not description:
130
  return jsonify({"success": False, "error": "Both fields are required"}), 400
131
 
132
- # Generate AI-based images (dummy URLs for now)
133
- image1_url, image2_url = generate_ai_images(description)
134
-
135
  # Determine price based on description length
136
  price = random.randint(100, 300) # Example logic for price setting
137
 
@@ -148,8 +145,6 @@ def generate_custom_dish():
148
  "Name": dish_name,
149
  "Price__c": price,
150
  "Description__c": description,
151
- "Image1__c": image1_url,
152
- "Image2__c": image2_url,
153
  "Veg_NonVeg__c": category,
154
  "Section__c": "Custom Dishes",
155
  "Total_Ordered__c": 0
@@ -162,56 +157,6 @@ def generate_custom_dish():
162
  except Exception as e:
163
  return jsonify({"success": False, "error": str(e)}), 500
164
 
165
- import openai
166
- import openai
167
-
168
- import openai
169
-
170
- import openai
171
-
172
- def generate_ai_images(description):
173
- """
174
- Use OpenAI's DALL路E API to generate images from a text description.
175
- """
176
- openai.api_key = 'YOUR_OPENAI_API_KEY' # Replace with your OpenAI API key
177
-
178
- try:
179
- # Generate images from the description using OpenAI's DALL路E model
180
- response = openai.Image.create(
181
- prompt=description,
182
- n=2, # Generate 2 images
183
- size="1024x1024" # Image size (can adjust this)
184
- )
185
-
186
- # Extract image URLs from the response
187
- image1_url = response['data'][0]['url']
188
- image2_url = response['data'][1]['url']
189
-
190
- return image1_url, image2_url
191
-
192
- except openai.InvalidRequestError as e:
193
- # Handle invalid request errors (e.g., invalid parameters)
194
- raise Exception(f"Invalid request error: {str(e)}")
195
-
196
- except openai.AuthenticationError as e:
197
- # Handle authentication errors (invalid API key)
198
- raise Exception(f"Authentication error: {str(e)}")
199
-
200
- except openai.RateLimitError as e:
201
- # Handle rate limit errors (API request limit exceeded)
202
- raise Exception(f"Rate limit error: {str(e)}")
203
-
204
- except openai.OpenAIError as e:
205
- # Catch any other OpenAI-related errors
206
- raise Exception(f"OpenAI API error: {str(e)}")
207
-
208
- except Exception as e:
209
- # Catch all other unexpected exceptions
210
- raise Exception(f"Unexpected error: {str(e)}")
211
-
212
-
213
-
214
-
215
  import re
216
  @app.route("/customer_details", methods=["GET"])
217
  def customer_details():
 
129
  if not dish_name or not description:
130
  return jsonify({"success": False, "error": "Both fields are required"}), 400
131
 
 
 
 
132
  # Determine price based on description length
133
  price = random.randint(100, 300) # Example logic for price setting
134
 
 
145
  "Name": dish_name,
146
  "Price__c": price,
147
  "Description__c": description,
 
 
148
  "Veg_NonVeg__c": category,
149
  "Section__c": "Custom Dishes",
150
  "Total_Ordered__c": 0
 
157
  except Exception as e:
158
  return jsonify({"success": False, "error": str(e)}), 500
159
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  import re
161
  @app.route("/customer_details", methods=["GET"])
162
  def customer_details():