Skip to content

Use Claude Code, Codex, VSCode, Pi, and OpenCode (and 6 other harnesses) for free (1.3B+ free tokens) from your terminal, app, IDE, or phone, and now from the browser with native browser sessions (multi-harness + multi-model) like OpenClaw (voice supported + ToS friendly)

Python

moved text.py to common utils for providers

Alishahryar12b0495dd0885
diff --git a/api/detection.py b/api/detection.py
index 29a150c1..0dc386eb 100644
--- a/api/detection.py
+++ b/api/detection.py
@@ -4,7 +4,7 @@ Detects quota checks, title generation, prefix detection, suggestion mode,
and filepath extraction requests to enable fast-path responses.
"""
-from utils.text import extract_text_from_content
+from providers.common.text import extract_text_from_content
from .models.anthropic import MessagesRequest
diff --git a/providers/common/text.py b/providers/common/text.py
new file mode 100644
index 00000000..ce89627e
--- /dev/null
+++ b/providers/common/text.py
@@ -0,0 +1,17 @@
+"""Shared text extraction utilities."""
+
+from typing import Any
+
+
+def extract_text_from_content(content: Any) -> str:
+ """Extract concatenated text from message content (str or list of content blocks)."""
+ if isinstance(content, str):
+ return content
+ if isinstance(content, list):
+ parts = []
+ for block in content:
+ text = getattr(block, "text", "")
+ if text and isinstance(text, str):
+ parts.append(text)
+ return "".join(parts)
+ return ""
diff --git a/providers/logging_utils.py b/providers/logging_utils.py
index 84dd5cb7..5cc5dfff 100644
--- a/providers/logging_utils.py
+++ b/providers/logging_utils.py
@@ -10,7 +10,7 @@ from typing import Any
from loguru import logger
-from utils.text import extract_text_from_content
+from providers.common.text import extract_text_from_content
def generate_request_fingerprint(messages: list[Any]) -> str:
diff --git a/tests/messaging/test_extract_text.py b/tests/messaging/test_extract_text.py
index a98e2421..b2234593 100644
--- a/tests/messaging/test_extract_text.py
+++ b/tests/messaging/test_extract_text.py
@@ -4,11 +4,11 @@ from unittest.mock import MagicMock
import pytest
-from utils.text import extract_text_from_content
+from providers.common.text import extract_text_from_content
class TestExtractTextFromContent:
- """Tests for utils.text.extract_text_from_content."""
+ """Tests for providers.common.text.extract_text_from_content."""
def test_string_content(self):
"""Return string content as-is."""
diff --git a/utils/text.py b/utils/text.py
index ce89627e..f38d60b8 100644
--- a/utils/text.py
+++ b/utils/text.py
@@ -1,17 +1,8 @@
-"""Shared text extraction utilities."""
+"""Shared text extraction utilities.
-from typing import Any
+This module is deprecated. Use providers.common.text instead.
+"""
+from providers.common.text import extract_text_from_content
-def extract_text_from_content(content: Any) -> str:
- """Extract concatenated text from message content (str or list of content blocks)."""
- if isinstance(content, str):
- return content
- if isinstance(content, list):
- parts = []
- for block in content:
- text = getattr(block, "text", "")
- if text and isinstance(text, str):
- parts.append(text)
- return "".join(parts)
- return ""
+__all__ = ["extract_text_from_content"]