mirror of
https://github.com/Alishahryar1/free-claude-code.git
synced 2026-04-28 03:20:01 +00:00
moved text.py to common utils for providers
This commit is contained in:
parent
2ad64cc97a
commit
2b0495dd08
5 changed files with 26 additions and 18 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
17
providers/common/text.py
Normal file
17
providers/common/text.py
Normal file
|
|
@ -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 ""
|
||||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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."""
|
||||
|
|
|
|||
|
|
@ -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"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue