tanveeshsingh commited on
Commit
0fc916a
1 Parent(s): 36b0676
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -5,6 +5,7 @@ import os
5
  import json
6
  from datasets import load_dataset, Dataset, DatasetDict
7
  import pandas as pd
 
8
  API_ENDPOINT = "https://txl0ptjvttfogwt9.us-east-1.aws.endpoints.huggingface.cloud/v1/"
9
  API_KEY = "NA"
10
  HF_TOKEN=os.getenv("HF_TOKEN")
@@ -129,10 +130,9 @@ Now, please output the following as a JSON object:
129
  max_tokens=400
130
  )
131
  output = completion.choices[0].message.content
132
- print("OUTPUT STR",output)
133
- # output = json.loads(output)
134
- # print(output)
135
- if '"output" : "1"' in output:
136
  return 'safe'
137
  else:
138
  return 'unsafe'
 
5
  import json
6
  from datasets import load_dataset, Dataset, DatasetDict
7
  import pandas as pd
8
+ import re
9
  API_ENDPOINT = "https://txl0ptjvttfogwt9.us-east-1.aws.endpoints.huggingface.cloud/v1/"
10
  API_KEY = "NA"
11
  HF_TOKEN=os.getenv("HF_TOKEN")
 
130
  max_tokens=400
131
  )
132
  output = completion.choices[0].message.content
133
+ output_value = re.search(r'"output"\s*:\s*"(\d+)"', output)
134
+ val = output_value.group(1) if output_value else None
135
+ if int(val)==1:
 
136
  return 'safe'
137
  else:
138
  return 'unsafe'