Spaces:
Running
on
T4
Running
on
T4
fixed context verification, refined buttons
Browse files- app.py +12 -11
- octotools/models/planner.py +5 -3
app.py
CHANGED
@@ -325,11 +325,11 @@ class Solver:
|
|
325 |
# [Step 8] Memory update and stopping condition
|
326 |
self.memory.add_action(step_count, tool_name, sub_goal, tool_command, result)
|
327 |
stop_verification = self.planner.verificate_memory(user_query, img_path, query_analysis, self.memory)
|
328 |
-
conclusion = self.planner.extract_conclusion(stop_verification)
|
329 |
|
330 |
# Save the context verification data
|
331 |
context_verification_data = {
|
332 |
-
"stop_verification":
|
333 |
"conclusion": conclusion,
|
334 |
"time": round(time.time() - start_time, 5)
|
335 |
}
|
@@ -339,7 +339,7 @@ class Solver:
|
|
339 |
conclusion_emoji = "β
" if conclusion == 'STOP' else "π"
|
340 |
messages.append(ChatMessage(
|
341 |
role="assistant",
|
342 |
-
content=f"**Analysis
|
343 |
metadata={"title": f"### π€ Step {step_count}: Context Verification"}))
|
344 |
yield messages
|
345 |
|
@@ -506,13 +506,14 @@ def main(args):
|
|
506 |
[Website](https://octotools.github.io/) |
|
507 |
[Github](https://github.com/octotools/octotools) |
|
508 |
[arXiv](https://arxiv.org/abs/2502.11271) |
|
|
|
509 |
[Paper](https://arxiv.org/pdf/2502.11271) |
|
510 |
[Daily Paper](https://huggingface.co/papers/2502.11271) |
|
511 |
[Tool Cards](https://octotools.github.io/#tool-cards) |
|
512 |
[Example Visualizations](https://octotools.github.io/#visualization) |
|
513 |
[YouTube](https://www.youtube.com/watch?v=4828sGfx7dk&t=1176s&ab_channel=DiscoverAI) |
|
514 |
[Coverage](https://x.com/lupantech/status/1892260474320015861) |
|
515 |
-
[
|
516 |
""")
|
517 |
|
518 |
with gr.Row():
|
@@ -594,8 +595,8 @@ def main(args):
|
|
594 |
|
595 |
# TODO: Add actions to the buttons
|
596 |
with gr.Row(elem_id="buttons") as button_row:
|
597 |
-
upvote_btn = gr.Button(value="π Upvote", interactive=True, variant="primary")
|
598 |
-
downvote_btn = gr.Button(value="π Downvote", interactive=True, variant="primary")
|
599 |
# stop_btn = gr.Button(value="βοΈ Stop", interactive=True) # TODO
|
600 |
# clear_btn = gr.Button(value="ποΈ Clear history", interactive=True) # TODO
|
601 |
|
@@ -604,25 +605,25 @@ def main(args):
|
|
604 |
comment_textbox = gr.Textbox(value="",
|
605 |
placeholder="Feel free to add any comments here. Thanks for using OctoTools!",
|
606 |
label="π¬ Comment (Type and press Enter to submit.)", interactive=True) # TODO
|
607 |
-
|
608 |
# Update the button click handlers
|
609 |
upvote_btn.click(
|
610 |
-
fn=lambda: save_feedback(QUERY_ID, "upvote"),
|
611 |
inputs=[],
|
612 |
outputs=[]
|
613 |
)
|
614 |
|
615 |
downvote_btn.click(
|
616 |
-
fn=lambda: save_feedback(QUERY_ID, "downvote"),
|
617 |
inputs=[],
|
618 |
outputs=[]
|
619 |
)
|
620 |
|
621 |
# Add handler for comment submission
|
622 |
comment_textbox.submit(
|
623 |
-
fn=lambda comment: save_feedback(QUERY_ID, "comment", comment),
|
624 |
inputs=[comment_textbox],
|
625 |
-
outputs=[]
|
626 |
)
|
627 |
|
628 |
# Bottom row for examples
|
|
|
325 |
# [Step 8] Memory update and stopping condition
|
326 |
self.memory.add_action(step_count, tool_name, sub_goal, tool_command, result)
|
327 |
stop_verification = self.planner.verificate_memory(user_query, img_path, query_analysis, self.memory)
|
328 |
+
context_verification, conclusion = self.planner.extract_conclusion(stop_verification)
|
329 |
|
330 |
# Save the context verification data
|
331 |
context_verification_data = {
|
332 |
+
"stop_verification": context_verification,
|
333 |
"conclusion": conclusion,
|
334 |
"time": round(time.time() - start_time, 5)
|
335 |
}
|
|
|
339 |
conclusion_emoji = "β
" if conclusion == 'STOP' else "π"
|
340 |
messages.append(ChatMessage(
|
341 |
role="assistant",
|
342 |
+
content=f"**Analysis:**\n{context_verification}\n\n**Conclusion:** `{conclusion}` {conclusion_emoji}",
|
343 |
metadata={"title": f"### π€ Step {step_count}: Context Verification"}))
|
344 |
yield messages
|
345 |
|
|
|
506 |
[Website](https://octotools.github.io/) |
|
507 |
[Github](https://github.com/octotools/octotools) |
|
508 |
[arXiv](https://arxiv.org/abs/2502.11271) |
|
509 |
+
[PyPI](https://pypi.org/project/octotoolkit/) |
|
510 |
[Paper](https://arxiv.org/pdf/2502.11271) |
|
511 |
[Daily Paper](https://huggingface.co/papers/2502.11271) |
|
512 |
[Tool Cards](https://octotools.github.io/#tool-cards) |
|
513 |
[Example Visualizations](https://octotools.github.io/#visualization) |
|
514 |
[YouTube](https://www.youtube.com/watch?v=4828sGfx7dk&t=1176s&ab_channel=DiscoverAI) |
|
515 |
[Coverage](https://x.com/lupantech/status/1892260474320015861) |
|
516 |
+
[Slack](https://join.slack.com/t/octotools/shared_invite/zt-3485ikfas-zMTbFbuodJmET~R6KXHEGw)
|
517 |
""")
|
518 |
|
519 |
with gr.Row():
|
|
|
595 |
|
596 |
# TODO: Add actions to the buttons
|
597 |
with gr.Row(elem_id="buttons") as button_row:
|
598 |
+
upvote_btn = gr.Button(value="π Upvote", interactive=True, variant="primary")
|
599 |
+
downvote_btn = gr.Button(value="π Downvote", interactive=True, variant="primary")
|
600 |
# stop_btn = gr.Button(value="βοΈ Stop", interactive=True) # TODO
|
601 |
# clear_btn = gr.Button(value="ποΈ Clear history", interactive=True) # TODO
|
602 |
|
|
|
605 |
comment_textbox = gr.Textbox(value="",
|
606 |
placeholder="Feel free to add any comments here. Thanks for using OctoTools!",
|
607 |
label="π¬ Comment (Type and press Enter to submit.)", interactive=True) # TODO
|
608 |
+
|
609 |
# Update the button click handlers
|
610 |
upvote_btn.click(
|
611 |
+
fn=lambda: (save_feedback(QUERY_ID, "upvote"), gr.Info("Thank you for your upvote! π")),
|
612 |
inputs=[],
|
613 |
outputs=[]
|
614 |
)
|
615 |
|
616 |
downvote_btn.click(
|
617 |
+
fn=lambda: (save_feedback(QUERY_ID, "downvote"), gr.Info("Thank you for your feedback. We'll work to improve! π")),
|
618 |
inputs=[],
|
619 |
outputs=[]
|
620 |
)
|
621 |
|
622 |
# Add handler for comment submission
|
623 |
comment_textbox.submit(
|
624 |
+
fn=lambda comment: (save_feedback(QUERY_ID, "comment", comment), gr.Info("Thank you for your comment! π¬")),
|
625 |
inputs=[comment_textbox],
|
626 |
+
outputs=[comment_textbox] # Clear the textbox after submission
|
627 |
)
|
628 |
|
629 |
# Bottom row for examples
|
octotools/models/planner.py
CHANGED
@@ -257,10 +257,12 @@ Response Format:
|
|
257 |
return stop_verification
|
258 |
|
259 |
def extract_conclusion(self, response: MemoryVerification) -> str:
|
260 |
-
|
261 |
-
|
|
|
|
|
262 |
else:
|
263 |
-
return 'CONTINUE'
|
264 |
|
265 |
def generate_final_output(self, question: str, image: str, memory: Memory, bytes_mode: bool = False) -> str:
|
266 |
if bytes_mode:
|
|
|
257 |
return stop_verification
|
258 |
|
259 |
def extract_conclusion(self, response: MemoryVerification) -> str:
|
260 |
+
analysis = response.analysis
|
261 |
+
stop_signal = response.stop_signal
|
262 |
+
if stop_signal:
|
263 |
+
return analysis, 'STOP'
|
264 |
else:
|
265 |
+
return analysis, 'CONTINUE'
|
266 |
|
267 |
def generate_final_output(self, question: str, image: str, memory: Memory, bytes_mode: bool = False) -> str:
|
268 |
if bytes_mode:
|