Skip to content

Commit 18d24d0

Browse files
Fix testcase - agentframework v2 - Refactor tests for ChatWithDataPlugin, ChatService, HistoryService, and App
- Removed test cases for deprecated agent factories in test_app.py. - Updated test cases in test_chat_with_data_plugin.py to reflect changes in the ChatWithDataPlugin implementation. - Refactored test cases in test_chat_service.py to remove dependencies on mock requests and streamline the setup. - Enhanced test_generate_title in test_history_service.py to utilize the new v2 agent framework. - Improved error handling tests in test_chat_service.py for rate limits and general exceptions. - Consolidated mock setups and assertions for clarity and maintainability.
1 parent bce02f4 commit 18d24d0

File tree

11 files changed

+416
-970
lines changed

11 files changed

+416
-970
lines changed

src/api/common/database/sqldb_service.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from helpers.azure_credential_utils import get_azure_credential_async
1010
import pyodbc
1111

12+
1213
class SQLTool(BaseModel):
1314
model_config = {"arbitrary_types_allowed": True}
1415
conn: pyodbc.Connection
@@ -27,6 +28,7 @@ async def get_sql_response(self, sql_query: str) -> str:
2728
if cursor:
2829
cursor.close()
2930

31+
3032
async def get_db_connection():
3133
"""Get a connection to the SQL database"""
3234
config = Config()

src/api/services/chat_service.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import json
1111
import logging
1212
import re
13-
import os
1413

1514
from helpers.azure_credential_utils import get_azure_credential_async
1615
from common.database.sqldb_service import SQLTool, get_db_connection as get_sqldb_connection
@@ -87,6 +86,7 @@ async def _delete_thread_async(self, thread_conversation_id: str):
8786
if credential is not None:
8887
await credential.close()
8988

89+
9090
class ChatService:
9191
"""
9292
Service for handling chat interactions, including streaming responses,
@@ -155,7 +155,7 @@ async def stream_openai_text(self, conversation_id: str, query: str) -> Streamin
155155
for content in chunk.contents:
156156
if hasattr(content, "annotations") and content.annotations:
157157
citations.extend(content.annotations)
158-
158+
159159
if first_chunk:
160160
if chunk is not None and chunk.text != "":
161161
first_chunk = False
@@ -166,6 +166,7 @@ async def stream_openai_text(self, conversation_id: str, query: str) -> Streamin
166166

167167
if ChatService.thread_cache is not None and thread is not None:
168168
ChatService.thread_cache[conversation_id] = thread_conversation_id
169+
169170
if citations:
170171
citation_list = [f"{{\"url\": \"{citation.url}\", \"title\": \"{citation.title}\"}}" for citation in citations]
171172
yield ", \"citations\": [" + ",".join(citation_list) + "]}"

src/tests/api/agents/test_base_agent_factory.py

Lines changed: 0 additions & 90 deletions
This file was deleted.

src/tests/api/agents/test_chart_agent_factory.py

Lines changed: 0 additions & 51 deletions
This file was deleted.

src/tests/api/agents/test_conversation_agent_factory.py

Lines changed: 0 additions & 108 deletions
This file was deleted.

0 commit comments

Comments
 (0)