[falcon]job updates with job.done and job.result
Browse files
app.py
CHANGED
@@ -578,17 +578,38 @@ async def falcon(ctx, *, prompt: str):
|
|
578 |
#fn 5 -> fn 1
|
579 |
# will give something like = /tmp/tmpklf60u2h.json, which will contain something like [["What day is today?", "Today"]] (prompt, generation)
|
580 |
job = falconspace.submit(prompt, result, instructions, 0.8, 0.9, fn_index=1) # This is not blocking
|
581 |
-
job.
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
job.
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
592 |
'''
|
593 |
result2 = falconspace.predict(
|
594 |
prompt, # str in 'Type an input and press Enter' Textbox component
|
|
|
578 |
#fn 5 -> fn 1
|
579 |
# will give something like = /tmp/tmpklf60u2h.json, which will contain something like [["What day is today?", "Today"]] (prompt, generation)
|
580 |
job = falconspace.submit(prompt, result, instructions, 0.8, 0.9, fn_index=1) # This is not blocking
|
581 |
+
while job.done() == False:
|
582 |
+
status = job.status()
|
583 |
+
print(status)
|
584 |
+
time.sleep(0.1)
|
585 |
+
if job.done() == True:
|
586 |
+
print(job.result())
|
587 |
+
|
588 |
+
directory = '/tmp/'
|
589 |
+
|
590 |
+
max_length = 0
|
591 |
+
max_length_file = None
|
592 |
+
|
593 |
+
for filename in os.listdir(directory):
|
594 |
+
if filename.endswith('.json'):
|
595 |
+
filepath = os.path.join(directory, filename)
|
596 |
+
with open(filepath, 'r') as file:
|
597 |
+
data = json.load(file)
|
598 |
+
for item in data:
|
599 |
+
if randomuuid in item[0]: # uuid should be in first item
|
600 |
+
text = item[1] if len(item) > 1 else '' # if there is no item[1], it won't work
|
601 |
+
length = len(text)
|
602 |
+
if length > max_length:
|
603 |
+
max_length = length
|
604 |
+
max_length_file = filepath
|
605 |
+
|
606 |
+
if max_length_file is not None:
|
607 |
+
print(f"The JSON file '{max_length_file}' contains the largest amount of text after the UUID.")
|
608 |
+
with open(max_length_file, "r") as file:
|
609 |
+
data = json.load(file)
|
610 |
+
await ctx.reply(f"Here's the resulting json file:\n{data}")
|
611 |
+
else:
|
612 |
+
print("No JSON file containing the UUID was found.")
|
613 |
'''
|
614 |
result2 = falconspace.predict(
|
615 |
prompt, # str in 'Type an input and press Enter' Textbox component
|