File tree Expand file tree Collapse file tree 1 file changed +38
-1
lines changed
Expand file tree Collapse file tree 1 file changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -192,11 +192,48 @@ def make_url(self, context: RequestTransformContext) -> str:
192192
193193
194194class HTTPGenerator (Generator ):
195- """Generator that uses transforms to map between HTTP APIs and the Message format."""
195+ """
196+ Generator to map messages to HTTP requests and back.
197+
198+ The generator takes a `spec` attribute which describes how to encode
199+ messages into HTTP requests and decode the responses back into messages.
200+
201+ You can pass this spec as a python dictionary, JSON string, YAML string,
202+ or a base64 encoded JSON/YAML string.
203+
204+ ```python
205+ import rigging as rg
206+
207+ spec = r\" ""
208+ request:
209+ url: "https://{{ model }}.crucible.dreadnode.io/submit"
210+ headers:
211+ "X-Api-Key": "{{ api_key }}"
212+ "Content-Type": "application/json"
213+ transforms:
214+ - type: "json"
215+ pattern: {
216+ "data": "$content"
217+ }
218+ response:
219+ transforms:
220+ - type: "jsonpath"
221+ pattern: $.flag,output,message
222+ \" ""
223+
224+ crucible = rg.get_generator("http!test,api_key=<key>")
225+ crucible.spec = spec
226+
227+ chat = await crucible.chat("How about a flag?").run()
228+
229+ print(chat.conversation)
230+ ```
231+ """
196232
197233 model_config = ConfigDict (validate_assignment = True )
198234
199235 spec : HTTPSpec | None = None
236+ """Specification for building/parsing HTTP interactions."""
200237
201238 @field_validator ("spec" , mode = "before" )
202239 def process_spec (cls , v : t .Any ) -> t .Any :
You can’t perform that action at this time.
0 commit comments