CosmoAI commited on
Commit
234bcdb
·
1 Parent(s): 26420fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -49,9 +49,12 @@ palm.configure(api_key=os.environ["PALM_KEY"])
49
  def responsenew(data):
50
  idval = str(uuid.uuid4())
51
  print(f"\n\n{data}")
52
- items = json.JSONDecoder().decode(data)
53
- text = items['text']
54
- print(text)
 
 
 
55
  response = palm.chat( messages=data)
56
  print(f"\n{response.last}")
57
  if data is not None:
 
49
  def responsenew(data):
50
  idval = str(uuid.uuid4())
51
  print(f"\n\n{data}")
52
+ try:
53
+ items = json.loads(data)
54
+ text = items['text']
55
+ print(text)
56
+ except json.JSONDecodeError as e:
57
+ print("Invalid JSON:", e)
58
  response = palm.chat( messages=data)
59
  print(f"\n{response.last}")
60
  if data is not None: