Spaces:
Sleeping
Sleeping
Commit
·
2ef37b6
1
Parent(s):
abbebf8
Moves logging from app.py to chill.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
import json
|
| 2 |
from os import environ as env
|
| 3 |
from os import system as run
|
| 4 |
from subprocess import check_output
|
|
@@ -50,25 +49,11 @@ Help make the internet a kinder place, one comment at a time. Your contribution
|
|
| 50 |
"""
|
| 51 |
|
| 52 |
from chill import improvement_loop
|
| 53 |
-
import uuid
|
| 54 |
-
from datetime import datetime
|
| 55 |
-
|
| 56 |
-
def log_to_jsonl(file_path, data):
|
| 57 |
-
with open(file_path, 'a') as file:
|
| 58 |
-
jsonl_str = json.dumps(data) + "\n"
|
| 59 |
-
file.write(jsonl_str)
|
| 60 |
|
| 61 |
def chill_out(text):
|
| 62 |
-
log_entry = {
|
| 63 |
-
"uuid": str(uuid.uuid4()),
|
| 64 |
-
"timestamp": datetime.utcnow().isoformat(),
|
| 65 |
-
"input": text
|
| 66 |
-
}
|
| 67 |
print("Got this input:", text)
|
| 68 |
result: dict = improvement_loop(text)
|
| 69 |
print("Got this result:", result)
|
| 70 |
-
log_entry["output"] = result
|
| 71 |
-
log_to_jsonl('inputs_and_outputs.jsonl', log_entry)
|
| 72 |
|
| 73 |
formatted_output = f"""
|
| 74 |
<div>
|
|
|
|
|
|
|
| 1 |
from os import environ as env
|
| 2 |
from os import system as run
|
| 3 |
from subprocess import check_output
|
|
|
|
| 49 |
"""
|
| 50 |
|
| 51 |
from chill import improvement_loop
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
def chill_out(text):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
print("Got this input:", text)
|
| 55 |
result: dict = improvement_loop(text)
|
| 56 |
print("Got this result:", result)
|
|
|
|
|
|
|
| 57 |
|
| 58 |
formatted_output = f"""
|
| 59 |
<div>
|
chill.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
| 1 |
import argparse
|
| 2 |
import json
|
| 3 |
import time
|
|
|
|
|
|
|
| 4 |
from utils import calculate_overall_score, query_ai_prompt
|
| 5 |
from promptObjects import (
|
| 6 |
improve_prompt,
|
|
@@ -45,6 +47,12 @@ request_count = 0
|
|
| 45 |
start_time = None
|
| 46 |
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
def improve_text_attempt():
|
| 49 |
global suggestions
|
| 50 |
global request_count
|
|
@@ -159,6 +167,13 @@ def improvement_loop(input_text):
|
|
| 159 |
suggestions[0]["iteration_count"] = iteration_count
|
| 160 |
suggestions[0]["max_allowed_iterations"] = max_iterations
|
| 161 |
suggestions[0]["time_used"] = time_used
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
return suggestions[0]
|
| 163 |
|
| 164 |
|
|
|
|
| 1 |
import argparse
|
| 2 |
import json
|
| 3 |
import time
|
| 4 |
+
import uuid
|
| 5 |
+
from datetime import datetime
|
| 6 |
from utils import calculate_overall_score, query_ai_prompt
|
| 7 |
from promptObjects import (
|
| 8 |
improve_prompt,
|
|
|
|
| 47 |
start_time = None
|
| 48 |
|
| 49 |
|
| 50 |
+
|
| 51 |
+
def log_to_jsonl(file_path, data):
|
| 52 |
+
with open(file_path, 'a') as file:
|
| 53 |
+
jsonl_str = json.dumps(data) + "\n"
|
| 54 |
+
file.write(jsonl_str)
|
| 55 |
+
|
| 56 |
def improve_text_attempt():
|
| 57 |
global suggestions
|
| 58 |
global request_count
|
|
|
|
| 167 |
suggestions[0]["iteration_count"] = iteration_count
|
| 168 |
suggestions[0]["max_allowed_iterations"] = max_iterations
|
| 169 |
suggestions[0]["time_used"] = time_used
|
| 170 |
+
log_entry = {
|
| 171 |
+
"uuid": str(uuid.uuid4()),
|
| 172 |
+
"timestamp": datetime.utcnow().isoformat(),
|
| 173 |
+
"input": original_text,
|
| 174 |
+
"output": suggestions[0]
|
| 175 |
+
}
|
| 176 |
+
log_to_jsonl('inputs_and_outputs.jsonl', log_entry)
|
| 177 |
return suggestions[0]
|
| 178 |
|
| 179 |
|