Network Error
{query.error}
@@ -594,21 +658,24 @@ export const DocsGPTWidget = ({
:
}
-
-
- setPrompt(event.target.value)}
- type='text' placeholder="What do you want to do?" />
-
-
-
-
+
+
+ setPrompt(event.target.value)}
+ type='text' placeholder="Ask your question" />
+
+
+
+
+
+ Powered by
+ DocsGPT
+
+
}
- >
+
)
}
\ No newline at end of file
diff --git a/extensions/react-widget/src/types/index.ts b/extensions/react-widget/src/types/index.ts
index bd27910b..6a6d30a7 100644
--- a/extensions/react-widget/src/types/index.ts
+++ b/extensions/react-widget/src/types/index.ts
@@ -24,10 +24,19 @@ export interface WidgetProps {
description?: string;
heroTitle?: string;
heroDescription?: string;
- size?: 'small' | 'medium' | 'large';
+ size?: 'small' | 'medium' | 'large' | {
+ custom: {
+ width: string;
+ height: string;
+ maxWidth?: string;
+ maxHeight?: string;
+ };
+ };
theme?:THEME,
buttonIcon?:string;
+ buttonText?:string;
buttonBg?:string;
- collectFeedback?:boolean
+ collectFeedback?:boolean;
+ deafultOpen?: boolean;
showSources?: boolean
}
\ No newline at end of file
diff --git a/frontend/src/Navigation.tsx b/frontend/src/Navigation.tsx
index ce23e90e..3591469b 100644
--- a/frontend/src/Navigation.tsx
+++ b/frontend/src/Navigation.tsx
@@ -254,7 +254,7 @@ export default function Navigation({ navOpen, setNavOpen }: NavigationProps) {
ref={navRef}
className={`${
!navOpen && '-ml-96 md:-ml-[18rem]'
- } duration-20 fixed top-0 z-40 flex h-full w-72 flex-col border-r-[1px] border-b-0 bg-white transition-all dark:border-r-purple-taupe dark:bg-chinese-black dark:text-white`}
+ } duration-20 fixed top-0 z-20 flex h-full w-72 flex-col border-r-[1px] border-b-0 bg-white transition-all dark:border-r-purple-taupe dark:bg-chinese-black dark:text-white`}
>
=> apiClient.get(endpoints.USER.DOCS),
+ getDocs: (sort = 'date', order = 'desc'): Promise
=>
+ apiClient.get(`${endpoints.USER.DOCS}?sort=${sort}&order=${order}`),
checkDocs: (data: any): Promise =>
apiClient.post(endpoints.USER.DOCS_CHECK, data),
getAPIKeys: (): Promise => apiClient.get(endpoints.USER.API_KEYS),
diff --git a/frontend/src/conversation/ConversationBubble.tsx b/frontend/src/conversation/ConversationBubble.tsx
index a9a05168..284c2b56 100644
--- a/frontend/src/conversation/ConversationBubble.tsx
+++ b/frontend/src/conversation/ConversationBubble.tsx
@@ -474,7 +474,7 @@ function AllSources(sources: AllSourcesProps) {
>
) : null}
-
+
{source.text}
diff --git a/frontend/src/conversation/conversationSlice.ts b/frontend/src/conversation/conversationSlice.ts
index 1b7e9d41..3ca05c7b 100644
--- a/frontend/src/conversation/conversationSlice.ts
+++ b/frontend/src/conversation/conversationSlice.ts
@@ -20,6 +20,7 @@ const API_STREAMING = import.meta.env.VITE_API_STREAMING === 'true';
export const fetchAnswer = createAsyncThunk
(
'fetchAnswer',
async ({ question }, { dispatch, getState, signal }) => {
+ let isSourceUpdated = false;
const state = getState() as RootState;
if (state.preference) {
if (API_STREAMING) {
@@ -36,9 +37,7 @@ export const fetchAnswer = createAsyncThunk(
(event) => {
const data = JSON.parse(event.data);
- // check if the 'end' event has been received
if (data.type === 'end') {
- // set status to 'idle'
dispatch(conversationSlice.actions.setStatus('idle'));
getConversations()
.then((fetchedConversations) => {
@@ -47,6 +46,14 @@ export const fetchAnswer = createAsyncThunk(
.catch((error) => {
console.error('Failed to fetch conversations: ', error);
});
+ if (!isSourceUpdated) {
+ dispatch(
+ updateStreamingSource({
+ index: state.conversation.queries.length - 1,
+ query: { sources: [] },
+ }),
+ );
+ }
} else if (data.type === 'id') {
dispatch(
updateConversationId({
@@ -54,6 +61,7 @@ export const fetchAnswer = createAsyncThunk(
}),
);
} else if (data.type === 'source') {
+ isSourceUpdated = true;
dispatch(
updateStreamingSource({
index: state.conversation.queries.length - 1,
diff --git a/frontend/src/preferences/preferenceApi.ts b/frontend/src/preferences/preferenceApi.ts
index ed730f7c..af1060b8 100644
--- a/frontend/src/preferences/preferenceApi.ts
+++ b/frontend/src/preferences/preferenceApi.ts
@@ -3,9 +3,12 @@ import userService from '../api/services/userService';
import { Doc } from '../models/misc';
//Fetches all JSON objects from the source. We only use the objects with the "model" property in SelectDocsModal.tsx. Hopefully can clean up the source file later.
-export async function getDocs(): Promise {
+export async function getDocs(
+ sort = 'date',
+ order = 'desc',
+): Promise {
try {
- const response = await userService.getDocs();
+ const response = await userService.getDocs(sort, order);
const data = await response.json();
const docs: Doc[] = [];
diff --git a/frontend/src/settings/Documents.tsx b/frontend/src/settings/Documents.tsx
index 004b6f48..f94d1a87 100644
--- a/frontend/src/settings/Documents.tsx
+++ b/frontend/src/settings/Documents.tsx
@@ -45,14 +45,30 @@ const Documents: React.FC = ({
const [modalState, setModalState] = useState('INACTIVE'); // Initialize with inactive state
const [isOnboarding, setIsOnboarding] = useState(false); // State for onboarding flag
const [loading, setLoading] = useState(false);
-
+ const [sortField, setSortField] = useState<'date' | 'tokens'>('date');
+ const [sortOrder, setSortOrder] = useState<'asc' | 'desc'>('desc');
const syncOptions = [
{ label: 'Never', value: 'never' },
{ label: 'Daily', value: 'daily' },
{ label: 'Weekly', value: 'weekly' },
{ label: 'Monthly', value: 'monthly' },
];
-
+ const refreshDocs = (field: 'date' | 'tokens') => {
+ if (field === sortField) {
+ setSortOrder(sortOrder === 'asc' ? 'desc' : 'asc');
+ } else {
+ setSortOrder('desc');
+ setSortField(field);
+ }
+ getDocs(sortField, sortOrder)
+ .then((data) => {
+ dispatch(setSourceDocs(data));
+ })
+ .catch((error) => console.error(error))
+ .finally(() => {
+ setLoading(false);
+ });
+ };
const handleManageSync = (doc: Doc, sync_frequency: string) => {
setLoading(true);
userService
@@ -110,19 +126,28 @@ const Documents: React.FC = ({
{t('settings.documents.date')}
- 
+ ![]() refreshDocs('date')}
+ src={caretSort}
+ alt="sort"
+ />
|
{t('settings.documents.tokenUsage')}
- 
+ ![]() refreshDocs('tokens')}
+ src={caretSort}
+ alt="sort"
+ />
|
{t('settings.documents.type')}
-
|
|