Spaces:
Running
Running
Germano Cavalcante
commited on
Commit
•
92238be
1
Parent(s):
1417758
Tool Calls: Implement Find Related
Browse files- routers/tool_calls.py +20 -2
- routers/tool_find_related.py +5 -4
routers/tool_calls.py
CHANGED
@@ -1,11 +1,18 @@
|
|
1 |
import json
|
2 |
import logging
|
3 |
-
from .tool_gpu_checker import gpu_checker_get_message
|
4 |
-
from .tool_bpy_doc import bpy_doc_get_documentation
|
5 |
from fastapi import APIRouter, Body
|
6 |
from typing import List, Dict
|
7 |
from pydantic import BaseModel
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
class ToolCallFunction(BaseModel):
|
11 |
name: str
|
@@ -33,6 +40,9 @@ def process_tool_call(tool_call: ToolCallInput) -> Dict:
|
|
33 |
elif function_name == "check_gpu":
|
34 |
output["output"] = gpu_checker_get_message(
|
35 |
function_args.get("gpu", ""))
|
|
|
|
|
|
|
36 |
except json.JSONDecodeError as e:
|
37 |
error_message = f"Malformed JSON encountered at position {e.pos}: {e.msg}\n {tool_call.function.arguments}"
|
38 |
output["output"] = error_message
|
@@ -73,6 +83,14 @@ if __name__ == "__main__":
|
|
73 |
"name": "check_gpu",
|
74 |
"arguments": "{\"gpu\":\"Mesa Intel(R) Iris(R) Plus Graphics 640 (Kaby Lake GT3e) (KBL GT3) Intel 4.6 (Core Profile) Mesa 22.2.5\"}"
|
75 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
}
|
77 |
]
|
78 |
|
|
|
1 |
import json
|
2 |
import logging
|
|
|
|
|
3 |
from fastapi import APIRouter, Body
|
4 |
from typing import List, Dict
|
5 |
from pydantic import BaseModel
|
6 |
|
7 |
+
try:
|
8 |
+
from .tool_gpu_checker import gpu_checker_get_message
|
9 |
+
from .tool_bpy_doc import bpy_doc_get_documentation
|
10 |
+
from .tool_find_related import find_relatedness
|
11 |
+
except:
|
12 |
+
from tool_gpu_checker import gpu_checker_get_message
|
13 |
+
from tool_bpy_doc import bpy_doc_get_documentation
|
14 |
+
from tool_find_related import find_relatedness
|
15 |
+
|
16 |
|
17 |
class ToolCallFunction(BaseModel):
|
18 |
name: str
|
|
|
40 |
elif function_name == "check_gpu":
|
41 |
output["output"] = gpu_checker_get_message(
|
42 |
function_args.get("gpu", ""))
|
43 |
+
elif function_name == "find_related":
|
44 |
+
output["output"] = find_relatedness(
|
45 |
+
function_args["repo"], function_args["number"])
|
46 |
except json.JSONDecodeError as e:
|
47 |
error_message = f"Malformed JSON encountered at position {e.pos}: {e.msg}\n {tool_call.function.arguments}"
|
48 |
output["output"] = error_message
|
|
|
83 |
"name": "check_gpu",
|
84 |
"arguments": "{\"gpu\":\"Mesa Intel(R) Iris(R) Plus Graphics 640 (Kaby Lake GT3e) (KBL GT3) Intel 4.6 (Core Profile) Mesa 22.2.5\"}"
|
85 |
}
|
86 |
+
},
|
87 |
+
{
|
88 |
+
"id": "call_abc789",
|
89 |
+
"type": "function",
|
90 |
+
"function": {
|
91 |
+
"name": "find_related",
|
92 |
+
"arguments": "{\"repo\":\"blender\",\"number\":111434}"
|
93 |
+
}
|
94 |
}
|
95 |
]
|
96 |
|
routers/tool_find_related.py
CHANGED
@@ -14,6 +14,7 @@ try:
|
|
14 |
except:
|
15 |
from utils_gitea import gitea_fetch_issues, gitea_json_issue_get
|
16 |
|
|
|
17 |
def _create_issue_string(title, body):
|
18 |
cleaned_body = body.replace('\r', '')
|
19 |
cleaned_body = cleaned_body.replace('**System Information**\n', '')
|
@@ -364,7 +365,8 @@ def text_search(owner, repo, text_to_embed, limit=None):
|
|
364 |
return result[:limit]
|
365 |
|
366 |
|
367 |
-
def find_relatedness(
|
|
|
368 |
assert gitea_issue['repository']['owner'] == 'blender'
|
369 |
repo = gitea_issue['repository']['name']
|
370 |
title = gitea_issue['title']
|
@@ -399,9 +401,8 @@ def find_relatedness(gitea_issue, limit=20):
|
|
399 |
|
400 |
|
401 |
@router.get("/find_related/{repo}/{number}")
|
402 |
-
def find_related(repo: str = 'blender', number: int = 104399, limit: int =
|
403 |
-
|
404 |
-
related = find_relatedness(issue, limit=limit)
|
405 |
return related
|
406 |
|
407 |
|
|
|
14 |
except:
|
15 |
from utils_gitea import gitea_fetch_issues, gitea_json_issue_get
|
16 |
|
17 |
+
|
18 |
def _create_issue_string(title, body):
|
19 |
cleaned_body = body.replace('\r', '')
|
20 |
cleaned_body = cleaned_body.replace('**System Information**\n', '')
|
|
|
365 |
return result[:limit]
|
366 |
|
367 |
|
368 |
+
def find_relatedness(repo, number, limit=20):
|
369 |
+
gitea_issue = gitea_json_issue_get('blender', repo, number)
|
370 |
assert gitea_issue['repository']['owner'] == 'blender'
|
371 |
repo = gitea_issue['repository']['name']
|
372 |
title = gitea_issue['title']
|
|
|
401 |
|
402 |
|
403 |
@router.get("/find_related/{repo}/{number}")
|
404 |
+
def find_related(repo: str = 'blender', number: int = 104399, limit: int = 15):
|
405 |
+
related = find_relatedness(repo, number, limit=limit)
|
|
|
406 |
return related
|
407 |
|
408 |
|