release/v2.2 -> master (#733)

This commit is contained in:
cybermaggedon 2026-03-29 20:27:25 +01:00 committed by GitHub
parent 3ed71a5620
commit 2449392896
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 774 additions and 1111 deletions

View file

@ -93,7 +93,7 @@ class TestTextCompletionIntegration:
assert call_args.kwargs['model'] == "gpt-3.5-turbo"
assert call_args.kwargs['temperature'] == 0.7
assert call_args.kwargs['max_tokens'] == 1024
assert call_args.kwargs['max_completion_tokens'] == 1024
assert len(call_args.kwargs['messages']) == 1
assert call_args.kwargs['messages'][0]['role'] == "user"
assert "You are a helpful assistant." in call_args.kwargs['messages'][0]['content'][0]['text']
@ -134,7 +134,7 @@ class TestTextCompletionIntegration:
call_args = mock_openai_client.chat.completions.create.call_args
assert call_args.kwargs['model'] == config['model']
assert call_args.kwargs['temperature'] == config['temperature']
assert call_args.kwargs['max_tokens'] == config['max_output']
assert call_args.kwargs['max_completion_tokens'] == config['max_output']
# Reset mock for next iteration
mock_openai_client.reset_mock()
@ -286,7 +286,7 @@ class TestTextCompletionIntegration:
# were removed in #561 as unnecessary parameters
assert 'model' in call_args.kwargs
assert 'temperature' in call_args.kwargs
assert 'max_tokens' in call_args.kwargs
assert 'max_completion_tokens' in call_args.kwargs
# Verify result structure
assert hasattr(result, 'text')
@ -362,7 +362,7 @@ class TestTextCompletionIntegration:
call_args = mock_openai_client.chat.completions.create.call_args
assert call_args.kwargs['model'] == "gpt-4"
assert call_args.kwargs['temperature'] == 0.8
assert call_args.kwargs['max_tokens'] == 2048
assert call_args.kwargs['max_completion_tokens'] == 2048
# Note: top_p, frequency_penalty, and presence_penalty
# were removed in #561 as unnecessary parameters

View file

@ -201,7 +201,7 @@ class TestTextCompletionStreaming:
call_args = mock_streaming_openai_client.chat.completions.create.call_args
assert call_args.kwargs['model'] == "gpt-4"
assert call_args.kwargs['temperature'] == 0.5
assert call_args.kwargs['max_tokens'] == 2048
assert call_args.kwargs['max_completion_tokens'] == 2048
assert call_args.kwargs['stream'] is True
# Verify chunks have correct model

View file

@ -121,7 +121,11 @@ class TestMux:
# Based on the code, it seems to catch exceptions
await mux.receive(mock_msg)
mock_ws.send_json.assert_called_once_with({"error": "Bad message"})
mock_ws.send_json.assert_called_once_with({
"error": {"message": "Bad message", "type": "error"},
"complete": True,
"id": "test-id-123",
})
@pytest.mark.asyncio
async def test_mux_receive_message_without_id(self):
@ -129,23 +133,26 @@ class TestMux:
mock_dispatcher_manager = MagicMock()
mock_ws = AsyncMock()
mock_running = MagicMock()
mux = Mux(
dispatcher_manager=mock_dispatcher_manager,
ws=mock_ws,
running=mock_running
)
# Mock message without id field
mock_msg = MagicMock()
mock_msg.json.return_value = {
"request": {"type": "test"}
}
# receive method should handle the RuntimeError internally
await mux.receive(mock_msg)
mock_ws.send_json.assert_called_once_with({"error": "Bad message"})
mock_ws.send_json.assert_called_once_with({
"error": {"message": "Bad message", "type": "error"},
"complete": True,
})
@pytest.mark.asyncio
async def test_mux_receive_invalid_json(self):
@ -153,19 +160,22 @@ class TestMux:
mock_dispatcher_manager = MagicMock()
mock_ws = AsyncMock()
mock_running = MagicMock()
mux = Mux(
dispatcher_manager=mock_dispatcher_manager,
ws=mock_ws,
running=mock_running
)
# Mock message with invalid JSON
mock_msg = MagicMock()
mock_msg.json.side_effect = ValueError("Invalid JSON")
# receive method should handle the ValueError internally
await mux.receive(mock_msg)
mock_msg.json.assert_called_once()
mock_ws.send_json.assert_called_once_with({"error": "Invalid JSON"})
mock_ws.send_json.assert_called_once_with({
"error": {"message": "Invalid JSON", "type": "error"},
"complete": True,
})

View file

@ -108,7 +108,7 @@ class TestAzureOpenAIProcessorSimple(IsolatedAsyncioTestCase):
}]
}],
temperature=0.0,
max_tokens=4192,
max_completion_tokens=4192,
top_p=1
)
@ -399,7 +399,7 @@ class TestAzureOpenAIProcessorSimple(IsolatedAsyncioTestCase):
# Verify other parameters
assert call_args[1]['model'] == 'gpt-4'
assert call_args[1]['temperature'] == 0.5
assert call_args[1]['max_tokens'] == 1024
assert call_args[1]['max_completion_tokens'] == 1024
assert call_args[1]['top_p'] == 1
@patch('trustgraph.model.text_completion.azure_openai.llm.AzureOpenAI')

View file

@ -102,7 +102,7 @@ class TestOpenAIProcessorSimple(IsolatedAsyncioTestCase):
}]
}],
temperature=0.0,
max_tokens=4096
max_completion_tokens=4096
)
@patch('trustgraph.model.text_completion.openai.llm.OpenAI')
@ -380,7 +380,7 @@ class TestOpenAIProcessorSimple(IsolatedAsyncioTestCase):
# Verify other parameters
assert call_args[1]['model'] == 'gpt-3.5-turbo'
assert call_args[1]['temperature'] == 0.5
assert call_args[1]['max_tokens'] == 1024
assert call_args[1]['max_completion_tokens'] == 1024
@patch('trustgraph.model.text_completion.openai.llm.OpenAI')