Skip to content

Commit

Permalink
Merge pull request #1456 from ManishMadan2882/main
Browse files Browse the repository at this point in the history
Minor UI adjustments
  • Loading branch information
dartpain authored Nov 27, 2024
2 parents 0584c29 + 0a97e5b commit 4ffdf3f
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 30 deletions.
13 changes: 6 additions & 7 deletions application/api/user/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,12 @@ def get(self):
jsonify({"success": False, "message": "Missing required fields"}), 400
)

try:
doc = sources_collection.find_one(
doc = sources_collection.find_one(
{"_id": ObjectId(source_id), "user": "local"}
)
if not doc:
)
if not doc:
return make_response(jsonify({"status": "not found"}), 404)

try:
if settings.VECTOR_STORE == "faiss":
shutil.rmtree(os.path.join(current_dir, "indexes", str(doc["_id"])))
else:
Expand All @@ -263,12 +262,12 @@ def get(self):
)
vectorstore.delete_index()

sources_collection.delete_one({"_id": ObjectId(source_id)})
except FileNotFoundError:
pass
except Exception as err:
return make_response(jsonify({"success": False, "error": str(err)}), 400)


sources_collection.delete_one({"_id": ObjectId(source_id)})
return make_response(jsonify({"success": True}), 200)


Expand Down
5 changes: 2 additions & 3 deletions frontend/src/conversation/Conversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { useDarkTheme, useMediaQuery } from '../hooks';
import { ShareConversationModal } from '../modals/ShareConversationModal';
import { selectConversationId } from '../preferences/preferenceSlice';
import { AppDispatch } from '../store';
import conversationService from '../api/services/conversationService';
import ConversationBubble from './ConversationBubble';
import { handleSendFeedback } from './conversationHandlers';
import { FEEDBACK, Query } from './conversationModels';
Expand Down Expand Up @@ -323,8 +322,8 @@ export default function Conversation() {
)}
</div>

<div className="flex w-11/12 flex-col items-end self-center rounded-2xl bg-opacity-0 z-3 sm:w-[62%] h-auto">
<div className="flex w-full items-center rounded-[40px] border border-silver bg-white py-1 dark:bg-raisin-black">
<div className="flex w-11/12 flex-col items-end self-center rounded-2xl bg-opacity-0 z-3 sm:w-[62%] h-auto py-1">
<div className="flex w-full items-center rounded-[40px] border border-silver bg-white dark:bg-raisin-black">
<textarea
id="inputbox"
ref={inputRef}
Expand Down
7 changes: 2 additions & 5 deletions frontend/src/conversation/ConversationBubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const ConversationBubble = forwardRef<
style={{
wordBreak: 'break-word',
}}
className="ml-2 mr-2 flex items-center rounded-[28px] bg-purple-30 py-[14px] px-[19px] text-white max-w-full whitespace-pre-wrap leading-normal"
className="text-sm sm:text-base ml-2 mr-2 flex items-center rounded-[28px] bg-purple-30 py-[14px] px-[19px] text-white max-w-full whitespace-pre-wrap leading-normal"
>
{message}
</div>
Expand Down Expand Up @@ -337,10 +337,7 @@ const ConversationBubble = forwardRef<
</div>
</div>
) : (
<code
className={className ? className : 'whitespace-pre-line'}
{...props}
>
<code className="whitespace-pre-line" {...props}>
{children}
</code>
);
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/conversation/conversationSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ export const fetchAnswer = createAsyncThunk<
result: '',
sources: [],
};
},
);
});

