diff --git a/service/local-ai/gateway.py b/service/local-ai/gateway.py index 09ed0b3e9864543ccc2aa659cf502a7c121b2b72..cfc23b0d290d0d7f6987aaef63f8e5e535155c3f 100644 --- a/service/local-ai/gateway.py +++ b/service/local-ai/gateway.py @@ -206,7 +206,7 @@ class Handler(BaseHTTPRequestHandler): if self.path.split("?", 1)[0] == "/.well-known/ai-agent-provider.json": content = json.dumps(agent_provider(), ensure_ascii=False).encode() self.send_response(200) - self.send_header("Content-Type", "application/json") + self.send_header("Content-Type", "application/json; charset=utf-8") self.send_header("Cache-Control", "no-store") self.send_header("Content-Length", str(len(content))) self.end_headers() diff --git a/service/local-ai/test_gateway.py b/service/local-ai/test_gateway.py index 0437338c72d28fb8a9c44b83e494bdb06075be77..5eb537018799e9d79b60a9c2c5983b292cd9037c 100644 --- a/service/local-ai/test_gateway.py +++ b/service/local-ai/test_gateway.py @@ -22,10 +22,11 @@ class ResponsesCompatibility(unittest.TestCase): client.request("GET", "/.well-known/ai-agent-provider.json?probe=1", headers=headers) response = client.getresponse() self.assertEqual(response.status, 200) - self.assertEqual(response.getheader("Content-Type"), "application/json") + self.assertEqual(response.getheader("Content-Type"), "application/json; charset=utf-8") content = response.read() self.assertEqual(int(response.getheader("Content-Length")), len(content)) - self.assertEqual(json.loads(content), agent_provider()) + self.assertIn("❄️".encode("utf-8"), content) + self.assertEqual(json.loads(content.decode("utf-8")), agent_provider()) self.assertNotIn(b"disposable-test-key", content) client.request("GET", "/v1/models") response = client.getresponse()