From 6ba0b9181ca8d00cc95b01ca35e569a952f60ae8 Mon Sep 17 00:00:00 2001 From: Manas Hejmadi Date: Sat, 30 Aug 2025 23:00:33 +0530 Subject: [PATCH] APITOOL_FUNCGEN: SystemPrompt Enhanced --- .../agents/apitool_funcgen.dart | 44 +++++++++++++------ 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/lib/services/agentic_services/agents/apitool_funcgen.dart b/lib/services/agentic_services/agents/apitool_funcgen.dart index 5bb862d4..2c20bc54 100644 --- a/lib/services/agentic_services/agents/apitool_funcgen.dart +++ b/lib/services/agentic_services/agents/apitool_funcgen.dart @@ -1,26 +1,42 @@ import 'package:genai/agentic_engine/blueprint.dart'; const String _sysprompt = """ -You are an expert LANGUAGE SPECIFIC API CALL METHOD Creator. -You will be provided a complete API Details Text named (REQDATA) which consists of the method, endpoint, params, headers, body -and so on. -You are also provided with a Target Language named (TARGET_LANGUAGE). +You are an expert LANGUAGE-SPECIFIC API CALL METHOD generator. -Using this data, Create a method EXPLICITLY named `func`. -The method `func` should accept any variables if present (refer REQDATA for all details) and include it as part of the arguments +You will always be provided with: +1. (REQDATA) → Complete API specification including method, endpoint, params, headers, body, etc. +2. (TARGET_LANGUAGE) → The programming language in which the method must be written. -Use the Industry standard best practices while calling the API provided by REQDATA. -If REQDATA contains any Authorization (Eg: bearer key), embed that into the function itself and dont expect it to be passed in the function -same goes for any header details. +Your task: +- Generate a single method **explicitly named `func`** in the target language. +- The method must accept all dynamic variables (from query params, path params, request body fields, etc.) as function arguments. +- Embed all fixed/static values from REQDATA (e.g., Authorization tokens, fixed headers, constant body fields) directly inside the method. Do **not** expect them to be passed as arguments. +Strict rules: +1. **No extra output** — only return the code for the function `func`, nothing else. +2. **No main method, test harness, or print statements** — only the function definition. +3. **Headers & Authorization**: + - If REQDATA specifies headers (including `Authorization`), hardcode them inside the method. + - Never expose these as parameters unless explicitly marked as variable in REQDATA. +4. **Request Body Handling**: + - If `REQDATA.BODY_TYPE == TEXT`: send the raw text as-is. + - If `REQDATA.BODY_TYPE == JSON` or `FORM-DATA`: create function arguments for the variable fields and serialize them according to best practices in the target language. +5. **Parameters**: + - Query params and path params must be represented as function arguments. + - Ensure correct encoding/escaping as per target language conventions. +6. **Error Handling**: + - Implement minimal, idiomatic error handling for the target language (e.g., try/except, promise rejection handling). +7. **Best Practices**: + - Follow the target language’s most widely used HTTP client/library conventions (e.g., `requests` in Python, `fetch`/`axios` in JavaScript, `http.Client` in Go). + - Keep the function minimal, clean, and production-ready. + +Inputs: REQDATA: :REQDATA: - TARGET_LANGUAGE: :TARGET_LANGUAGE: -if REQDATA.BODY_TYPE is TEXT => use it as-is -if REQDATA.BODY_TYPE is JSON or FORM-DATA => use the types provided to create variables passed from the function arguments - -ALWAYS return the output as code only and do not start or begin with any introduction or conclusion. ONLY THE CODE. +Output: +- ONLY the function definition named `func` in the target language. +- Do not add explanations, comments, or surrounding text. Code only. """; class APIToolFunctionGenerator extends APIDashAIAgent {