-
Notifications
You must be signed in to change notification settings - Fork 0
Feat: Implement NLG prompt templates for report generation #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds a new NLG prompt templates module and utilities, standardizes per-agent status/timeout/error shaping in the orchestrator, updates agent function signatures and tests to new return shapes and parameters, and adjusts integration test mocks to patch orchestrator-level fetch functions. Changes
Sequence Diagram(s)sequenceDiagram
participant Orchestrator
participant Agent
Note over Orchestrator: For each registered agent
Orchestrator->>Agent: invoke fetch_* (with timeout)
alt Agent completes within timeout
Agent-->>Orchestrator: return result (dict or value)
Orchestrator->>Orchestrator: if result has "status" use as-is\nelse wrap -> {"status":"completed","data":result}
else Agent times out
Agent--xOrchestrator: no response
Orchestrator-->>Orchestrator: create {"status":"failed","error":"timeout"}
end
alt Agent raises exception
Agent--xOrchestrator: exception
Orchestrator-->>Orchestrator: create {"status":"failed","error":exception_message}
end
Orchestrator-->>Orchestrator: aggregate per-agent statuses for final result
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (14)
📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used🧬 Code graph analysis (2)backend/app/services/agents/tests/test_onchain_agent.py (1)
backend/app/services/agents/tests/test_code_audit_agent.py (1)
🪛 Ruff (0.14.5)backend/app/core/orchestrator.py206-206: Do not catch blind exception: (BLE001) 248-248: Do not catch blind exception: (BLE001) 296-296: Do not catch blind exception: (BLE001) backend/app/services/agents/tests/test_onchain_agent.py144-144: Possible hardcoded password assigned to argument: "token_id" (S106) 164-164: Possible hardcoded password assigned to argument: "token_id" (S106) 185-185: Possible hardcoded password assigned to argument: "token_id" (S106) 237-237: Possible hardcoded password assigned to argument: "token_id" (S106) 255-255: Possible hardcoded password assigned to argument: "token_id" (S106) 300-300: Possible hardcoded password assigned to argument: "token_id" (S106) 349-349: Possible hardcoded password assigned to argument: "token_id" (S106) 384-384: Possible hardcoded password assigned to argument: "token_id" (S106) 🔇 Additional comments (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
backend/app/services/nlg/prompt_templates.py (1)
10-70: Move templates dictionary to module-level constant for better performance.The
templatesdictionary is recreated on every call toget_template(), which is inefficient. Since the templates are static, consider moving this to a module-level constant.Apply this refactor:
+# Prompt templates for various report sections +PROMPT_TEMPLATES = { + "tokenomics": """ + Analyze the following tokenomics data and provide a comprehensive summary, + highlighting key aspects such as token distribution, vesting schedules, + inflation/deflation mechanisms, and any potential risks or advantages. + Focus on how these factors impact the long-term value and stability of the token. + + Tokenomics Data: + {data} + """, + "onchain_metrics": """ + Examine the provided on-chain metrics and generate an insightful analysis. + Cover aspects like active addresses, transaction volume, whale activity, + and network growth. Explain the implications of these metrics for the + project's health and adoption. + + On-chain Metrics Data: + {data} + """, + "sentiment": """ + Review the social sentiment data and summarize the overall market perception + of the project. Identify key themes, positive or negative trends, and + any significant events influencing sentiment. Discuss the potential impact + of this sentiment on the project's future. + + Sentiment Data: + {data} + """, + "team_analysis": """ + Analyze the team's background, experience, and contributions based on the + provided data. Assess the team's capability to execute the project roadmap + and highlight any strengths or weaknesses. + + Team Analysis Data: + {data} + """, + "documentation": """ + Evaluate the quality and completeness of the project's documentation. + Identify areas of excellence and areas needing improvement. Discuss how + effective documentation contributes to user adoption and developer engagement. + + Documentation Data: + {data} + """, + "code_audit": """ + Summarize the findings from the code audit report. Highlight critical + vulnerabilities, security best practices followed, and overall code quality. + Explain the implications of these findings for the project's security and reliability. + + Code Audit Data: + {data} + """, + "risk_factors": """ + Based on the provided data, identify and elaborate on the key risk factors + associated with the project. Categorize risks (e.g., technical, market, regulatory) + and discuss their potential impact and mitigation strategies. + + Risk Factors Data: + {data} + """ +} + def get_template(section_id: str) -> str: """ Retrieves a prompt template based on the section ID. """ - templates = { - "tokenomics": """ - Analyze the following tokenomics data and provide a comprehensive summary, - highlighting key aspects such as token distribution, vesting schedules, - inflation/deflation mechanisms, and any potential risks or advantages. - Focus on how these factors impact the long-term value and stability of the token. - - Tokenomics Data: - {data} - """, - "onchain_metrics": """ - Examine the provided on-chain metrics and generate an insightful analysis. - Cover aspects like active addresses, transaction volume, whale activity, - and network growth. Explain the implications of these metrics for the - project's health and adoption. - - On-chain Metrics Data: - {data} - """, - "sentiment": """ - Review the social sentiment data and summarize the overall market perception - of the project. Identify key themes, positive or negative trends, and - any significant events influencing sentiment. Discuss the potential impact - of this sentiment on the project's future. - - Sentiment Data: - {data} - """, - "team_analysis": """ - Analyze the team's background, experience, and contributions based on the - provided data. Assess the team's capability to execute the project roadmap - and highlight any strengths or weaknesses. - - Team Analysis Data: - {data} - """, - "documentation": """ - Evaluate the quality and completeness of the project's documentation. - Identify areas of excellence and areas needing improvement. Discuss how - effective documentation contributes to user adoption and developer engagement. - - Documentation Data: - {data} - """, - "code_audit": """ - Summarize the findings from the code audit report. Highlight critical - vulnerabilities, security best practices followed, and overall code quality. - Explain the implications of these findings for the project's security and reliability. - - Code Audit Data: - {data} - """, - "risk_factors": """ - Based on the provided data, identify and elaborate on the key risk factors - associated with the project. Categorize risks (e.g., technical, market, regulatory) - and discuss their potential impact and mitigation strategies. - - Risk Factors Data: - {data} - """ - } - return templates.get(section_id, "No template found for this section ID.") + return PROMPT_TEMPLATES.get(section_id, "No template found for this section ID.")
This PR introduces a new module for managing and dynamically filling prompt templates used in NLG report generation.
Changes
backend/app/services/nlg/prompt_templates.pyto house all prompt templates.{data}placeholders.prompt_templates.pyfor dynamically filling these templates with provided data.Summary by CodeRabbit
New Features
Bug Fixes / Reliability
Tests
✏️ Tip: You can customize this high-level summary in your review settings.