Add web research and source file reading
This commit is contained in:
+18
-5
@@ -88,6 +88,19 @@ class ChatCubit extends Cubit<ChatState> {
|
||||
emit(
|
||||
state.copyWith(
|
||||
isWorkspaceMode: !state.isWorkspaceMode,
|
||||
isWebSearchMode: false,
|
||||
clearError: true,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void toggleWebSearchMode() {
|
||||
if (!state.isSending) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
isWebSearchMode: !state.isWebSearchMode,
|
||||
isWorkspaceMode: false,
|
||||
clearError: true,
|
||||
),
|
||||
);
|
||||
@@ -254,11 +267,11 @@ class ChatCubit extends Cubit<ChatState> {
|
||||
),
|
||||
);
|
||||
_startElapsedTimer(generation);
|
||||
if (state.isWorkspaceMode) {
|
||||
answer = await _api.askWorkspaceAgent(
|
||||
prompt,
|
||||
model: state.selectedModel,
|
||||
);
|
||||
if (state.isWorkspaceMode || state.isWebSearchMode) {
|
||||
answer =
|
||||
state.isWorkspaceMode
|
||||
? await _api.askWorkspaceAgent(prompt, model: state.selectedModel)
|
||||
: await _api.searchWeb(prompt, model: state.selectedModel);
|
||||
if (isClosed || generation != _requestGeneration) return;
|
||||
if (answer.trim().isEmpty) {
|
||||
throw Exception('لم يصل نص في إجابة الوكيل.');
|
||||
|
||||
@@ -81,6 +81,7 @@ class ChatState {
|
||||
this.isLoadingHistory = true,
|
||||
this.isSending = false,
|
||||
this.isWorkspaceMode = false,
|
||||
this.isWebSearchMode = false,
|
||||
this.error,
|
||||
this.modelName = 'جارٍ اكتشاف النموذج…',
|
||||
this.modelStatus = ModelConnectionStatus.checking,
|
||||
@@ -98,6 +99,7 @@ class ChatState {
|
||||
final bool isLoadingHistory;
|
||||
final bool isSending;
|
||||
final bool isWorkspaceMode;
|
||||
final bool isWebSearchMode;
|
||||
final String? error;
|
||||
final String modelName;
|
||||
final ModelConnectionStatus modelStatus;
|
||||
@@ -116,6 +118,7 @@ class ChatState {
|
||||
bool? isLoadingHistory,
|
||||
bool? isSending,
|
||||
bool? isWorkspaceMode,
|
||||
bool? isWebSearchMode,
|
||||
String? error,
|
||||
bool clearError = false,
|
||||
String? modelName,
|
||||
@@ -138,6 +141,7 @@ class ChatState {
|
||||
isLoadingHistory: isLoadingHistory ?? this.isLoadingHistory,
|
||||
isSending: isSending ?? this.isSending,
|
||||
isWorkspaceMode: isWorkspaceMode ?? this.isWorkspaceMode,
|
||||
isWebSearchMode: isWebSearchMode ?? this.isWebSearchMode,
|
||||
error: clearError ? null : (error ?? this.error),
|
||||
modelName: modelName ?? this.modelName,
|
||||
modelStatus: modelStatus ?? this.modelStatus,
|
||||
|
||||
Reference in New Issue
Block a user