Skip to content

Commit b7a629d

Browse files
committed
updating tags.json file location
1 parent 8c64eee commit b7a629d

File tree

4 files changed

+84
-18
lines changed

4 files changed

+84
-18
lines changed
28.8 KB
Binary file not shown.

discussion_labeler/basic.prompty

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ system:
5151
Discussion Title: "New feature request: Dark mode in Azure"
5252
Discussion Body: "Would love to see dark mode in the Azure portal."
5353
Tag List: ["feature-request", "ui-design"]
54-
Output: []
54+
Output: ["feature-request", "ui-design"]
5555

5656
user:
5757
Discussion Title: {{title}}

discussion_labeler/basic.py

Lines changed: 75 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -378,12 +378,20 @@ def run_with_rag(title: str, description: str) -> List[str]:
378378
List of tags
379379
"""
380380
try:
381-
# Load tags from JSON file with better error handling
381+
# Look for tags.json in the current directory and in the discussion_labeler directory
382382
tags_file_path = Path("tags.json")
383383
if not tags_file_path.exists():
384-
logger.error("tags.json file not found")
385-
return []
384+
# Try with discussion_labeler prefix
385+
tags_file_path = Path("discussion_labeler/tags.json")
386+
if not tags_file_path.exists():
387+
# Try with the absolute path from the current directory
388+
current_dir = Path(__file__).resolve().parent
389+
tags_file_path = current_dir / "tags.json"
390+
if not tags_file_path.exists():
391+
logger.error(f"tags.json file not found - searched in current dir, discussion_labeler/, and {current_dir}")
392+
return []
386393

394+
logger.info(f"Loading tags from: {tags_file_path}")
387395
with open(tags_file_path, "r") as f:
388396
tags_data = json.load(f)
389397

@@ -411,39 +419,87 @@ def run_with_rag(title: str, description: str) -> List[str]:
411419
# Combine search results with the original description
412420
augmented_description = description + "\n\n" + "\n".join(tag_strings)
413421

414-
# Execute the Prompty file
422+
# Execute the Prompty file - look in multiple directories
415423
prompty_file_path = Path("basic.prompty")
424+
prompty_file_name = "basic.prompty"
425+
416426
if not prompty_file_path.exists():
417-
logger.error("basic.prompty file not found")
418-
return []
427+
# Try with discussion_labeler prefix
428+
prompty_file_path = Path("discussion_labeler/basic.prompty")
429+
prompty_file_name = "discussion_labeler/basic.prompty"
419430

431+
if not prompty_file_path.exists():
432+
# Try with the absolute path from the current directory
433+
current_dir = Path(__file__).resolve().parent
434+
prompty_file_path = current_dir / "basic.prompty"
435+
prompty_file_name = str(prompty_file_path)
436+
437+
if not prompty_file_path.exists():
438+
logger.error(f"basic.prompty file not found - searched in current dir, discussion_labeler/, and {current_dir}")
439+
return []
440+
441+
logger.info(f"Using prompty file from: {prompty_file_path}")
420442
raw = prompty.execute(
421-
"basic.prompty",
443+
prompty_file_name,
422444
inputs={
423445
"title": title,
424446
"tags": azure_tags,
425447
"description": augmented_description
426448
}
427449
)
428450

451+
# Enhanced debugging for prompty output
452+
logger.info(f"Raw output from prompty: {raw}")
453+
429454
# Parse prompty's JSON output
430455
try:
456+
if not raw or raw.strip() == "None" or raw.strip() == "null":
457+
logger.error("Empty or null response from prompty")
458+
return []
459+
431460
parsed = json.loads(raw)
461+
logger.info(f"Parsed output type: {type(parsed)}, value: {parsed}")
462+
432463
# If prompty returns a bare list:
433464
if isinstance(parsed, list):
434-
return [str(item) for item in parsed] # Ensure all items are strings
465+
result = [str(item) for item in parsed] # Ensure all items are strings
466+
logger.info(f"Returning tag list: {result}")
467+
return result
468+
435469
# If it returns {"tags": [...]}:
436470
if isinstance(parsed, dict):
437471
tags = parsed.get("tags", [])
438-
return [str(item) for item in tags] # Ensure all items are strings
472+
result = [str(item) for item in tags] # Ensure all items are strings
473+
logger.info(f"Returning tags from dict: {result}")
474+
return result
475+
476+
logger.error(f"Unexpected parsed output format: {parsed}")
477+
return []
439478

440479
except json.JSONDecodeError as e:
441480
logger.error(f"Could not parse RAG output: {e}")
442-
logger.debug(f"RAG raw output: {raw}")
481+
logger.error(f"RAG raw output: {raw}")
482+
483+
# Try to return any valid strings that might be in the output
484+
if raw and isinstance(raw, str):
485+
# Try to clean the output if it looks like it might contain tags
486+
if "[" in raw and "]" in raw:
487+
try:
488+
# Extract the part between [ and ]
489+
tag_part = raw[raw.find("["): raw.rfind("]") + 1]
490+
cleaned = json.loads(tag_part)
491+
if isinstance(cleaned, list):
492+
logger.info(f"Recovered tags from malformed output: {cleaned}")
493+
return [str(item) for item in cleaned]
494+
except:
495+
pass
443496

444497
except Exception as e:
445498
logger.error(f"Error in run_with_rag: {str(e)}")
499+
import traceback
500+
logger.error(traceback.format_exc())
446501

502+
logger.warning("Returning empty tag list due to errors or no matches")
447503
return []
448504

449505
@trace
@@ -612,9 +668,17 @@ def process_discussions(repo: str = None) -> None:
612668
Args:
613669
repo: Repository URL in the format "owner/name" (optional)
614670
"""
671+
# Set the working directory to the script's location to ensure relative paths work
672+
script_dir = Path(__file__).resolve().parent
673+
os.chdir(script_dir)
674+
logger.info(f"Working directory set to: {os.getcwd()}")
675+
615676
if not repo:
616677
repo = DEFAULT_REPO
617-
678+
679+
logger.info(f"Processing discussions for repo: {repo}")
680+
logger.info(f"Using GitHub App ID: {APP_ID}")
681+
618682
try:
619683
# Validate GitHub App configuration
620684
validate_github_app_config()

