mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-11 13:20:58 +00:00
style: fix ruff format issues in plugin_diagnostics and test_handler_actions
This commit is contained in:
@@ -216,9 +216,7 @@ def _build_plugin_sources(
|
|||||||
if response_sources is not None:
|
if response_sources is not None:
|
||||||
plugin_refs = [_extract_response_source_plugin_ref(source) for source in response_sources]
|
plugin_refs = [_extract_response_source_plugin_ref(source) for source in response_sources]
|
||||||
return [
|
return [
|
||||||
PluginResponseSource(plugin=plugin, event_name=event_name)
|
PluginResponseSource(plugin=plugin, event_name=event_name) for plugin in plugin_refs if plugin is not None
|
||||||
for plugin in plugin_refs
|
|
||||||
if plugin is not None
|
|
||||||
]
|
]
|
||||||
|
|
||||||
if emitted_plugins:
|
if emitted_plugins:
|
||||||
|
|||||||
@@ -51,13 +51,15 @@ class TestRagRerankAction:
|
|||||||
app.model_mgr.get_rerank_model_by_uuid = AsyncMock(return_value=rerank_model)
|
app.model_mgr.get_rerank_model_by_uuid = AsyncMock(return_value=rerank_model)
|
||||||
runtime_handler = make_handler(app)
|
runtime_handler = make_handler(app)
|
||||||
|
|
||||||
response = await runtime_handler.actions[PluginToRuntimeAction.INVOKE_RERANK.value]({
|
response = await runtime_handler.actions[PluginToRuntimeAction.INVOKE_RERANK.value](
|
||||||
'rerank_model_uuid': 'rerank-1',
|
{
|
||||||
'query': 'hello',
|
'rerank_model_uuid': 'rerank-1',
|
||||||
'documents': ['a', 'b'],
|
'query': 'hello',
|
||||||
'top_k': 1,
|
'documents': ['a', 'b'],
|
||||||
'extra_args': {'return_documents': False},
|
'top_k': 1,
|
||||||
})
|
'extra_args': {'return_documents': False},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
assert response.code == 0
|
assert response.code == 0
|
||||||
assert response.data['results'] == [{'index': 1, 'relevance_score': 0.9}]
|
assert response.data['results'] == [{'index': 1, 'relevance_score': 0.9}]
|
||||||
@@ -72,16 +74,16 @@ class TestRagRerankAction:
|
|||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_returns_error_when_rerank_model_missing(self, app):
|
async def test_returns_error_when_rerank_model_missing(self, app):
|
||||||
"""Missing rerank model returns an action error."""
|
"""Missing rerank model returns an action error."""
|
||||||
app.model_mgr.get_rerank_model_by_uuid = AsyncMock(
|
app.model_mgr.get_rerank_model_by_uuid = AsyncMock(side_effect=ValueError('not found'))
|
||||||
side_effect=ValueError('not found')
|
|
||||||
)
|
|
||||||
runtime_handler = make_handler(app)
|
runtime_handler = make_handler(app)
|
||||||
|
|
||||||
response = await runtime_handler.actions[PluginToRuntimeAction.INVOKE_RERANK.value]({
|
response = await runtime_handler.actions[PluginToRuntimeAction.INVOKE_RERANK.value](
|
||||||
'rerank_model_uuid': 'missing',
|
{
|
||||||
'query': 'hello',
|
'rerank_model_uuid': 'missing',
|
||||||
'documents': ['a'],
|
'query': 'hello',
|
||||||
})
|
'documents': ['a'],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
assert response.code != 0
|
assert response.code != 0
|
||||||
assert 'Rerank model with rerank_model_uuid missing not found' in response.message
|
assert 'Rerank model with rerank_model_uuid missing not found' in response.message
|
||||||
|
|||||||
Reference in New Issue
Block a user