mirror of
https://github.com/foss42/apidash.git
synced 2025-12-01 18:28:25 +08:00
initializeAIRequest moved out of api_type_dropdown & cleaned
This commit is contained in:
@@ -245,7 +245,21 @@ class CollectionStateNotifier
|
|||||||
debugPrint("Unable to update as Request Id is null");
|
debugPrint("Unable to update as Request Id is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentModel = state![rId]!;
|
var currentModel = state![rId]!;
|
||||||
|
|
||||||
|
if (apiType == APIType.ai) {
|
||||||
|
//Adding default AI Request Modoel
|
||||||
|
AIRequestModel? aiRM = currentModel.aiRequestModel;
|
||||||
|
LLMSaveObject? defaultLLMSO = ref
|
||||||
|
.watch(settingsProvider.notifier)
|
||||||
|
.settingsModel
|
||||||
|
?.defaultLLMSaveObject; //Settings Default
|
||||||
|
if (aiRM == null) {
|
||||||
|
aiRequestModel = AIRequestModel.fromDefaultSaveObject(defaultLLMSO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var currentHttpRequestModel = currentModel.httpRequestModel;
|
var currentHttpRequestModel = currentModel.httpRequestModel;
|
||||||
final newModel = currentModel.copyWith(
|
final newModel = currentModel.copyWith(
|
||||||
apiType: apiType ?? currentModel.apiType,
|
apiType: apiType ?? currentModel.apiType,
|
||||||
|
|||||||
@@ -16,9 +16,6 @@ class APITypeDropdown extends ConsumerWidget {
|
|||||||
return APITypePopupMenu(
|
return APITypePopupMenu(
|
||||||
apiType: apiType,
|
apiType: apiType,
|
||||||
onChanged: (type) {
|
onChanged: (type) {
|
||||||
if (type == APIType.ai) {
|
|
||||||
initializeAIRequest(ref);
|
|
||||||
}
|
|
||||||
ref
|
ref
|
||||||
.read(collectionStateNotifierProvider.notifier)
|
.read(collectionStateNotifierProvider.notifier)
|
||||||
.update(apiType: type);
|
.update(apiType: type);
|
||||||
@@ -26,33 +23,3 @@ class APITypeDropdown extends ConsumerWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeAIRequest(WidgetRef ref) {
|
|
||||||
final selectedId = ref.watch(selectedIdStateProvider);
|
|
||||||
final req = ref.watch(collectionStateNotifierProvider)![selectedId]!;
|
|
||||||
AIRequestModel? aiRequestModel = req.aiRequestModel;
|
|
||||||
LLMSaveObject? defaultLLMSO = ref
|
|
||||||
.watch(settingsProvider.notifier)
|
|
||||||
.settingsModel
|
|
||||||
?.defaultLLMSaveObject; //Settings Default
|
|
||||||
|
|
||||||
if (aiRequestModel == null) {
|
|
||||||
// Creating the AIRequest Model initially
|
|
||||||
final gmC = GeminiModelController.instance;
|
|
||||||
final newAIRM = AIRequestModel(
|
|
||||||
model: defaultLLMSO?.selectedLLM ??
|
|
||||||
LLMProvider.gemini.getLLMByIdentifier('gemini-2.0-flash'),
|
|
||||||
provider: defaultLLMSO?.provider ?? LLMProvider.gemini,
|
|
||||||
payload: LLMInputPayload(
|
|
||||||
endpoint: defaultLLMSO?.endpoint ?? gmC.inputPayload.endpoint,
|
|
||||||
credential: defaultLLMSO?.credential ?? '',
|
|
||||||
systemPrompt: '',
|
|
||||||
userPrompt: '',
|
|
||||||
configMap: defaultLLMSO?.configMap ?? gmC.inputPayload.configMap,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
ref.read(collectionStateNotifierProvider.notifier).update(
|
|
||||||
aiRequestModel: newAIRM,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user