discussion_labeler/tags.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,23 @@
66
{"name": "ai-services", "description": "Discussions about various AI services."},
77
{"name": "azure-ai-search", "description": "Topics related to Azure AI Search."},
88
{"name": "azure-openai", "description": "Discussions about Azure OpenAI services."},
9-
{"name": "bug", "description": "Issues indicating something isn't working."},
10-
{"name": "documentation", "description": "Suggestions for improvements or additions to documentation."},
9+
{"name": "bug", "description": "Something isn't working"},
10+
{"name": "documentation", "description": "Improvements or additions to documentation"},
1111
{"name": "dotnet-sdk", "description": "Discussions related to the .NET SDK."},
12-
{"name": "duplicate", "description": "Indicates that the issue or pull request already exists."},
13-
{"name": "idea", "description": "New feature ideas or requests."},
12+
{"name": "duplicate", "description": "This issue or pull request already exists"},
13+
{"name": "foundry-local", "description": "Discussions related to foundry-local"},
14+
{"name": "idea", "description": "New feature idea or request"},
1415
{"name": "integrations", "description": "Discussions about integrating with other services."},
15-
{"name": "invalid", "description": "Indicates that something doesn't seem right."},
16+
{"name": "invalid", "description": "This doesn't seem right"},
1617
{"name": "java-sdk", "description": "Discussions related to the Java SDK."},
1718
{"name": "javascript-sdk", "description": "Discussions related to the JavaScript SDK."},
1819
{"name": "mcp", "description": "Discussions related to MCP."},
20+
{"name": "Microsoft Fabric", "description": "Discussions related to Microsoft Fabric"},
1921
{"name": "observability", "description": "Topics concerning observability in Azure AI Foundry."},
2022
{"name": "python-sdk", "description": "Discussions related to the Python SDK."},
2123
{"name": "security", "description": "Discussions about security-related topics."},
2224
{"name": "semantic-kernel", "description": "Discussions related to the Semantic Kernel."},
2325
{"name": "Templates", "description": "Discussions about templates."},
24-
{"name": "wontfix", "description": "Indicates that the issue will not be worked on."}
26+
{"name": "wontfix", "description": "This will not be worked on"}
2527
]
2628
}

0 commit comments

Comments
 (0)