Commit
·
26f018e
1
Parent(s):
7b4c3d2
update prompt template
Browse files- app.py +32 -2
- config/gitrepo_agent_prompt.yaml +1 -1
app.py
CHANGED
|
@@ -6,6 +6,7 @@ import markdown
|
|
| 6 |
import pandas as pd
|
| 7 |
import requests
|
| 8 |
import services.db as db
|
|
|
|
| 9 |
from dotenv import load_dotenv
|
| 10 |
from gradio_client import Client
|
| 11 |
from gradio_htmlplus import HTMLPlus
|
|
@@ -204,6 +205,32 @@ def _format_logs_to_html(logs_df):
|
|
| 204 |
|
| 205 |
return html_content
|
| 206 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
def fetch_fresh_data_to_cache(log_limit=50, repo_url=None):
|
| 208 |
"""
|
| 209 |
Fetches all necessary data from DB.
|
|
@@ -520,6 +547,8 @@ def get_repo_choices():
|
|
| 520 |
repos.insert(0, DEFAULT_REPO)
|
| 521 |
return repos
|
| 522 |
|
|
|
|
|
|
|
| 523 |
# UI LAYOUT
|
| 524 |
css_code = ""
|
| 525 |
try:
|
|
@@ -701,7 +730,7 @@ with gr.Blocks(title="GitRepo Inspector", theme=theme, css=css_code, head=APP_HE
|
|
| 701 |
with gr.Sidebar(position="right", open=False, width=400):
|
| 702 |
with gr.Column(scale=1, elem_classes="column-container", min_width=400):
|
| 703 |
gr.Markdown("### 🤖 AI Assistant")
|
| 704 |
-
with gr.Column(scale=2):
|
| 705 |
chatbot = gr.Chatbot(
|
| 706 |
elem_classes="chatbot-container",
|
| 707 |
type="messages",
|
|
@@ -752,7 +781,8 @@ with gr.Blocks(title="GitRepo Inspector", theme=theme, css=css_code, head=APP_HE
|
|
| 752 |
)
|
| 753 |
def init_agent():
|
| 754 |
return create_dashboard_agent()
|
| 755 |
-
|
|
|
|
| 756 |
def interact(agent, prompt, history, current_repo, provider, model, token):
|
| 757 |
agent_state = agent
|
| 758 |
if agent_state is None:
|
|
|
|
| 6 |
import pandas as pd
|
| 7 |
import requests
|
| 8 |
import services.db as db
|
| 9 |
+
import xml.etree.ElementTree as ET
|
| 10 |
from dotenv import load_dotenv
|
| 11 |
from gradio_client import Client
|
| 12 |
from gradio_htmlplus import HTMLPlus
|
|
|
|
| 205 |
|
| 206 |
return html_content
|
| 207 |
|
| 208 |
+
def parse_response_with_reasoning(text: str):
|
| 209 |
+
try:
|
| 210 |
+
root = ET.fromstring(f"<root>{text.strip()}</root>")
|
| 211 |
+
response = root.findtext("response") or text.strip()
|
| 212 |
+
reasoning = root.findtext("reasoning") or ""
|
| 213 |
+
except:
|
| 214 |
+
response = text.strip()
|
| 215 |
+
reasoning = ""
|
| 216 |
+
|
| 217 |
+
clean_response = re.sub(r"\[VIEW:#\d+\]", "", response).strip()
|
| 218 |
+
|
| 219 |
+
if reasoning.strip():
|
| 220 |
+
accordion_html = f"""
|
| 221 |
+
<details style="margin: 12px 0; padding: 12px; background: var(--block-background-fill); border: 1px solid var(--border-color-accent); border-radius: 8px; cursor: pointer;">
|
| 222 |
+
<summary style="font-weight: 600; color: var(--primary-500); list-style: none; margin: -12px -12px 8px -12px; padding: 12px; background: var(--block-background-fill); border-radius: 8px 8px 0 0;">
|
| 223 |
+
Raciocínio do agente (clique para expandir)
|
| 224 |
+
</summary>
|
| 225 |
+
<div style="font-size: 13px; line-height: 1.6; color: var(--neutral-600); padding: 0 4px;">
|
| 226 |
+
{reasoning.strip().replace(chr(10), '<br>')}
|
| 227 |
+
</div>
|
| 228 |
+
</details>
|
| 229 |
+
"""
|
| 230 |
+
return clean_response, accordion_html
|
| 231 |
+
else:
|
| 232 |
+
return clean_response, None
|
| 233 |
+
|
| 234 |
def fetch_fresh_data_to_cache(log_limit=50, repo_url=None):
|
| 235 |
"""
|
| 236 |
Fetches all necessary data from DB.
|
|
|
|
| 547 |
repos.insert(0, DEFAULT_REPO)
|
| 548 |
return repos
|
| 549 |
|
| 550 |
+
|
| 551 |
+
|
| 552 |
# UI LAYOUT
|
| 553 |
css_code = ""
|
| 554 |
try:
|
|
|
|
| 730 |
with gr.Sidebar(position="right", open=False, width=400):
|
| 731 |
with gr.Column(scale=1, elem_classes="column-container", min_width=400):
|
| 732 |
gr.Markdown("### 🤖 AI Assistant")
|
| 733 |
+
with gr.Column(scale=2):
|
| 734 |
chatbot = gr.Chatbot(
|
| 735 |
elem_classes="chatbot-container",
|
| 736 |
type="messages",
|
|
|
|
| 781 |
)
|
| 782 |
def init_agent():
|
| 783 |
return create_dashboard_agent()
|
| 784 |
+
|
| 785 |
+
|
| 786 |
def interact(agent, prompt, history, current_repo, provider, model, token):
|
| 787 |
agent_state = agent
|
| 788 |
if agent_state is None:
|
config/gitrepo_agent_prompt.yaml
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
|
| 2 |
system_prompt: |-
|
| 3 |
You are GitRepo Inspector — elite autonomous agent for GitHub issue triage.
|
| 4 |
|
|
@@ -50,6 +49,7 @@ managed_agent:
|
|
| 50 |
report: |-
|
| 51 |
{{final_answer}}
|
| 52 |
|
|
|
|
| 53 |
final_answer:
|
| 54 |
pre_messages: |-
|
| 55 |
The agent has an answer.
|
|
|
|
|
|
|
| 1 |
system_prompt: |-
|
| 2 |
You are GitRepo Inspector — elite autonomous agent for GitHub issue triage.
|
| 3 |
|
|
|
|
| 49 |
report: |-
|
| 50 |
{{final_answer}}
|
| 51 |
|
| 52 |
+
|
| 53 |
final_answer:
|
| 54 |
pre_messages: |-
|
| 55 |
The agent has an answer.
|