Skip to content

Commit

Permalink
[APP-3688] Revert chat api enable by default (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
kideh88 authored Jan 10, 2025
1 parent 87ea9d5 commit 5af1cd3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Chat API
CHAT_CAPABILITIES_KEY = 'supports_chat_api'
# To disable chat api even when deployment supports it. Default set to True until there is full support
FORCE_DISABLE_CHAT_API = False
FORCE_DISABLE_CHAT_API = True
ENABLE_CHAT_API_STREAMING = True

# Timeouts
Expand Down
2 changes: 1 addition & 1 deletion src/dr_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def send_chat_api_request(message):
data_str = chunk.decode('utf-8').lstrip("data: ")
data_json = json.loads(data_str)

if len(data_json['choices']) == 0:
if len(data_json.get('choices', [])) == 0:
continue

# Get completion content, e.g., choices[0].delta.content
Expand Down
2 changes: 1 addition & 1 deletion template_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
"source": {
"repositoryUrl": "https://github.com/datarobot-oss/qa-app-streamlit",
"releaseTag": "11.0.5"
"releaseTag": "11.0.6"
},
"previewImage": "qa-app-preview.png"
},
Expand Down
6 changes: 5 additions & 1 deletion tests/test_qa_chat_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
@patch('constants.I18N_SPLASH_TITLE', 'What would you like to know?')
@patch('constants.I18N_SPLASH_TEXT', 'Ask me anything!')
@patch('constants.I18N_INPUT_PLACEHOLDER', 'Send your question')
@patch('constants.FORCE_DISABLE_CHAT_API', False)
def test_empty_chat_app():
# Path to the CSV file relative to the test file
current_dir = os.path.dirname(__file__)
Expand Down Expand Up @@ -58,6 +59,7 @@ def test_empty_chat_app():
"mock_deployment_api",
"app_id"
)
@patch('constants.FORCE_DISABLE_CHAT_API', False)
def test_chat_api_supported_app():
"""The app loads and uses deployment capabilities to check for Chat API support"""
at = AppTest.from_file("qa_chat_bot.py").run()
Expand All @@ -72,6 +74,7 @@ def test_chat_api_supported_app():
"mock_deployment_chat_api_stream",
"mock_version_api",
)
@patch('constants.FORCE_DISABLE_CHAT_API', False)
def test_chat_send_chat_api_stream_request():
"""The app receives chat response after sending a prompt"""
app = AppTest.from_file("qa_chat_bot.py")
Expand Down Expand Up @@ -122,6 +125,7 @@ def test_chat_send_chat_api_stream_request():
"mock_deployment_chat_api",
"mock_version_api",
)
@patch('constants.FORCE_DISABLE_CHAT_API', False)
@patch('dr_requests.ENABLE_CHAT_API_STREAMING', False)
def test_chat_send_chat_api_without_stream_request():
"""The app receives chat response after sending a prompt"""
Expand Down Expand Up @@ -173,7 +177,6 @@ def test_chat_send_chat_api_without_stream_request():
"mock_deployment_api",
"mock_version_api",
)
@patch('constants.FORCE_DISABLE_CHAT_API', True)
def test_chat_send_predict_request():
"""The app receives chat response after sending a prompt"""
app = AppTest.from_file("qa_chat_bot.py")
Expand Down Expand Up @@ -228,6 +231,7 @@ def test_chat_send_predict_request():
"is_model_specific"
)
@pytest.mark.parametrize("is_model_specific", [True, False])
@patch('constants.FORCE_DISABLE_CHAT_API', False)
def test_chat_feedback_request(feedback_endpoint, model_id, is_model_specific):
"""The user can submit feedback for a response"""
app = AppTest.from_file("qa_chat_bot.py")
Expand Down

0 comments on commit 5af1cd3

Please sign in to comment.