Skip to content

Prod v6 fix #909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
06b2c58
Staging to main (#735)
aashipandya Sep 9, 2024
b80a164
Update FileTable.tsx
kartikpersistent Oct 1, 2024
c7066ee
Merge branch 'STAGING' of https://github.com/neo4j-labs/llm-graph-bui…
prakriti-solankey Oct 25, 2024
1dcc84a
Merge branch 'main' of https://github.com/neo4j-labs/llm-graph-builder
prakriti-solankey Oct 25, 2024
c052227
merge changes
prakriti-solankey Oct 25, 2024
2669e60
Update README.md
kartikpersistent Oct 28, 2024
e9fec8e
Update README.md
kartikpersistent Oct 28, 2024
8d29146
Update README.md
kartikpersistent Oct 29, 2024
86efe46
Update README.md
kartikpersistent Oct 29, 2024
a357b74
Graph visualization improvement and chunk text details (#860)
aashipandya Nov 12, 2024
32f5064
enable communities removed and delete queries updated
kaustubh-darekar Nov 28, 2024
06963fb
nginx security headers
kartikpersistent Nov 28, 2024
ebd6207
removed parameter to include chunk nodes as entity source
aashipandya Nov 28, 2024
a7fa0b4
Ready to reprocess
kartikpersistent Nov 28, 2024
6aa7b66
Merge branch 'prod_v6_fix' of https://github.com/neo4j-labs/llm-graph…
kartikpersistent Nov 28, 2024
efd6218
communities fix
prakriti-solankey Nov 28, 2024
7903fed
dependency fix Reprocess fix
kartikpersistent Nov 28, 2024
4a79dc5
Merge branch 'prod_v6_fix' of https://github.com/neo4j-labs/llm-graph…
kartikpersistent Nov 28, 2024
763ab34
icon size fix
kartikpersistent Nov 28, 2024
7566ecc
z index fix
kartikpersistent Nov 28, 2024
74b1a2c
icon fix
kartikpersistent Nov 28, 2024
2da1f30
icon gap fix
kartikpersistent Nov 28, 2024
6ae6325
upload status
kartikpersistent Nov 28, 2024
c35b78d
Checkbox fix
kartikpersistent Nov 28, 2024
307d667
fix: table issue chat bot clear issue
kartikpersistent Nov 29, 2024
6a32abc
new document deletion, 2nd level community deletion handled
kaustubh-darekar Nov 29, 2024
5155f3f
claer history
prakriti-solankey Nov 29, 2024
4a53afc
Merge branch 'prod_v6_fix' of https://github.com/neo4j-labs/llm-graph…
prakriti-solankey Nov 29, 2024
f0a6b6c
graph info and delete query update
prakriti-solankey Nov 29, 2024
241d22b
Merge branch 'DEV' of https://github.com/neo4j-labs/llm-graph-builder…
prakriti-solankey Dec 2, 2024
653c3ec
format changes
prakriti-solankey Dec 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion backend/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,6 @@ async def fetch_chunktext(
page_no: int = Form(1)
):
try:

start = time.time()
result = await asyncio.to_thread(
get_chunktext_results,
Expand Down
41 changes: 21 additions & 20 deletions backend/src/graphDB_dataAccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,11 @@ def check_gds_version(self):
result = self.graph.query(gds_procedure_count)
total_gds_procedures = result[0]['totalGdsProcedures'] if result else 0

enable_communities = os.environ.get('ENABLE_COMMUNITIES','').upper() == "TRUE"
logging.info(f"Enable Communities {enable_communities}")

if enable_communities and total_gds_procedures > 0:
if total_gds_procedures > 0:
logging.info("GDS is available in the database.")
return True
else:
logging.info("Communities are disabled or GDS is not available in the database.")
logging.info("GDS is not available in the database.")
return False
except Exception as e:
logging.error(f"An error occurred while checking GDS version: {e}")
Expand Down Expand Up @@ -285,27 +282,31 @@ def delete_file_from_graph(self, filenames, source_types, deleteEntities:str, me
query_to_delete_document_and_entities="""
MATCH (d:Document)
WHERE d.fileName IN $filename_list AND d.fileSource IN $source_types_list
WITH COLLECT(d) as documents
WITH COLLECT(d) AS documents
UNWIND documents AS d
MATCH (d)<-[:PART_OF]-(c:Chunk)
WITH d, c, documents
OPTIONAL MATCH (c)-[:HAS_ENTITY]->(e)
OPTIONAL MATCH (d)<-[:PART_OF]-(c:Chunk)
OPTIONAL MATCH (c:Chunk)-[:HAS_ENTITY]->(e)
WITH d, c, e, documents
WHERE NOT EXISTS {
MATCH (e)<-[:HAS_ENTITY]-(c2)-[:PART_OF]->(d2:Document)
WHERE NOT d2 IN documents
}
DETACH DELETE c, e, d
"""
WITH d, COLLECT(c) AS chunks, COLLECT(e) AS entities
FOREACH (chunk IN chunks | DETACH DELETE chunk)
FOREACH (entity IN entities | DETACH DELETE entity)
DETACH DELETE d
"""
query_to_delete_communities = """
MATCH (c:`__Community__`)
WHERE NOT EXISTS { ()-[:IN_COMMUNITY]->(c) } AND c.level = 0
DETACH DELETE c

WITH *
UNWIND range(1, $max_level) AS level
MATCH (c1:`__Community__`)
WHERE c1.level = level AND NOT EXISTS { (c1)<-[:PARENT_COMMUNITY]-(child) }
DETACH DELETE c1
MATCH (c:`__Community__`)
WHERE c.level = 0 AND NOT EXISTS { ()-[:IN_COMMUNITY]->(c) }
DETACH DELETE c
WITH 1 AS dummy
UNWIND range(1, $max_level) AS level
CALL (level) {
MATCH (c:`__Community__`)
WHERE c.level = level AND NOT EXISTS { ()-[:PARENT_COMMUNITY]->(c) }
DETACH DELETE c
}
"""
param = {"filename_list" : filename_list, "source_types_list": source_types_list}
community_param = {"max_level":MAX_COMMUNITY_LEVELS}
Expand Down
2 changes: 1 addition & 1 deletion frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ COPY --from=build /app/dist /usr/share/nginx/html
COPY /nginx/nginx.${DEPLOYMENT_ENV}.conf /etc/nginx/templates/nginx.conf.template

EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]
CMD ["nginx", "-g", "daemon off;"]
42 changes: 21 additions & 21 deletions frontend/nginx/nginx.prod.conf
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
server {
listen 8080;
add_header X-Frame-Options "DENY";
add_header X-Content-Type-Options "nosniff";
add_header Content-Security-Policy "connect-src 'self' ${VITE_BACKEND_API_URL} ${VITE_SEGMENT_API_URL};
frame-src 'self' *.youtube.com *.wikipedia.org;
script-src 'self' 'unsafe-inline' https://accounts.google.com/gsi/client;
default-src 'self' *.${VITE_FRONTEND_HOSTNAME} data:;
style-src 'self' *.googleapis.com 'unsafe-inline';" always ;
gzip on;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
error_page 401 403 404 index.html;
location /public {
root /usr/local/var/www;
}
server {
listen 8080;
add_header X-Frame-Options "DENY";
add_header X-Content-Type-Options "nosniff";
add_header Content-Security-Policy "connect-src 'self' ${VITE_BACKEND_API_URL} ${VITE_SEGMENT_API_URL};
frame-src 'self' *.youtube.com *.wikipedia.org;
script-src 'self' 'unsafe-inline' https://accounts.google.com/gsi/client;
default-src 'self' *.${VITE_FRONTEND_HOSTNAME} data:;
style-src 'self' *.googleapis.com 'unsafe-inline';" always ;
gzip on;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}

error_page 401 403 404 index.html;

location /public {
root /usr/local/var/www;
}
}
4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"@mui/material": "^5.15.10",
"@mui/styled-engine": "^5.15.9",
"@neo4j-devtools/word-color": "^0.0.8",
"@neo4j-ndl/base": "^3.0.14",
"@neo4j-ndl/react": "^3.0.23",
"@neo4j-ndl/base": "^3.0.16",
"@neo4j-ndl/react": "^3.0.30",
"@neo4j-nvl/base": "^0.3.6",
"@neo4j-nvl/react": "^0.3.6",
"@react-oauth/google": "^0.12.1",
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
}

.contentWithChatBot {
width: calc(-528px + 100dvw);
width: calc(-512px + 100dvw);
height: calc(100dvh - 58px);
padding: 3px;
display: flex;
Expand Down Expand Up @@ -395,4 +395,4 @@
}
.tbody-light .ndl-data-grid-tr:hover {
--cell-background: rgb(226 227 229) !important;
}
}
2 changes: 1 addition & 1 deletion frontend/src/components/ChatBot/ChatInfoModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ const ChatInfoModal: React.FC<chatInfoMessage> = ({
[activeChatmodes]
);
return (
<div className='n-bg-palette-neutral-bg-weak p-4 overflow-y-auto'>
<div className='n-bg-palette-neutral-bg-weak p-4'>
<div className='flex flex-row pb-6 items-center mb-2'>
<img
src={Neo4jRetrievalLogo}
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/components/ChatBot/Chatbot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ const Chatbot: FC<ChatbotProps> = (props) => {
} else {
setListMessages((prev) =>
prev.map((msg) =>
(msg.id === chatbotMessageId ? { ...msg, modes: { ...msg.modes, [mode]: responseMode } } : msg)
msg.id === chatbotMessageId ? { ...msg, modes: { ...msg.modes, [mode]: responseMode } } : msg
)
);
}
Expand All @@ -264,7 +264,7 @@ const Chatbot: FC<ChatbotProps> = (props) => {
} else {
setListMessages((prev) =>
prev.map((msg) =>
(msg.id === chatbotMessageId ? { ...msg, modes: { ...msg.modes, [mode]: responseMode } } : msg)
msg.id === chatbotMessageId ? { ...msg, modes: { ...msg.modes, [mode]: responseMode } } : msg
)
);
}
Expand All @@ -273,15 +273,15 @@ const Chatbot: FC<ChatbotProps> = (props) => {
console.error(`API call failed for mode ${mode}:`, result.reason);
setListMessages((prev) =>
prev.map((msg) =>
(msg.id === chatbotMessageId
msg.id === chatbotMessageId
? {
...msg,
modes: {
...msg.modes,
[mode]: { message: 'Failed to fetch response for this mode.', error: result.reason },
},
}
: msg)
: msg
)
);
}
Expand All @@ -294,7 +294,7 @@ const Chatbot: FC<ChatbotProps> = (props) => {
if (error instanceof Error) {
setListMessages((prev) =>
prev.map((msg) =>
(msg.id === chatbotMessageId
msg.id === chatbotMessageId
? {
...msg,
isLoading: false,
Expand All @@ -306,7 +306,7 @@ const Chatbot: FC<ChatbotProps> = (props) => {
},
},
}
: msg)
: msg
)
);
}
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/ChatBot/CommunitiesInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ const CommunitiesInfo: FC<CommunitiesProps> = ({ loading, communities, mode }) =
</ul>
</div>
) : (
<span className='h6 text-center'> No Communities Found</span>
<Typography variant='h6' className='text-center'>
{' '}
No Communities Found
</Typography>
)}
{openGraphView && (
<GraphViewModal
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/ChatBot/EntitiesInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ const EntitiesInfo: FC<EntitiesProps> = ({ loading, mode, graphonly_entities, in
})}
</ul>
) : (
<span className='h6 text-center'>No Entities Found</span>
<Typography variant='h6' className='text-center'>
No Entities Found
</Typography>
)}
{openGraphView && (
<GraphViewModal
Expand Down
35 changes: 19 additions & 16 deletions frontend/src/components/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ const Content: React.FC<ContentProps> = ({
setProcessedCount,
setchatModes,
} = useFileContext();

const [viewPoint, setViewPoint] = useState<'tableView' | 'showGraphView' | 'chatInfoView' | 'neighborView'>(
'tableView'
);
Expand Down Expand Up @@ -128,7 +127,9 @@ const Content: React.FC<ContentProps> = ({
(async () => {
showNormalToast(<PostProcessingToast isGdsActive={isGdsActive} postProcessingTasks={postProcessingTasks} />);
try {
const payload = isGdsActive ? postProcessingTasks : postProcessingTasks.filter((task) => task !== 'enable_communities');
const payload = isGdsActive
? postProcessingTasks
: postProcessingTasks.filter((task) => task !== 'enable_communities');
const response = await postProcessing(userCredentials as UserCredentials, payload);
if (response.data.status === 'Success') {
const communityfiles = response.data?.data;
Expand Down Expand Up @@ -509,8 +510,9 @@ const Content: React.FC<ContentProps> = ({
const handleOpenGraphClick = () => {
const bloomUrl = process.env.VITE_BLOOM_URL;
const uriCoded = userCredentials?.uri.replace(/:\d+$/, '');
const connectURL = `${uriCoded?.split('//')[0]}//${userCredentials?.userName}@${uriCoded?.split('//')[1]}:${userCredentials?.port ?? '7687'
}`;
const connectURL = `${uriCoded?.split('//')[0]}//${userCredentials?.userName}@${uriCoded?.split('//')[1]}:${
userCredentials?.port ?? '7687'
}`;
const encodedURL = encodeURIComponent(connectURL);
const replacedUrl = bloomUrl?.replace('{CONNECT_URL}', encodedURL);
window.open(replacedUrl, '_blank');
Expand All @@ -520,10 +522,10 @@ const Content: React.FC<ContentProps> = ({
isLeftExpanded && isRightExpanded
? 'contentWithExpansion'
: isRightExpanded
? 'contentWithChatBot'
: !isLeftExpanded && !isRightExpanded
? 'w-[calc(100%-128px)]'
: 'contentWithDropzoneExpansion';
? 'contentWithChatBot'
: !isLeftExpanded && !isRightExpanded
? 'w-[calc(100%-128px)]'
: 'contentWithDropzoneExpansion';

const handleGraphView = () => {
setOpenGraphView(true);
Expand Down Expand Up @@ -555,12 +557,12 @@ const Content: React.FC<ContentProps> = ({
return prev.map((f) => {
return f.name === filename
? {
...f,
status: 'Ready to Reprocess',
processingProgress: isStartFromBegining ? 0 : f.processingProgress,
nodesCount: isStartFromBegining ? 0 : f.nodesCount,
relationshipsCount: isStartFromBegining ? 0 : f.relationshipsCount,
}
...f,
status: 'Ready to Reprocess',
processingProgress: isStartFromBegining ? 0 : f.processingProgress,
nodesCount: isStartFromBegining ? 0 : f.nodesCount,
relationshipsCount: isStartFromBegining ? 0 : f.relationshipsCount,
}
: f;
});
});
Expand Down Expand Up @@ -869,8 +871,9 @@ const Content: React.FC<ContentProps> = ({
handleGenerateGraph={processWaitingFilesOnRefresh}
></FileTable>
<Flex
className={`${!isLeftExpanded && !isRightExpanded ? 'w-[calc(100%-128px)]' : 'w-full'
} p-2.5 absolute bottom-4 mt-1.5 self-start`}
className={`${
!isLeftExpanded && !isRightExpanded ? 'w-[calc(100%-128px)]' : 'w-full'
} p-2.5 absolute bottom-4 mt-1.5 self-start`}
justifyContent='space-between'
flexDirection={isTablet ? 'column' : 'row'}
>
Expand Down
22 changes: 0 additions & 22 deletions frontend/src/components/FileTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -970,28 +970,6 @@ const FileTable = forwardRef<ChildRef, FileTableProps>((props, ref) => {
}),
[table]
);
useEffect(() => {
if (tableRef.current) {
// Component has content, calculate maximum height for table
// Observes the height of the content and calculates own height accordingly
const resizeObserver = new ResizeObserver((entries) => {
for (let index = 0; index < entries.length; index++) {
const entry = entries[index];
const { height } = entry.contentRect;
const rowHeight = document?.getElementsByClassName('ndl-data-grid-td')?.[0]?.clientHeight ?? 69;
table.setPageSize(Math.floor(height / rowHeight));
}
});

const [contentElement] = document.getElementsByClassName('ndl-data-grid-scrollable');
resizeObserver.observe(contentElement);

return () => {
// Stop observing content after cleanup
resizeObserver.unobserve(contentElement);
};
}
}, []);

const classNameCheck = isExpanded ? 'fileTableWithExpansion' : `filetable`;

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Graph/GraphPropertiesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ const GraphPropertiesTable = ({ propertiesWithTypes }: GraphPropertiesTableProps
<div className='shrink basis-1/3 overflow-hidden whitespace-nowrap'>
<GraphLabel
type='propertyKey'
className='pointer-events-none !max-w-full overflow-ellipsis'
htmlAttributes={{
tabIndex: -1,
}}
className='pointer-events-none !max-w-full overflow-ellipsis'
>
{key}
</GraphLabel>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const Header: React.FC<HeaderProp> = ({ chatOnly, deleteOnClick, setOpenConnecti
const userName = neo4jConnection.user;
const { password } = neo4jConnection;
const { database } = neo4jConnection;
const [,port]= uri.split(':');
const [, port] = uri.split(':');
const encodedPassword = btoa(password);
const chatUrl = `/chat-only?uri=${encodeURIComponent(
uri
Expand Down
8 changes: 1 addition & 7 deletions frontend/src/components/Layout/PageLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const PageLayout: React.FC<PageLayoutProp> = () => {
const [shows3Modal, toggleS3Modal] = useReducer((s) => !s, false);
const [showGCSModal, toggleGCSModal] = useReducer((s) => !s, false);
const [showGenericModal, toggleGenericModal] = useReducer((s) => !s, false);

const toggleLeftDrawer = () => {
if (largedesktops) {
setIsLeftExpanded(!isLeftExpanded);
Expand Down Expand Up @@ -92,12 +91,7 @@ const PageLayout: React.FC<PageLayoutProp> = () => {
}
try {
const parsedConnection = JSON.parse(neo4jConnection);
if (
parsedConnection.uri &&
parsedConnection.user &&
parsedConnection.password &&
parsedConnection.database
) {
if (parsedConnection.uri && parsedConnection.user && parsedConnection.password && parsedConnection.database) {
setUserCredentials({
uri: parsedConnection.uri,
userName: parsedConnection.user,
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/Popups/ChunkPopUp/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const ChunkPopUp = ({
const sortedChunksData = useMemo(() => {
return chunks.sort((a, b) => a.position - b.position);
}, [chunks]);

return (
<Dialog isOpen={showChunkPopup} onClose={onClose}>
<Dialog.Header>
Expand Down
Loading