Skip to content

Commit e94c20f

Browse files
bagusindrayanasanchitmonga22greptile-apps[bot]
authored
Feature/flutter structured output (#382)
* feat: implement structured output json for flutter * refactor: add return structuredData in result generate, fix some type in ffi and bride * refactor: add systemprompt from StructuredOutputHandler, impove system prompt * update: example for structured output json * Update examples/flutter/RunAnywhereAI/lib/features/structured_output/structured_output_view.dart Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * Update sdk/runanywhere-flutter/packages/runanywhere/lib/public/runanywhere.dart Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * Update sdk/runanywhere-flutter/packages/runanywhere/lib/public/runanywhere.dart Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * Update examples/flutter/RunAnywhereAI/lib/features/structured_output/structured_output_view.dart Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * refactor: update structuredData type and fix layout in structured data example screen * fix: remove redundant import icons * Update sdk/runanywhere-flutter/packages/runanywhere/lib/features/llm/structured_output/structured_output_handler.dart Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * Update sdk/runanywhere-flutter/packages/runanywhere/lib/public/runanywhere.dart Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * Update sdk/runanywhere-flutter/packages/runanywhere/lib/public/runanywhere.dart Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * fix: remove duplicate class * fix: remove duplicate StreamToken class, fix memory leak issue, fix exception handle --------- Co-authored-by: Sanchit Monga <sanchitmonga22@gmail.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
1 parent f37034a commit e94c20f

11 files changed

Lines changed: 1333 additions & 141 deletions

File tree

examples/android/RunAnywhereAI/app/src/main/java/com/runanywhere/runanywhereai/presentation/settings/SettingsScreen.kt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ import androidx.compose.material.icons.outlined.RestartAlt
3838
import androidx.compose.material.icons.outlined.Visibility
3939
import androidx.compose.material.icons.outlined.VisibilityOff
4040
import androidx.compose.material.icons.outlined.Warning
41+
import androidx.compose.material.icons.outlined.Build
42+
import androidx.compose.material.icons.outlined.Add
4143
import androidx.compose.material3.*
4244
import androidx.compose.runtime.*
4345
import androidx.compose.ui.Alignment
@@ -811,7 +813,7 @@ fun ToolSettingsSection() {
811813
val application = context.applicationContext as Application
812814
val toolViewModel = remember { ToolSettingsViewModel.getInstance(application) }
813815
val toolState by toolViewModel.uiState.collectAsStateWithLifecycle()
814-
816+
815817
SettingsSection(title = "Tool Calling") {
816818
// Enable/Disable Toggle
817819
Row(
@@ -841,10 +843,10 @@ fun ToolSettingsSection() {
841843
),
842844
)
843845
}
844-
846+
845847
if (toolState.toolCallingEnabled) {
846848
HorizontalDivider(modifier = Modifier.padding(vertical = 8.dp))
847-
849+
848850
// Registered Tools Count
849851
Row(
850852
modifier = Modifier
@@ -875,7 +877,7 @@ fun ToolSettingsSection() {
875877
color = AppColors.primaryAccent,
876878
)
877879
}
878-
880+
879881
// Tool List (if any)
880882
if (toolState.registeredTools.isNotEmpty()) {
881883
toolState.registeredTools.forEach { tool ->
@@ -893,9 +895,9 @@ fun ToolSettingsSection() {
893895
}
894896
}
895897
}
896-
898+
897899
HorizontalDivider(modifier = Modifier.padding(vertical = 8.dp))
898-
900+
899901
// Action Buttons
900902
Row(
901903
modifier = Modifier.fillMaxWidth(),
@@ -917,7 +919,7 @@ fun ToolSettingsSection() {
917919
Spacer(modifier = Modifier.width(4.dp))
918920
Text(if (toolState.isLoading) "Loading..." else "Add Demo Tools")
919921
}
920-
922+
921923
if (toolState.registeredTools.isNotEmpty()) {
922924
OutlinedButton(
923925
onClick = { toolViewModel.clearAllTools() },
@@ -936,7 +938,7 @@ fun ToolSettingsSection() {
936938
}
937939
}
938940
}
939-
941+
940942
Spacer(modifier = Modifier.height(8.dp))
941943
Text(
942944
text = "Demo tools: get_weather (Open-Meteo API), get_current_time, calculate",
@@ -945,4 +947,4 @@ fun ToolSettingsSection() {
945947
)
946948
}
947949
}
948-
}
950+
}

examples/flutter/RunAnywhereAI/lib/features/chat/chat_interface_view.dart

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import 'package:runanywhere_ai/features/models/model_selection_sheet.dart';
1616
import 'package:runanywhere_ai/features/models/model_status_components.dart';
1717
import 'package:runanywhere_ai/features/models/model_types.dart';
1818
import 'package:runanywhere_ai/features/settings/tool_settings_view_model.dart';
19+
import 'package:runanywhere_ai/features/structured_output/structured_output_view.dart';
1920
import 'package:shared_preferences/shared_preferences.dart';
2021

2122
/// ChatInterfaceView (mirroring iOS ChatInterfaceView.swift)
@@ -452,7 +453,18 @@ class _ChatInterfaceViewState extends State<ChatInterfaceView> {
452453
return Scaffold(
453454
appBar: AppBar(
454455
title: const Text('Chat'),
455-
actions: [
456+
actions: [
457+
IconButton(
458+
icon: const Icon(Icons.data_object),
459+
onPressed: () {
460+
Navigator.of(context).push<void>(
461+
MaterialPageRoute<void>(
462+
builder: (context) => const StructuredOutputView(),
463+
),
464+
);
465+
},
466+
tooltip: 'Structured Output Examples',
467+
),
456468
if (_messages.isNotEmpty)
457469
IconButton(
458470
icon: const Icon(Icons.delete_outline),

0 commit comments

Comments
 (0)