Spaces:
Runtime error
Runtime error
fixes
Browse files
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
|
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 |
-
|
|
|
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 |
|