Skip to content

Commit 44b0586

Browse files
fix: Kernel Function Method Renaming for Clarity
2 parents 89a34e1 + 8a0b811 commit 44b0586

File tree

2 files changed

+21
-23
lines changed

2 files changed

+21
-23
lines changed

src/api/plugins/chat_with_data_plugin.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ def __init__(self):
3636
self.azure_ai_search_index = config.azure_ai_search_index
3737
self.use_ai_project_client = config.use_ai_project_client
3838

39-
@kernel_function(name="ChatWithSQLDatabase",
39+
@kernel_function(name="GetDatabaseMetrics",
4040
description="Provides quantified results from the database.")
41-
async def get_sql_response(
41+
async def get_database_metrics(
4242
self,
4343
input: Annotated[str, "the question"]
4444
):
@@ -94,8 +94,8 @@ async def get_sql_response(
9494

9595
return answer
9696

97-
@kernel_function(name="ChatWithCallTranscripts", description="Provides summaries or detailed explanations from the search index.")
98-
async def get_answers_from_calltranscripts(
97+
@kernel_function(name="GetCallInsights", description="Provides summaries, explanations, and insights from customer call transcripts.")
98+
async def get_call_insights(
9999
self,
100100
question: Annotated[str, "the question"]
101101
):
@@ -168,13 +168,12 @@ def replace_marker(match):
168168
return answer
169169

170170
@kernel_function(name="GenerateChartData", description="Generates Chart.js v4.4.4 compatible JSON data for data visualization requests using current and immediate previous context.")
171-
async def get_chart_data(
171+
async def generate_chart_data(
172172
self,
173173
input: Annotated[str, "The user's data visualization request along with relevant conversation history and context needed to generate appropriate chart data"],
174174
):
175175
query = input
176176
query = query.strip()
177-
print("Query for chart data:", query, flush=True)
178177
try:
179178
agent_info = await ChartAgentFactory.get_agent()
180179
agent = agent_info["agent"]
@@ -208,5 +207,4 @@ async def get_chart_data(
208207

209208
except Exception:
210209
chartdata = 'Details could not be retrieved. Please try again later.'
211-
print("Chart data:", chartdata, flush=True)
212210
return chartdata

src/tests/api/plugins/test_chat_with_data_plugin.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class TestChatWithDataPlugin:
2929
@pytest.mark.asyncio
3030
@patch("plugins.chat_with_data_plugin.execute_sql_query", new_callable=AsyncMock)
3131
@patch("plugins.chat_with_data_plugin.SQLAgentFactory.get_agent", new_callable=AsyncMock)
32-
async def test_get_sql_response_with_sql_agent(self, mock_get_agent, mock_execute_sql, chat_plugin):
32+
async def test_get_database_metrics_with_sql_agent(self, mock_get_agent, mock_execute_sql, chat_plugin):
3333
# Mocks
3434
mock_agent = MagicMock()
3535
mock_agent.id = "agent-id"
@@ -63,7 +63,7 @@ async def test_get_sql_response_with_sql_agent(self, mock_get_agent, mock_execut
6363
mock_client.agents.threads.delete.return_value = None
6464

6565
# Act
66-
result = await chat_plugin.get_sql_response("Total number of calls by date for last 7 days")
66+
result = await chat_plugin.get_database_metrics("Total number of calls by date for last 7 days")
6767

6868
# Assert
6969
assert result == "(datetime.date(2025, 6, 27), 11)(datetime.date(2025, 6, 28), 20)(datetime.date(2025, 6, 29), 29)(datetime.date(2025, 6, 30), 17)(datetime.date(2025, 7, 1), 19)(datetime.date(2025, 7, 2), 16)"
@@ -77,12 +77,12 @@ async def test_get_sql_response_with_sql_agent(self, mock_get_agent, mock_execut
7777
@pytest.mark.asyncio
7878
@patch("plugins.chat_with_data_plugin.execute_sql_query")
7979
@patch("plugins.chat_with_data_plugin.SQLAgentFactory.get_agent", new_callable=AsyncMock)
80-
async def test_get_sql_response_exception(self, mock_get_agent, mock_execute_sql, chat_plugin):
80+
async def test_get_database_metrics_exception(self, mock_get_agent, mock_execute_sql, chat_plugin):
8181
# Setup mock to raise exception
8282
mock_get_agent.side_effect = Exception("Test error")
8383

8484
# Call the method
85-
result = await chat_plugin.get_sql_response("Show me data")
85+
result = await chat_plugin.get_database_metrics("Show me data")
8686

8787
# Assertions
8888
assert result == "Details could not be retrieved. Please try again later."
@@ -91,7 +91,7 @@ async def test_get_sql_response_exception(self, mock_get_agent, mock_execute_sql
9191

9292
@pytest.mark.asyncio
9393
@patch("plugins.chat_with_data_plugin.SearchAgentFactory.get_agent", new_callable=AsyncMock)
94-
async def test_get_answers_from_calltranscripts_success(self, mock_get_agent, chat_plugin):
94+
async def test_get_call_insights_success(self, mock_get_agent, chat_plugin):
9595
# Use the fixture passed by pytest
9696
self.chat_plugin = chat_plugin # or just use `chat_plugin` directly
9797

@@ -138,7 +138,7 @@ async def test_get_answers_from_calltranscripts_success(self, mock_get_agent, ch
138138
mock_client.agents.threads.delete.return_value = None
139139

140140
# Call the method
141-
result = await chat_plugin.get_answers_from_calltranscripts("What is the summary?")
141+
result = await chat_plugin.get_call_insights("What is the summary?")
142142

143143
# Assert
144144
assert isinstance(result, dict)
@@ -147,19 +147,19 @@ async def test_get_answers_from_calltranscripts_success(self, mock_get_agent, ch
147147

148148
@pytest.mark.asyncio
149149
@patch("plugins.chat_with_data_plugin.SearchAgentFactory.get_agent", new_callable=AsyncMock)
150-
async def test_get_answers_from_calltranscripts_exception(self, mock_get_agent, chat_plugin):
150+
async def test_get_call_insights_exception(self, mock_get_agent, chat_plugin):
151151
# Setup the mock to raise an exception
152152
mock_get_agent.side_effect = Exception("Test error")
153153

154154
# Call the method
155-
result = await chat_plugin.get_answers_from_calltranscripts("Sample question")
155+
result = await chat_plugin.get_call_insights("Sample question")
156156

157157
# Assertions
158158
assert result == "Details could not be retrieved. Please try again later."
159159

160160
@pytest.mark.asyncio
161161
@patch("plugins.chat_with_data_plugin.ChartAgentFactory.get_agent", new_callable=AsyncMock)
162-
async def test_get_chart_data_success(self, mock_get_agent, chat_plugin):
162+
async def test_generate_chart_data_success(self, mock_get_agent, chat_plugin):
163163
# Mock agent and client setup
164164
mock_agent = MagicMock()
165165
mock_agent.id = "chart-agent-id"
@@ -187,7 +187,7 @@ async def test_get_chart_data_success(self, mock_get_agent, chat_plugin):
187187
mock_client.agents.threads.delete.return_value = None
188188

189189
# Call the method with combined input
190-
result = await chat_plugin.get_chart_data(
190+
result = await chat_plugin.generate_chart_data(
191191
"Create a bar chart. Total calls by date: 2025-06-27: 11, 2025-06-28: 20"
192192
)
193193

@@ -208,7 +208,7 @@ async def test_get_chart_data_success(self, mock_get_agent, chat_plugin):
208208

209209
@pytest.mark.asyncio
210210
@patch("plugins.chat_with_data_plugin.ChartAgentFactory.get_agent", new_callable=AsyncMock)
211-
async def test_get_chart_data_failed_run(self, mock_get_agent, chat_plugin):
211+
async def test_generate_chart_data_failed_run(self, mock_get_agent, chat_plugin):
212212
# Mock agent and client setup
213213
mock_agent = MagicMock()
214214
mock_agent.id = "chart-agent-id"
@@ -227,7 +227,7 @@ async def test_get_chart_data_failed_run(self, mock_get_agent, chat_plugin):
227227
mock_client.agents.runs.create_and_process.return_value = mock_run
228228

229229
# Call the method with single input parameter
230-
result = await chat_plugin.get_chart_data("Create a chart with some data")
230+
result = await chat_plugin.generate_chart_data("Create a chart with some data")
231231

232232
# Assert
233233
assert result == "Details could not be retrieved. Please try again later."
@@ -240,19 +240,19 @@ async def test_get_chart_data_failed_run(self, mock_get_agent, chat_plugin):
240240

241241
@pytest.mark.asyncio
242242
@patch("plugins.chat_with_data_plugin.ChartAgentFactory.get_agent", new_callable=AsyncMock)
243-
async def test_get_chart_data_exception(self, mock_get_agent, chat_plugin):
243+
async def test_generate_chart_data_exception(self, mock_get_agent, chat_plugin):
244244
# Setup mock to raise exception
245245
mock_get_agent.side_effect = Exception("Chart agent error")
246246

247247
# Call the method with single input parameter
248-
result = await chat_plugin.get_chart_data("Create a chart with some data")
248+
result = await chat_plugin.generate_chart_data("Create a chart with some data")
249249

250250
# Assert
251251
assert result == "Details could not be retrieved. Please try again later."
252252

253253
@pytest.mark.asyncio
254254
@patch("plugins.chat_with_data_plugin.ChartAgentFactory.get_agent", new_callable=AsyncMock)
255-
async def test_get_chart_data_empty_response(self, mock_get_agent, chat_plugin):
255+
async def test_generate_chart_data_empty_response(self, mock_get_agent, chat_plugin):
256256
# Mock agent and client setup
257257
mock_agent = MagicMock()
258258
mock_agent.id = "chart-agent-id"
@@ -276,7 +276,7 @@ async def test_get_chart_data_empty_response(self, mock_get_agent, chat_plugin):
276276
mock_client.agents.threads.delete.return_value = None
277277

278278
# Call the method with single input parameter
279-
result = await chat_plugin.get_chart_data("Create a chart with some data")
279+
result = await chat_plugin.generate_chart_data("Create a chart with some data")
280280

281281
# Assert - should return empty string when no agent messages found
282282
assert result == ""

0 commit comments

Comments
 (0)