@@ -58,7 +58,6 @@ async def guard_text(
5858 * ,
5959 recipe : str | None = None ,
6060 debug : bool | None = None ,
61- llm_info : str | None = None ,
6261 log_fields : LogFields | None = None ,
6362 ) -> PangeaResponse [TextGuardResult [None ]]:
6463 """
@@ -78,7 +77,6 @@ async def guard_text(
7877 are to be applied to the text, such as defang malicious URLs.
7978 debug: Setting this value to true will provide a detailed analysis
8079 of the text data
81- llm_info: Short string hint for the LLM Provider information
8280 log_field: Additional fields to include in activity log
8381
8482 Examples:
@@ -92,7 +90,6 @@ async def guard_text(
9290 messages : _T ,
9391 recipe : str | None = None ,
9492 debug : bool | None = None ,
95- llm_info : str | None = None ,
9693 log_fields : LogFields | None = None ,
9794 ) -> PangeaResponse [TextGuardResult [_T ]]:
9895 """
@@ -113,59 +110,19 @@ async def guard_text(
113110 are to be applied to the text, such as defang malicious URLs.
114111 debug: Setting this value to true will provide a detailed analysis
115112 of the text data
116- llm_info: Short string hint for the LLM Provider information
117113 log_field: Additional fields to include in activity log
118114
119115 Examples:
120116 response = await ai_guard.guard_text(messages=[{"role": "user", "content": "hello world"}])
121117 """
122118
123- @overload
124- async def guard_text (
125- self ,
126- * ,
127- llm_input : _T ,
128- recipe : str | None = None ,
129- debug : bool | None = None ,
130- llm_info : str | None = None ,
131- log_fields : LogFields | None = None ,
132- ) -> PangeaResponse [TextGuardResult [_T ]]:
133- """
134- Text Guard for scanning LLM inputs and outputs
135-
136- Analyze and redact text to avoid manipulation of the model, addition of
137- malicious content, and other undesirable data transfers.
138-
139- OperationId: ai_guard_post_v1_text_guard
140-
141- Args:
142- llm_input: Structured full llm payload data to be scanned by AI
143- Guard for PII, sensitive data, malicious content, and other data
144- types defined by the configuration. Supports processing up to
145- 10KB of JSON text
146- recipe: Recipe key of a configuration of data types and settings
147- defined in the Pangea User Console. It specifies the rules that
148- are to be applied to the text, such as defang malicious URLs.
149- debug: Setting this value to true will provide a detailed analysis
150- of the text data
151- llm_info: Short string hint for the LLM Provider information
152- log_field: Additional fields to include in activity log
153-
154- Examples:
155- response = await ai_guard.guard_text(
156- llm_input={"model": "gpt-4o", "messages": [{"role": "user", "content": "hello world"}]}
157- )
158- """
159-
160119 async def guard_text ( # type: ignore[misc]
161120 self ,
162121 text : str | None = None ,
163122 * ,
164123 messages : _T | None = None ,
165- llm_input : _T | None = None ,
166124 recipe : str | None = None ,
167125 debug : bool | None = None ,
168- llm_info : str | None = None ,
169126 log_fields : LogFields | None = None ,
170127 ) -> PangeaResponse [TextGuardResult [None ]]:
171128 """
@@ -184,38 +141,28 @@ async def guard_text( # type: ignore[misc]
184141 PII, sensitive data, malicious content, and other data types
185142 defined by the configuration. Supports processing up to 10KB of
186143 JSON text
187- llm_input: Structured full llm payload data to be scanned by AI
188- Guard for PII, sensitive data, malicious content, and other data
189- types defined by the configuration. Supports processing up to
190- 10KB of JSON text
191144 recipe: Recipe key of a configuration of data types and settings
192145 defined in the Pangea User Console. It specifies the rules that
193146 are to be applied to the text, such as defang malicious URLs.
194147 debug: Setting this value to true will provide a detailed analysis
195148 of the text data
196- llm_info: Short string hint for the LLM Provider information
197149 log_field: Additional fields to include in activity log
198150
199151 Examples:
200152 response = await ai_guard.guard_text("text")
201153 """
202154
203- if not any ((text , messages , llm_input )):
204- raise ValueError ("Exactly one of `text`, `messages`, or `llm_input` must be given" )
205-
206- if sum ((text is not None , messages is not None , llm_input is not None )) > 1 :
207- raise ValueError ("Only one of `text`, `messages`, or `llm_input` can be given at once" )
155+ if text is not None and messages is not None :
156+ raise ValueError ("Exactly one of `text` or `messages` must be given" )
208157
209158 return await self .request .post (
210159 "v1/text/guard" ,
211160 TextGuardResult ,
212161 data = {
213162 "text" : text ,
214163 "messages" : messages ,
215- "llm_input" : llm_input ,
216164 "recipe" : recipe ,
217165 "debug" : debug ,
218- "llm_info" : llm_info ,
219166 "log_fields" : log_fields ,
220167 },
221168 )
0 commit comments