leonardo 2 місяців тому
батько
коміт
9094975a16

+ 2 - 2
dist/index.html

@@ -6,8 +6,8 @@
     <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1" />
     <link rel="icon" type="image/x-icon" href="/favicon.ico?v=2" />
     <title>ORÁCULO</title>
-    <script type="module" crossorigin src="/assets/index-BAAztuye.js"></script>
-    <link rel="stylesheet" crossorigin href="/assets/index-C13ET8ov.css">
+    <script type="module" crossorigin src="/assets/index--kZF7n2V.js"></script>
+    <link rel="stylesheet" crossorigin href="/assets/index-BjdCURZL.css">
   </head>
   <body class="bg-background">
     <noscript>

+ 4 - 4
src/api/chat.js

@@ -1,14 +1,14 @@
 import { apiBaseUrl, apiFetch, buildAuthHeaders, refreshAccessToken, notifyAuthError } from "./client.js";
 
-export async function sendChat(message, { conversationId } = {}) {
+export async function sendChat(message, { conversationId, mode } = {}) {
   return apiFetch("/api/chat", {
     method: "POST",
-    body: { message, ...(conversationId ? { conversationId } : {}) }
+    body: { message, ...(conversationId ? { conversationId } : {}), ...(mode ? { mode } : {}) }
   });
 }
 
-export async function sendChatStream(message, { conversationId, onChunk, onSources, onStatus, onDone, onError, signal } = {}) {
-  const body = JSON.stringify({ message, ...(conversationId ? { conversationId } : {}) });
+export async function sendChatStream(message, { conversationId, mode, onChunk, onSources, onStatus, onDone, onError, signal } = {}) {
+  const body = JSON.stringify({ message, ...(conversationId ? { conversationId } : {}), ...(mode ? { mode } : {}) });
 
   const doFetch = () =>
     fetch(`${apiBaseUrl}/api/chat/stream`, {

+ 22 - 2
src/components/ChatWindow.vue

@@ -102,6 +102,25 @@
       </div>
     </div>
 
+    <div class="flex items-center gap-1 self-start rounded-lg border border-gray-200 bg-gray-50 p-0.5 text-xs dark:border-gray-700 dark:bg-gray-800/50">
+      <button
+        type="button"
+        class="rounded-md px-2.5 py-1 font-medium transition-colors"
+        :class="mode === 'documentos' ? 'bg-white text-foreground shadow-sm dark:bg-gray-700' : 'text-gray-500 dark:text-gray-400'"
+        @click="$emit('update:mode', 'documentos')"
+      >
+        Documentos
+      </button>
+      <button
+        type="button"
+        class="rounded-md px-2.5 py-1 font-medium transition-colors"
+        :class="mode === 'atendimentos' ? 'bg-white text-foreground shadow-sm dark:bg-gray-700' : 'text-gray-500 dark:text-gray-400'"
+        @click="$emit('update:mode', 'atendimentos')"
+      >
+        Atendimentos
+      </button>
+    </div>
+
     <div class="grid gap-3 md:grid-cols-[1fr_auto] md:items-end">
       <textarea
         v-model="draft"
@@ -149,10 +168,11 @@ import BaseButton from "./base/BaseButton.vue";
 const props = defineProps({
   messages: { type: Array, required: true },
   loading: { type: Boolean, required: true },
-  error: { type: String, required: true }
+  error: { type: String, required: true },
+  mode: { type: String, default: "documentos" }
 });
 
-const emit = defineEmits(["send", "clearError"]);
+const emit = defineEmits(["send", "clearError", "update:mode"]);
 
 const draft = ref("");
 const chatEl = ref(null);

+ 8 - 0
src/composables/useChat.js

@@ -39,6 +39,7 @@ export function useChat() {
   const conversations = ref([]);
   const activeConversationId = ref(null);
   const messages = ref([...defaultMessages]);
+  const chatMode = ref("documentos");
   const loading = ref(false);
   const error = ref("");
   const conversationsLoading = ref(false);
@@ -202,6 +203,10 @@ export function useChat() {
     error.value = "";
   }
 
+  function setMode(mode) {
+    chatMode.value = mode === "atendimentos" ? "atendimentos" : "documentos";
+  }
+
   function cancelCurrentStream() {
     if (_streamAbort) {
       _streamAbort.abort();
@@ -249,6 +254,7 @@ export function useChat() {
 
     await sendChatStream(trimmed, {
       conversationId: convId,
+      mode: chatMode.value,
       signal: _streamAbort.signal,
       onStatus: ({ stage, count }) => {
         if (stage === "buscando") liveMsg.statusMsg = "Buscando documentos...";
@@ -295,12 +301,14 @@ export function useChat() {
     conversations,
     activeConversationId,
     messages,
+    chatMode,
     loading,
     error,
     conversationsLoading,
     conversationsError,
     conversationsHasMore,
     send,
+    setMode,
     clearError,
     cancelCurrentStream,
     newConversation,

+ 3 - 1
src/views/pagina-inicial/PaginaInicialView.vue

@@ -9,7 +9,9 @@ const {
   messages: chatMessages,
   loading: chatLoading,
   error: chatError,
+  chatMode,
   send: sendMessage,
+  setMode,
   clearError,
   cancelCurrentStream,
   activeConversationId,
@@ -171,7 +173,7 @@ onMounted(() => {
             {{ exportando ? "Exportando..." : "Exportar .md" }}
           </button>
         </div>
-        <ChatWindow class="flex-1 min-h-1" :messages="chatMessages" :loading="chatLoading" :error="chatError" @send="sendMessage" @clearError="clearError" />
+        <ChatWindow class="flex-1 min-h-1" :messages="chatMessages" :loading="chatLoading" :error="chatError" :mode="chatMode" @send="sendMessage" @clearError="clearError" @update:mode="setMode" />
       </div>
     </div>
   </LayoutSistema>