Agentic Calls corrected to comply with new Architecture

This commit is contained in:
Manas Hejmadi
2025-08-03 17:49:00 +05:30
parent ed41f8446b
commit 06a71ea232
8 changed files with 34 additions and 22 deletions

View File

@@ -7,7 +7,7 @@ import 'package:genai/genai.dart';
class APIDashAgentCaller {
static APIDashAgentCaller instance = APIDashAgentCaller();
Future<(String? output, String error)> call(
Future<dynamic> call(
APIDashAIAgent agent, {
required WidgetRef ref,
required AgentInputs input,
@@ -15,7 +15,7 @@ class APIDashAgentCaller {
final defaultAIModel =
ref.read(settingsProvider.select((e) => e.defaultAIModel));
if (defaultAIModel == null) {
return (null, 'NO_DEFAULT_LLM');
throw Exception('NO_DEFAULT_LLM');
}
final baseAIRequestObject = AIRequestModel.fromJson(defaultAIModel);
final ans = await GenAIAgenticService.callAgent(

View File

@@ -0,0 +1,5 @@
export 'intermediate_rep_gen.dart';
export 'semantic_analyser.dart';
export 'stac2flutter.dart';
export 'stacgen.dart';
export 'stacmodifier.dart';

View File

@@ -1,6 +1,6 @@
import 'package:genai/agentic_engine/blueprint.dart';
const String kIntermediateRepGenSystemPrompt = """
const String _sysprompt = """
You are an expert at converting API Responses into a YAML schema tree.
When you get a given JSON API Response, I want you to break it down and recombine it in the form of a YAMK UI schema.
@@ -45,7 +45,7 @@ class IntermediateRepresentationGen extends APIDashAIAgent {
@override
String getSystemPrompt() {
return kIntermediateRepGenSystemPrompt;
return _sysprompt;
}
@override

View File

@@ -1,6 +1,6 @@
import 'package:genai/agentic_engine/blueprint.dart';
const String kSemanticAnalyserSystemPrompt = """
const String _sysprompt = """
You are an expert at understanding API response structures.
When i provide a sample JSON response, Please give me a semantic analysis about it.
@@ -20,7 +20,7 @@ class ResponseSemanticAnalyser extends APIDashAIAgent {
@override
String getSystemPrompt() {
return kSemanticAnalyserSystemPrompt;
return _sysprompt;
}
@override

View File

@@ -1,6 +1,6 @@
import 'package:genai/agentic_engine/blueprint.dart';
const String kIntermediateRepGenSystemPrompt = """
const String _sysprompt = """
You are an expert agent whose sole JOB is to accept FLutter-SDUI (json-like) representation
and convert it into actual working FLutter component.
@@ -22,7 +22,7 @@ class StacToFlutterBot extends APIDashAIAgent {
@override
String getSystemPrompt() {
return kIntermediateRepGenSystemPrompt;
return _sysprompt;
}
@override

View File

@@ -1,6 +1,6 @@
import 'package:genai/agentic_engine/blueprint.dart';
const String kIntermediateRepGenSystemPrompt = """
const String _sysprompt = """
You are an expert agent whose sole JOB is to generate FLutter-SDUI (json-like) representation from a Text based description
and a provided Schema
@@ -232,7 +232,7 @@ class StacGenBot extends APIDashAIAgent {
@override
String getSystemPrompt() {
return kIntermediateRepGenSystemPrompt;
return _sysprompt;
}
@override

View File

@@ -1,6 +1,6 @@
import 'package:genai/agentic_engine/blueprint.dart';
const String kIntermediateRepGenSystemPrompt = """
const String _sysprompt = """
You are an expert agent whose sole JOB is to accept FLutter-SDUI (json-like) representation
and modify it to match the requests of the client.
@@ -21,7 +21,7 @@ class SlacModifierBot extends APIDashAIAgent {
@override
String getSystemPrompt() {
return kIntermediateRepGenSystemPrompt;
return _sysprompt;
}
@override

View File

@@ -1,13 +1,15 @@
import 'dart:convert';
import 'package:apidash/consts.dart';
import 'package:apidash/services/agentic_services/agent_caller.dart';
import 'package:apidash/widgets/widget_sending.dart';
import 'package:apidash_design_system/apidash_design_system.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:genai/agentic_engine/blueprint.dart';
import 'package:stac/stac.dart' as stac;
import '../services/agentic_services/agents/agents.dart';
void showCustomDialog(BuildContext context, String content) {
showDialog(
context: context,
@@ -48,32 +50,37 @@ class _DialogContentsState extends ConsumerState<DialogContents> {
});
//STEP 1: RESPONSE_ANALYSER (call the Semantic Analysis & IRGen Bots in parallel)
final step1Res = await Future.wait([
APIDashAgentCaller.instance.semanticAnalyser(
ref,
APIDashAgentCaller.instance.call(
ResponseSemanticAnalyser(),
ref: ref,
input: AgentInputs(query: apiResponse),
),
APIDashAgentCaller.instance.irGenerator(
ref,
APIDashAgentCaller.instance.call(
IntermediateRepresentationGen(),
ref: ref,
input: AgentInputs(variables: {
'VAR_API_RESPONSE': apiResponse,
}),
),
]);
final SA = step1Res[0]['SEMANTIC_ANALYSIS'];
final IR = step1Res[1]['INTERMEDIATE_REPRESENTATION'];
final SA = step1Res[0]?['SEMANTIC_ANALYSIS'];
final IR = step1Res[1]?['INTERMEDIATE_REPRESENTATION'];
print("Semantic Analysis: $SA");
print("Intermediate Representation: $IR");
//STEP 2: STAC_GEN (Generate the SDUI Code)
final sduiCode = await APIDashAgentCaller.instance.stacGenerator(
ref,
final sduiCode = await APIDashAgentCaller.instance.call(
StacGenBot(),
ref: ref,
input: AgentInputs(variables: {
'VAR_RAW_API_RESPONSE': apiResponse,
'VAR_INTERMEDIATE_REPR': IR,
'VAR_SEMANTIC_ANALYSIS': SA,
}),
);
return sduiCode['STAC'].toString();
return sduiCode?['STAC']?.toString() ?? "<NONE>";
}
@override