MCPcopy Index your code
hub / github.com/KnowledgeXLab/LeanRAG / clean_str

Function clean_str

GraphExtraction/_utils.py:5–13  ·  view source on GitHub ↗

Clean an input string by removing HTML escapes, control characters, and other unwanted characters.

(input: Any)

Source from the content-addressed store, hash-verified

3from typing import Any, Union
4import html
5def clean_str(input: Any) -> str:
6 """Clean an input string by removing HTML escapes, control characters, and other unwanted characters."""
7 # If we get non-string input, just give it back
8 if not isinstance(input, str):
9 return input
10
11 result = html.unescape(input.strip())
12 # https://stackoverflow.com/questions/4324790/removing-control-characters-from-a-string-in-python
13 return re.sub(r"[\x00-\x1f\x7f-\x9f]", "", result)
14def pack_user_ass_to_openai_messages(*args: str):
15 roles = ["user", "assistant"]
16 return [

Calls

no outgoing calls

Tested by

no test coverage detected