|
52 | 52 | from mcpgateway.services.tool_service import ToolService |
53 | 53 | from mcpgateway.toolops.utils.db_util import populate_testcases_table, query_testcases_table, query_tool_auth |
54 | 54 | from mcpgateway.toolops.utils.format_conversion import convert_to_toolops_spec, post_process_nl_test_cases |
55 | | -from mcpgateway.toolops.utils.llm_util import chat_llm_instance, get_llm_instance |
| 55 | +from mcpgateway.toolops.utils.llm_util import get_llm_instance |
56 | 56 |
|
57 | | -# importing toolops modules from ALTK |
| 57 | +logging_service = LoggingService() |
| 58 | +logger = logging_service.get_logger(__name__) |
58 | 59 |
|
59 | 60 |
|
60 | 61 | toolops_llm_provider = os.getenv("LLM_PROVIDER") |
61 | 62 | toolops_llm, toolops_llm_provider_config = get_llm_instance() |
62 | 63 | if toolops_llm is not None and toolops_llm_provider_config is not None: |
63 | | - toolops_llm_config = LLMConfig(provider=toolops_llm_provider, config=toolops_llm_provider_config) |
64 | | - |
65 | | -logging_service = LoggingService() |
66 | | -logger = logging_service.get_logger(__name__) |
| 64 | + TOOLOPS_LLM_CONFIG = LLMConfig(provider=toolops_llm_provider, config=toolops_llm_provider_config) |
| 65 | +else: |
| 66 | + logger.error("Error in obtaining LLM instance for Toolops services") |
| 67 | + TOOLOPS_LLM_CONFIG = None |
67 | 68 |
|
68 | 69 | LLM_MODEL_ID = os.getenv("OPENAI_MODEL", "") |
69 | 70 | provider = os.getenv("OPENAI_BASE_URL", "") |
@@ -102,6 +103,7 @@ def custom_mcp_cf_execute_prompt(prompt, client=None, gen_mode=None, parameters= |
102 | 103 | # To suppress pylint errors creating dummy altk params and asserting |
103 | 104 | altk_dummy_params = {"client": client, "gen_mode": gen_mode, "parameters": parameters, "max_new_tokens": max_new_tokens, "stop_sequences": stop_sequences} |
104 | 105 | assert altk_dummy_params is not None |
| 106 | + chat_llm_instance, _ = get_llm_instance(model_type="chat") |
105 | 107 | llm_response = chat_llm_instance.invoke(prompt) |
106 | 108 | response = llm_response.content |
107 | 109 | return response |
@@ -203,11 +205,11 @@ async def execute_tool_nl_test_cases(tool_id, tool_nl_test_cases, tool_service: |
203 | 205 | tool_auth = query_tool_auth(tool_id, db) |
204 | 206 | # handling transport based on protocol type |
205 | 207 | if "/mcp" in tool_url: |
206 | | - config = MCPClientConfig(mcp_server=MCPServerConfig(url=tool_url, transport="streamable_http", headers=tool_auth), llm=toolops_llm_config) |
| 208 | + config = MCPClientConfig(mcp_server=MCPServerConfig(url=tool_url, transport="streamable_http", headers=tool_auth), llm=TOOLOPS_LLM_CONFIG) |
207 | 209 | elif "/sse" in tool_url: |
208 | | - config = MCPClientConfig(mcp_server=MCPServerConfig(url=tool_url, transport="sse", headers=tool_auth), llm=toolops_llm_config) |
| 210 | + config = MCPClientConfig(mcp_server=MCPServerConfig(url=tool_url, transport="sse", headers=tool_auth), llm=TOOLOPS_LLM_CONFIG) |
209 | 211 | else: |
210 | | - config = MCPClientConfig(mcp_server=MCPServerConfig(url=tool_url, transport="stdio", headers=tool_auth), llm=toolops_llm_config) |
| 212 | + config = MCPClientConfig(mcp_server=MCPServerConfig(url=tool_url, transport="stdio", headers=tool_auth), llm=TOOLOPS_LLM_CONFIG) |
211 | 213 |
|
212 | 214 | service = MCPChatService(config) |
213 | 215 | await service.initialize() |
|
0 commit comments