Skip to content

Commit

Permalink
fix jupediaz#12 incorrect rendering in instruction section
Browse files Browse the repository at this point in the history
  • Loading branch information
mediocre9 committed Nov 3, 2024
1 parent 017961b commit 26b5976
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions api/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def index():
prompt = ""
split_length = ""
file_data = []
num_parts = 0

redis_client.incr("visit_counter")
visit_count = int(redis_client.get("visit_counter"))
Expand All @@ -27,11 +28,11 @@ def index():
prompt = request.form["prompt"]
split_length = int(request.form["split_length"])

file_data = split_prompt(prompt, split_length)
file_data, num_parts = split_prompt(prompt, split_length)

hash_value = generate_random_hash(8)

return render_template("index.html", prompt=prompt, split_length=split_length, file_data=file_data, hash=hash_value, visit_count=visit_count)
return render_template("index.html", prompt=prompt, split_length=split_length, num_parts=num_parts, file_data=file_data, hash=hash_value, visit_count=visit_count)

def split_prompt(text, split_length):
if split_length <= 0:
Expand All @@ -56,7 +57,7 @@ def split_prompt(text, split_length):
'content': content
})

return file_data
return file_data, num_parts

def generate_random_hash(length):
return ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(length))
Expand Down
8 changes: 4 additions & 4 deletions api/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ <h3>Instructions</h3>

For sending you that content, I will follow this rule:

[START PART 1/10]
this is the content of the part 1 out of 10 in total
[END PART 1/10]
[START PART 1/{{ num_parts }}]
this is the content of the part 1 out of {{ num_parts }} in total
[END PART 1/{{ num_parts }}]

Then you just answer: "Received part 1/10"
Then you just answer: "Received part 1/{{ num_parts }}"

And when I tell you "ALL PARTS SENT", then you can continue processing the data and answering my requests.</pre>
<button type="button" class="copy-btn" id="copy-instructions-btn" onclick="copyInstructions()">Copy Instructions (first message to send)</button>
Expand Down

0 comments on commit 26b5976

Please sign in to comment.