Skip to content

feat: Stricter DevRel classification & GitHubToolkit fixes #128

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ TAVILY_API_KEY=
LANGSMITH_TRACING=
LANGSMITH_ENDPOINT=
LANGSMITH_API_KEY=
LANGSMITH_PROJECT=
LANGSMITH_PROJECT=

#Discord Bot Name Configuration
BOT_NAME = "DevRelBot" #Add your own Discord Bot name
Comment on lines +26 to +29
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix environment variable syntax and formatting issues

The new BOT_NAME environment variable has incorrect syntax with spaces around the equal sign and missing quotes around the value. Additionally, there are formatting issues that should be addressed.

Apply this diff to fix the syntax and formatting:

 LANGSMITH_PROJECT=
 
-#Discord Bot Name Configuration
-BOT_NAME = "DevRelBot" #Add your own Discord Bot name
+# Discord Bot Name Configuration
+BOT_NAME="DevRelBot" # Add your own Discord Bot name
+

This fixes:

  1. Removes spaces around the equal sign (environment variable syntax)
  2. Adds a space after # in the comment header for consistency
  3. Adds a space after # in the inline comment
  4. Adds a blank line at the end of the file
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
LANGSMITH_PROJECT=
#Discord Bot Name Configuration
BOT_NAME = "DevRelBot" #Add your own Discord Bot name
LANGSMITH_PROJECT=
# Discord Bot Name Configuration
BOT_NAME="DevRelBot" # Add your own Discord Bot name
🧰 Tools
🪛 dotenv-linter (3.3.0)

[warning] 26-26: [UnorderedKey] The LANGSMITH_PROJECT key should go before the LANGSMITH_TRACING key


[warning] 29-29: [EndingBlankLine] No blank line at the end of the file


[warning] 29-29: [SpaceCharacter] The line has spaces around equal sign


[warning] 29-29: [ValueWithoutQuotes] This value needs to be surrounded in quotes

🤖 Prompt for AI Agents
In backend/.env.example around lines 26 to 29, the BOT_NAME entry and nearby
comments have incorrect environment variable syntax and formatting; remove
spaces around the equal sign, set the value as BOT_NAME="DevRelBot" (no
surrounding spaces), add a space after the '#' in the comment header and the
inline comment for consistency, and ensure the file ends with a single blank
line.

4 changes: 2 additions & 2 deletions backend/app/agents/devrel/github/github_toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ async def execute(self, query: str) -> Dict[str, Any]:
if classification == "contributor_recommendation":
result = await handle_contributor_recommendation(query)
elif classification == "repo_support":
result = "Not implemented"
result = {"status": "not_implemented", "message": "Repo support not implemented yet"}
# result = await handle_repo_query(query)
elif classification == "issue_creation":
result = "Not implemented"
# result = await handle_issue_creation(query)
Comment on lines 110 to 111
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Inconsistent return type for issue_creation branch

While you fixed the repo_support and documentation_generation branches to return dictionaries, the issue_creation branch still returns a plain string "Not implemented", which will cause the same error when trying to augment it with intent_analysis and type at lines 120-121.

Apply this diff to maintain consistency:

             elif classification == "issue_creation":
-                result = "Not implemented"
+                result = {"status": "not_implemented", "message": "Issue creation not implemented yet"}
                 # result = await handle_issue_creation(query)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
result = "Not implemented"
# result = await handle_issue_creation(query)
elif classification == "issue_creation":
- result = "Not implemented"
+ result = {"status": "not_implemented", "message": "Issue creation not implemented yet"}
# result = await handle_issue_creation(query)
🤖 Prompt for AI Agents
In backend/app/agents/devrel/github/github_toolkit.py around lines 110-111, the
issue_creation branch returns a plain string "Not implemented" while other
branches return dictionaries; change that branch to return a dictionary (e.g.,
{'result': 'Not implemented'}) so the code downstream can augment it with
intent_analysis and type without errors, and ensure the dict shape matches the
repo_support/documentation_generation branches.

elif classification == "documentation_generation":
result = "Not implemented"
result = {"status": "not_implemented", "message": "Documentation generation is not yet implemented"}
# result = await handle_documentation_generation(query)
elif classification == "web_search":
result = await handle_web_search(query)
Expand Down
34 changes: 22 additions & 12 deletions backend/app/classification/classification_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,34 @@
logger = logging.getLogger(__name__)

class ClassificationRouter:
"""Simple DevRel triage - determines if message needs DevRel assistance"""
"""Strict DevRel triage - determines if message needs DevRel assistance"""

def __init__(self, llm_client=None):
self.bot_name = settings.bot_name.lower()
self.llm = llm_client or ChatGoogleGenerativeAI(
model=settings.classification_agent_model,
temperature=0.1,
google_api_key=settings.gemini_api_key
)

async def should_process_message(self, message: str, context: Dict[str, Any] = None) -> Dict[str, Any]:
"""Simple triage: Does this message need DevRel assistance?"""
"""Strict triage: Does this message need DevRel assistance?"""
try:
# Detect explicit bot mention
mention_flag = False
if self.bot_name in message.lower():
mention_flag = True
# Add note to the context so LLM knows it was mentioned
context = (context or '') + f" | Note: This message explicitly mentions the bot '{self.bot_name}'."

triage_prompt = DEVREL_TRIAGE_PROMPT.format(
message=message,
context=context or 'No additional context'
)

response = await self.llm.ainvoke([HumanMessage(content=triage_prompt)])

response_text = response.content.strip()

if '{' in response_text:
json_start = response_text.find('{')
json_end = response_text.rfind('}') + 1
Expand All @@ -37,23 +45,25 @@ async def should_process_message(self, message: str, context: Dict[str, Any] = N
result = json.loads(json_str)

return {
"needs_devrel": result.get("needs_devrel", True),
"needs_devrel": result.get("needs_devrel", False),
"priority": result.get("priority", "medium"),
"reasoning": result.get("reasoning", "LLM classification"),
"original_message": message
"original_message": message,
"bot_mentioned": mention_flag
}

return self._fallback_triage(message)
return self._fallback_triage(message, mention_flag)

except Exception as e:
logger.error(f"Triage error: {str(e)}")
return self._fallback_triage(message)

def _fallback_triage(self, message: str) -> Dict[str, Any]:
"""Fallback: assume it needs DevRel help"""
def _fallback_triage(self, message: str, mention_flag=False) -> Dict[str, Any]:
"""Fallback: only trigger DevRel if bot was mentioned and message looks relevant"""
return {
"needs_devrel": True,
"priority": "medium",
"reasoning": "Fallback - assuming DevRel assistance needed",
"original_message": message
"needs_devrel": mention_flag,
"priority": "medium" if mention_flag else "low",
"reasoning": "Fallback - bot mention" if mention_flag else "Fallback - no DevRel assistance",
"original_message": message,
"bot_mentioned": mention_flag
}
1 change: 1 addition & 0 deletions backend/app/core/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Settings(BaseSettings):
# Platforms
github_token: str = ""
discord_bot_token: str = ""
bot_name: str = "DevRelBot" # 👈 Default bot name, can override via .env

# DB configuration
supabase_url: str
Expand Down