-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscanner_client.py
More file actions
31 lines (27 loc) · 1.21 KB
/
Copy pathscanner_client.py
File metadata and controls
31 lines (27 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from mcp import ClientSession
from mcp.client.sse import sse_client
from CustomLLM import CustomLLM
from prompt import scanner_prompt
import asyncio
customllm = CustomLLM()
class ScannerClient:
def __init__(self, folder_path):
self.folder_path = folder_path
async def scan(self):
async with sse_client(url="http://localhost:8000/sse") as (read, write):
async with ClientSession(read, write) as session:
if hasattr(session, "initialize"):
await session.initialize()
file_content = await session.call_tool("concatenate_smalltalk_files", {"folder_path": self.folder_path})
file_content = file_content.content[0].text
prompt = (
scanner_prompt +
"\nHere is the original project code to be scanned:\n" +
file_content
)
response = customllm.generate_response(prompt=prompt)
return response
async def get_scanned(self):
return await self.scan()
# scanner = ScannerClient(folder_path= "C:/Users/anhkh/Downloads/Github/Legacy Code Migration Tool/smalltalk_project")
# print(scanner.get_scanned())