Afeezee commited on
Commit
384868d
·
verified ·
1 Parent(s): 87cf26a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -52,12 +52,14 @@ def analyze_image(image, instruction):
52
  top_p=0.1,
53
  )
54
 
55
- # Extract and return the response
56
- analysis = completion.choices[0].message.content
57
- return analysis
 
 
58
  except Exception as e:
59
- return f"Error: {str(e)}"
60
-
61
  # Gradio interface
62
  iface = gr.Interface(
63
  fn=analyze_image,
 
52
  top_p=0.1,
53
  )
54
 
55
+ # Extract the content from the first choice
56
+ analysis = response["choices"][0]["message"]["content"]
57
+ return analysis.strip()
58
+ except KeyError:
59
+ return "Error: Response format from the API is unexpected."
60
  except Exception as e:
61
+ return f"Error:
62
+
63
  # Gradio interface
64
  iface = gr.Interface(
65
  fn=analyze_image,