-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdependency_client.py
More file actions
34 lines (29 loc) · 1.34 KB
/
Copy pathdependency_client.py
File metadata and controls
34 lines (29 loc) · 1.34 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
32
33
34
from mcp import ClientSession
from mcp.client.sse import sse_client
from CustomLLM import CustomLLM
from prompt import *
import asyncio
from scanner_client import customllm
class DependencyClient:
def __init__(self, java_code_file_path, project_summary):
self.java_code_file_path = java_code_file_path
self.project_summary = project_summary
async def dependency(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()
java_code = await session.call_tool("load_file", {"folder_path": self.java_code_file_path})
java_code = java_code.content[0].text
prompt = (
"Here is your task:\n" +
dependency_prompt +
"\nHere is the project summary for reference:\n" +
self.project_summary +
"\nHere is the converted java code that you are making the dependencies for:\n" +
java_code
)
response = customllm.generate_response(prompt=prompt)
return response
async def get_dependency(self):
return await self.dependency()