= ({ generationId, citationKey, agentId }
const safeUrl = getSafeUrl(document.url);
const { text, lightText, fill, lightFill, dark, light } = useBrandedColors(agentId);
- const brandedClassName = cn(text, lightText, dark(lightFill), light(fill));
+ const brandedClassName = cn(dark(lightText), light(text), dark(lightFill), light(fill));
return (
diff --git a/src/interfaces/assistants_web/src/components/UI/Button.tsx b/src/interfaces/assistants_web/src/components/UI/Button.tsx
index b6e52930ef..00697f1a12 100644
--- a/src/interfaces/assistants_web/src/components/UI/Button.tsx
+++ b/src/interfaces/assistants_web/src/components/UI/Button.tsx
@@ -33,7 +33,8 @@ const getLabelStyles = (kind: ButtonKind, theme: ButtonTheme, disabled: boolean)
theme === 'blue' ||
theme === 'quartz' ||
theme === 'evolved-blue' ||
- theme === 'evolved-quartz',
+ theme === 'evolved-quartz' ||
+ theme === 'mushroom',
// dark mode
'dark:text-volcanic-150 dark:fill-volcanic-150':
theme === 'evolved-green' ||
diff --git a/src/interfaces/assistants_web/src/hooks/use-brandedColors.ts b/src/interfaces/assistants_web/src/hooks/use-brandedColors.ts
index 8294e51717..7b4129d9f4 100644
--- a/src/interfaces/assistants_web/src/hooks/use-brandedColors.ts
+++ b/src/interfaces/assistants_web/src/hooks/use-brandedColors.ts
@@ -15,21 +15,21 @@ const ASSISTANT_COLORS = [
'quartz-500',
'evolved-quartz-700',
'evolved-mushroom-500',
- 'mushroom-300',
+ 'mushroom-500',
];
const ASSISTANT_LIGHT_COLORS = [
'green-800',
'quartz-800',
'evolved-quartz-900',
'evolved-mushroom-800',
- 'mushroom-600',
+ 'mushroom-700',
];
const ASSISTANT_CONTRAST_COLORS = [
'marble-950',
'marble-950',
'marble-950',
'volcanic-100',
- 'mushroom-800',
+ 'mushroom-900',
];
const DEFAULT_COLOR = 'evolved-blue-500';
const DEFAULT_LIGHT_COLOR = 'blue-800';
From de58a58451ea685ba8783410e995ca6dfb6b13c3 Mon Sep 17 00:00:00 2001
From: Tomeu
Date: Thu, 22 Aug 2024 17:57:42 +0200
Subject: [PATCH 4/6] fix: try to update citations starting points when a code
block is present (#731)
* fix: try to update citations start and end points when there is a code block present
* fix: decoding data before to generate file
* fix: multiple blocks with multi citations
---
.../src/stores/slices/citationsSlice.ts | 4 +-
.../src/utils/citations.test.ts | 203 +++++++++++++++++-
.../assistants_web/src/utils/citations.ts | 85 +++++++-
3 files changed, 271 insertions(+), 21 deletions(-)
diff --git a/src/interfaces/assistants_web/src/stores/slices/citationsSlice.ts b/src/interfaces/assistants_web/src/stores/slices/citationsSlice.ts
index e1f5ffafc6..4257301f4a 100644
--- a/src/interfaces/assistants_web/src/stores/slices/citationsSlice.ts
+++ b/src/interfaces/assistants_web/src/stores/slices/citationsSlice.ts
@@ -1,7 +1,7 @@
import { StateCreator } from 'zustand';
import { Document } from '@/cohere-client';
-import { mapExtensionToMimeType } from '@/utils';
+import { decodeBase64, mapExtensionToMimeType } from '@/utils';
import { StoreState } from '..';
@@ -87,7 +87,7 @@ export const createCitationsSlice: StateCreator {
},
]);
});
+
+ test('should fix citations position for to get the correct markdown', () => {
+ const citations = [
+ {
+ text: '(fn',
+ start: 71,
+ end: 74,
+ document_ids: ['12345'],
+ },
+ {
+ text: 'delay',
+ start: 76,
+ end: 81,
+ document_ids: ['12345'],
+ },
+ {
+ text: 'let debounceTimer',
+ start: 86,
+ end: 103,
+ document_ids: ['12345'],
+ },
+ {
+ text: 'return function',
+ start: 107,
+ end: 122,
+ document_ids: ['12345'],
+ },
+ {
+ text: 'args',
+ start: 126,
+ end: 130,
+ document_ids: ['12345'],
+ },
+ {
+ text: 'clearTimeout',
+ start: 135,
+ end: 147,
+ document_ids: ['12345'],
+ },
+ {
+ text: '(debounceTimer',
+ start: 147,
+ end: 161,
+ document_ids: ['12345'],
+ },
+ {
+ text: 'debounceTimer = setTimeout',
+ start: 165,
+ end: 191,
+ document_ids: ['12345'],
+ },
+ {
+ text: 'fn.apply(this, args',
+ start: 201,
+ end: 220,
+ document_ids: ['12345'],
+ },
+ {
+ text: 'delay',
+ start: 227,
+ end: 232,
+ document_ids: ['12345'],
+ },
+ {
+ text: 'code is only executed once per user input',
+ start: 285,
+ end: 326,
+ document_ids: ['12345'],
+ },
+ {
+ text: 'takes two parameters',
+ start: 331,
+ end: 351,
+ document_ids: ['12345'],
+ },
+ {
+ text: 'the function to be debounced',
+ start: 353,
+ end: 381,
+ document_ids: ['12345'],
+ },
+ {
+ text: 'the delay in milliseconds',
+ start: 386,
+ end: 411,
+ document_ids: ['12345'],
+ },
+ ];
+ const text =
+ "Here's a JavaScript debounce function: ```javascript function debounce(fn, delay) { let debounceTimer; return function(...args) { clearTimeout(debounceTimer); debounceTimer = setTimeout(() => { fn.apply(this, args); }, delay); }; } ``` The debounce function ensures that the code is only executed once per user input. It takes two parameters: the function to be debounced and the delay in milliseconds.";
+ const result = fixInlineCitationsForMarkdown(citations, text);
+ expect(result).toStrictEqual([
+ {
+ text: '(fn',
+ start: 71,
+ end: 74,
+ document_ids: ['12345'],
+ },
+ {
+ text: 'delay',
+ start: 76,
+ end: 81,
+ document_ids: ['12345'],
+ },
+ {
+ text: 'let debounceTimer',
+ start: 86,
+ end: 103,
+ document_ids: ['12345'],
+ },
+ {
+ text: 'return function',
+ start: 107,
+ end: 122,
+ document_ids: ['12345'],
+ },
+ {
+ text: 'args',
+ start: 126,
+ end: 130,
+ document_ids: ['12345'],
+ },
+ {
+ text: 'clearTimeout',
+ start: 135,
+ end: 147,
+ document_ids: ['12345'],
+ },
+ {
+ text: '(debounceTimer',
+ start: 147,
+ end: 161,
+ document_ids: ['12345'],
+ },
+ {
+ text: 'debounceTimer = setTimeout',
+ start: 165,
+ end: 191,
+ document_ids: ['12345'],
+ },
+ {
+ text: 'fn.apply(this, args',
+ start: 201,
+ end: 220,
+ document_ids: ['12345'],
+ },
+ {
+ text: 'delay',
+ start: 227,
+ end: 232,
+ document_ids: ['12345'],
+ },
+ {
+ text: 'code is only executed once per user input',
+ start: 301,
+ end: 342,
+ document_ids: ['12345'],
+ },
+ {
+ text: 'takes two parameters',
+ start: 347,
+ end: 367,
+ document_ids: ['12345'],
+ },
+ {
+ text: 'the function to be debounced',
+ start: 369,
+ end: 397,
+ document_ids: ['12345'],
+ },
+ {
+ text: 'the delay in milliseconds',
+ start: 402,
+ end: 427,
+ document_ids: ['12345'],
+ },
+ ]);
+ });
});
describe('isReferenceBetweenSpecialTags', () => {
test('should return true if the citation is between