graphiti-core 0.5.0rc4__py3-none-any.whl → 0.5.0rc5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of graphiti-core might be problematic. Click here for more details.
- graphiti_core/llm_client/client.py +26 -0
- graphiti_core/llm_client/openai_client.py +1 -0
- {graphiti_core-0.5.0rc4.dist-info → graphiti_core-0.5.0rc5.dist-info}/METADATA +1 -1
- {graphiti_core-0.5.0rc4.dist-info → graphiti_core-0.5.0rc5.dist-info}/RECORD +6 -6
- {graphiti_core-0.5.0rc4.dist-info → graphiti_core-0.5.0rc5.dist-info}/LICENSE +0 -0
- {graphiti_core-0.5.0rc4.dist-info → graphiti_core-0.5.0rc5.dist-info}/WHEEL +0 -0
|
@@ -56,6 +56,29 @@ class LLMClient(ABC):
|
|
|
56
56
|
self.cache_enabled = cache
|
|
57
57
|
self.cache_dir = Cache(DEFAULT_CACHE_DIR) # Create a cache directory
|
|
58
58
|
|
|
59
|
+
|
|
60
|
+
def _clean_input(self, input: str) -> str:
|
|
61
|
+
"""Clean input string of invalid unicode and control characters.
|
|
62
|
+
|
|
63
|
+
Args:
|
|
64
|
+
input: Raw input string to be cleaned
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
Cleaned string safe for LLM processing
|
|
68
|
+
"""
|
|
69
|
+
# Clean any invalid Unicode
|
|
70
|
+
cleaned = input.encode('utf-8', errors='ignore').decode('utf-8')
|
|
71
|
+
|
|
72
|
+
# Remove zero-width characters and other invisible unicode
|
|
73
|
+
zero_width = '\u200b\u200c\u200d\ufeff\u2060'
|
|
74
|
+
for char in zero_width:
|
|
75
|
+
cleaned = cleaned.replace(char, '')
|
|
76
|
+
|
|
77
|
+
# Remove control characters except newlines, returns, and tabs
|
|
78
|
+
cleaned = ''.join(char for char in cleaned if ord(char) >= 32 or char in '\n\r\t')
|
|
79
|
+
|
|
80
|
+
return cleaned
|
|
81
|
+
|
|
59
82
|
@retry(
|
|
60
83
|
stop=stop_after_attempt(4),
|
|
61
84
|
wait=wait_random_exponential(multiplier=10, min=5, max=120),
|
|
@@ -106,6 +129,9 @@ class LLMClient(ABC):
|
|
|
106
129
|
logger.debug(f'Cache hit for {cache_key}')
|
|
107
130
|
return cached_response
|
|
108
131
|
|
|
132
|
+
for message in messages:
|
|
133
|
+
message.content = self._clean_input(message.content)
|
|
134
|
+
|
|
109
135
|
response = await self._generate_response_with_retry(messages, response_model)
|
|
110
136
|
|
|
111
137
|
if self.cache_enabled:
|
|
@@ -88,6 +88,7 @@ class OpenAIClient(LLMClient):
|
|
|
88
88
|
) -> dict[str, typing.Any]:
|
|
89
89
|
openai_messages: list[ChatCompletionMessageParam] = []
|
|
90
90
|
for m in messages:
|
|
91
|
+
m.content = self._clean_input(m.content)
|
|
91
92
|
if m.role == 'user':
|
|
92
93
|
openai_messages.append({'role': 'user', 'content': m.content})
|
|
93
94
|
elif m.role == 'system':
|
|
@@ -13,11 +13,11 @@ graphiti_core/graphiti.py,sha256=XzgnEbcnRvYXeS1Ul0bngCe0Z3-coZIoVNuAaxcwcvM,270
|
|
|
13
13
|
graphiti_core/helpers.py,sha256=DYS8bR7QdtZoZZu5nrJgSAeixYB2hQm-vehHQFnqI7M,2375
|
|
14
14
|
graphiti_core/llm_client/__init__.py,sha256=PA80TSMeX-sUXITXEAxMDEt3gtfZgcJrGJUcyds1mSo,207
|
|
15
15
|
graphiti_core/llm_client/anthropic_client.py,sha256=4hU_PXObkdiT_gUNj9G-Cj6vHFPQ0QpolwaRnJwDiL4,2497
|
|
16
|
-
graphiti_core/llm_client/client.py,sha256=
|
|
16
|
+
graphiti_core/llm_client/client.py,sha256=BytbjhIdJLx5i-vph7KYpGi3ewO0Lo5EnhOXeebLRAk,4806
|
|
17
17
|
graphiti_core/llm_client/config.py,sha256=VwtvD0B7TNqE6Cl-rvH5v-bAfmjMLhEUuFmHSPt10EI,2339
|
|
18
18
|
graphiti_core/llm_client/errors.py,sha256=Vk0mj2SgNDg8E8p7m1UyUaerqLPNLCDKPVsMEnOSBdQ,1028
|
|
19
19
|
graphiti_core/llm_client/groq_client.py,sha256=A4TcbBGXyF5Br5Ggm7qnvso76L1ERO4JoCA2HlzDEyI,2421
|
|
20
|
-
graphiti_core/llm_client/openai_client.py,sha256=
|
|
20
|
+
graphiti_core/llm_client/openai_client.py,sha256=RGq2emM1CioOGFTNfulT3nNdMAKHTXlI7kNp7vQJe9c,6555
|
|
21
21
|
graphiti_core/llm_client/utils.py,sha256=zKpxXEbKa369m4W7RDEf-m56kH46V1Mx3RowcWZEWWs,1000
|
|
22
22
|
graphiti_core/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
23
|
graphiti_core/models/edges/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -53,7 +53,7 @@ graphiti_core/utils/maintenance/graph_data_operations.py,sha256=w66_SLlvPapuG91Y
|
|
|
53
53
|
graphiti_core/utils/maintenance/node_operations.py,sha256=rwQUNG8t7wEI_LBZIhA5vjPJl5MYOzcpEOKviqTEycA,12029
|
|
54
54
|
graphiti_core/utils/maintenance/temporal_operations.py,sha256=MWg1HErEPVqfLNz-lO0qbuuBT-xw1f2Gq5YoBzrWDfA,3669
|
|
55
55
|
graphiti_core/utils/maintenance/utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
56
|
-
graphiti_core-0.5.
|
|
57
|
-
graphiti_core-0.5.
|
|
58
|
-
graphiti_core-0.5.
|
|
59
|
-
graphiti_core-0.5.
|
|
56
|
+
graphiti_core-0.5.0rc5.dist-info/LICENSE,sha256=KCUwCyDXuVEgmDWkozHyniRyWjnWUWjkuDHfU6o3JlA,11325
|
|
57
|
+
graphiti_core-0.5.0rc5.dist-info/METADATA,sha256=NQcfpv5kLb3xfwtEKpAXlEGRxdeIcG6j6sE_bXC2ShA,10061
|
|
58
|
+
graphiti_core-0.5.0rc5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
59
|
+
graphiti_core-0.5.0rc5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|