export const conversationSlice = createSlice({
name: 'conversation',
Expand Down
34 changes: 21 additions & 13 deletions frontend/src/settings/Documents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Doc, DocumentsProps, ActiveState } from '../models/misc'; // Ensure Act
import { getDocs, getDocsWithPagination } from '../preferences/preferenceApi';
import { setSourceDocs } from '../preferences/preferenceSlice';
import { setPaginatedDocuments } from '../preferences/preferenceSlice';
import { truncate } from '../utils/stringUtils';

// Utility function to format numbers
const formatTokens = (tokens: number): string => {
Expand Down Expand Up @@ -134,7 +135,6 @@ const Documents: React.FC<DocumentsProps> = ({
};

useEffect(() => {
// console.log('modalState', modalState);
if (modalState === 'INACTIVE') {
refreshDocs(sortField, currentPage, rowsPerPage);
}
Expand Down Expand Up @@ -184,13 +184,13 @@ const Documents: React.FC<DocumentsProps> = ({
<div className="flex flex-col">
<div className="flex-grow">
<div className="dark:border-silver/40 border-silver rounded-md border overflow-auto">
<table className="min-w-full divide-y divide-silver dark:divide-silver/40 ">
<table className="min-w-full divide-y divide-silver dark:divide-silver/40 text-xs sm:text-sm ">
<thead>
<tr className="text-nowrap">
<th className="px-5 py-3 text-start text-sm font-medium text-gray-700 dark:text-gray-50 uppercase">
<th className="px-5 py-3 text-start font-medium text-gray-700 dark:text-gray-50 uppercase w-96">
{t('settings.documents.name')}
</th>
<th className="px-5 py-3 text-start text-sm font-medium text-gray-700 dark:text-gray-50 uppercase">
<th className="px-5 py-3 text-start font-medium text-gray-700 dark:text-gray-50 uppercase">
<div className="flex justify-center items-center">
{t('settings.documents.date')}
<img
Expand All @@ -201,7 +201,10 @@ const Documents: React.FC<DocumentsProps> = ({
/>
</div>
</th>
<th className="px-5 py-2 text-center text-sm font-medium text-gray-700 dark:text-gray-50 uppercase">
<th
scope="col"
className="px-5 py-2 text-center font-medium text-gray-700 dark:text-gray-50 uppercase"
>
<div className="flex justify-center items-center">
{t('settings.documents.tokenUsage')}
<img
Expand All @@ -221,16 +224,18 @@ const Documents: React.FC<DocumentsProps> = ({
*/}
<th
scope="col"
className="px-6 py-2 text-start text-xs font-medium text-gray-700 dark:text-gray-50 uppercase"
></th>
className="px-6 py-2 text-start font-medium text-gray-700 dark:text-gray-50 uppercase"
>
{' '}
</th>
</tr>
</thead>
<tbody className="divide-y divide-gray-200 dark:divide-neutral-700">
{!currentDocuments?.length && (
<tr>
<td
colSpan={5}
className="!p-4 text-gray-800 dark:text-neutral-200 text-center"
colSpan={4}
className="!py-4 text-gray-800 dark:text-neutral-200 text-center"
>
{t('settings.documents.noData')}
</td>
Expand All @@ -239,13 +244,16 @@ const Documents: React.FC<DocumentsProps> = ({
{Array.isArray(currentDocuments) &&
currentDocuments.map((document, index) => (
<tr key={index} className="text-nowrap font-normal">
<td className="px-6 py-4 whitespace-nowrap text-left text-sm font-medium text-gray-800 dark:text-neutral-200">
{document.name}
<td
title={document.name}
className="px-6 py-4 whitespace-nowrap text-left font-medium text-gray-800 dark:text-neutral-200"
>
{truncate(document.name, 50)}
</td>
<td className="px-6 py-4 whitespace-nowrap text-center text-sm font-medium text-gray-800 dark:text-neutral-200">
<td className="px-6 py-4 whitespace-nowrap text-center font-medium text-gray-800 dark:text-neutral-200">
{document.date}
</td>
<td className="px-6 py-4 whitespace-nowrap text-center text-sm font-medium text-gray-800 dark:text-neutral-200">
<td className="px-6 py-4 whitespace-nowrap text-center font-medium text-gray-800 dark:text-neutral-200">
{document.tokens
? formatTokens(+document.tokens)
: ''}
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/utils/stringUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export function truncate(str: string, n: number) {
// slices long strings and ends with ...
return str.length > n ? str.slice(0, n - 1) + '...' : str;
}

0 comments on commit 4ffdf3f

Please sign in to comment.