From 5bb3ead107b4b399bb0ad34f5c1821e6a32ceb8c Mon Sep 17 00:00:00 2001 From: Cyber-Freak999 Date: Mon, 21 Oct 2024 02:54:51 +0100 Subject: [PATCH 1/2] Added Wrapper for AI functionality --- submissions/Chimoney-Python/chimoney/AI.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 submissions/Chimoney-Python/chimoney/AI.py diff --git a/submissions/Chimoney-Python/chimoney/AI.py b/submissions/Chimoney-Python/chimoney/AI.py new file mode 100644 index 00000000..a738621b --- /dev/null +++ b/submissions/Chimoney-Python/chimoney/AI.py @@ -0,0 +1,12 @@ +from chimoney import BaseAPI + +class AI(BaseAPI): + def invoice_gen(self, instruction: str): + if not instruction: + raise ValueError("Instruction is required") + + payload = { + "instruction": instruction + } + + return self._handle_request("POST", "/v0.2/ai/invoice/generate", payload) From 49ee545c2b52d1c111b72833d5ac69c683416415 Mon Sep 17 00:00:00 2001 From: Cyber-Freak999 Date: Mon, 28 Oct 2024 15:29:34 +0100 Subject: [PATCH 2/2] chore: Add docstring to AI wrapper --- submissions/Chimoney-Python/chimoney/AI.py | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/submissions/Chimoney-Python/chimoney/AI.py b/submissions/Chimoney-Python/chimoney/AI.py index a738621b..f314bff5 100644 --- a/submissions/Chimoney-Python/chimoney/AI.py +++ b/submissions/Chimoney-Python/chimoney/AI.py @@ -1,7 +1,34 @@ from chimoney import BaseAPI class AI(BaseAPI): + """ + A class that extends the BaseAPI class to handle AI-based invoice generation requests. + + Methods: + -------- + invoice_gen(instruction: str) -> dict + Generates an invoice based on a given instruction. + """ def invoice_gen(self, instruction: str): + """ + Generates an invoice by sending a POST request with the given instruction to the AI endpoint. + + Parameters: + ----------- + instruction : str + A description or set of details required to generate the invoice. It should specify key elements + like items, quantities, prices, and any additional instructions for the invoice layout. + + Returns: + -------- + dict + A dictionary containing the response from the invoice generation API, which includes details of the generated invoice. + + Raises: + ------- + ValueError + If the 'instruction' parameter is empty or None. + """ if not instruction: raise ValueError("Instruction is required")