lauro1 commited on
Commit
7d5cf5f
Β·
1 Parent(s): 4b9be9a
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -5,14 +5,13 @@ DEMO_SERVER = "4.208.9.167:80"
5
 
6
  def run_query( prompt):
7
  POLICY = "./cce_policy.txt"
8
- if prompt != True:
9
- return("β›” Error: invalid user input for query")
10
- if prompt.len() == 0:
11
  return("β›” Error: please add your query for automated code completion")
12
  try:
13
  with SecureSession(f"http://{DEMO_SERVER}", POLICY) as secure_session:
14
  res = secure_session.post(endpoint="/generate", json={"input_text": prompt})
15
- return("βœ… Query successful\n" + res.text.replace('\\n', '\n'))
 
16
  except Exception as err:
17
  return(f"β›” Query failed!\n{err}")
18
 
 
5
 
6
  def run_query( prompt):
7
  POLICY = "./cce_policy.txt"
8
+ if len(prompt) == 0:
 
 
9
  return("β›” Error: please add your query for automated code completion")
10
  try:
11
  with SecureSession(f"http://{DEMO_SERVER}", POLICY) as secure_session:
12
  res = secure_session.post(endpoint="/generate", json={"input_text": prompt})
13
+ cleaned = res.text.replace('\\n', '\n').split('\n\n')[0].split(':"')[1]
14
+ return("βœ… Query successful\n" + cleaned)
15
  except Exception as err:
16
  return(f"β›” Query failed!\n{err}")
17