Skip to content

Dev #705

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 24 commits into from
Aug 22, 2024
Merged

Dev #705

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
271e8d5
Merge branch 'DEV' of https://github.com/neo4j-labs/llm-graph-builder…
prakriti-solankey Aug 20, 2024
e078e21
connection _check
prakriti-solankey Aug 20, 2024
7c66bf2
Fix typo: correct 'josn_obj' to 'json_obj' (#697)
destiny966113 Aug 20, 2024
477fda0
lint fixes
kartikpersistent Aug 20, 2024
bacbcfc
connection _check
prakriti-solankey Aug 20, 2024
885c345
Merge branch 'DEV' of https://github.com/neo4j-labs/llm-graph-builder…
prakriti-solankey Aug 20, 2024
2fc3e13
Chatbot changes (#700)
vasanthasaikalluri Aug 21, 2024
c0cca99
Merge branch 'DEV' of https://github.com/neo4j-labs/llm-graph-builder…
prakriti-solankey Aug 21, 2024
279d820
fixed issue delete entities return count
praveshkumar1988 Aug 21, 2024
30f92cd
removed specified version due to dependency clashes between versions
praveshkumar1988 Aug 21, 2024
832afd9
Merge branch 'DEV' of https://github.com/neo4j-labs/llm-graph-builder…
praveshkumar1988 Aug 21, 2024
edcff3b
updated script"integration test cases"
abhishekkumar-27 Aug 21, 2024
71ed29a
decreased the delay for pollintg API
kartikpersistent Aug 21, 2024
7eb7605
Merge branch 'DEV' of https://github.com/neo4j-labs/llm-graph-builder…
kartikpersistent Aug 21, 2024
1af5877
Graph enhancements (#696)
prakriti-solankey Aug 21, 2024
4575198
changed chat mode names (#702)
vasanthasaikalluri Aug 21, 2024
2d76462
Merge branch 'STAGING' into DEV
prakriti-solankey Aug 21, 2024
a6ee345
env changes
kartikpersistent Aug 21, 2024
dc351a0
used axios instance for network calls
kartikpersistent Aug 22, 2024
a241c6b
disabled the toolip when dropdown is open state
kartikpersistent Aug 22, 2024
426906b
format fixes + chat mode naming changes
kartikpersistent Aug 22, 2024
78ec3fd
Merge branch 'DEV' of https://github.com/neo4j-labs/llm-graph-builder…
prakriti-solankey Aug 22, 2024
7d0b431
mode added to info model for entities
prakriti-solankey Aug 22, 2024
e60a6e3
Merge branch 'STAGING' into DEV
prakriti-solankey Aug 22, 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ Allow unauthenticated request : Yes
| VITE_LLM_MODELS | Mandatory | diffbot,openai-gpt-3.5,openai-gpt-4o | Models available for selection on the frontend, used for entities extraction and Q&A
| VITE_CHAT_MODES | Mandatory | vector,graph+vector,graph,hybrid | Chat modes available for Q&A
| VITE_ENV | Mandatory | DEV or PROD | Environment variable for the app |
| VITE_TIME_PER_CHUNK | Optional | 4 | Time per chunk for processing |
| VITE_TIME_PER_PAGE | Optional | 50 | Time per page for processing |
| VITE_CHUNK_SIZE | Optional | 5242880 | Size of each chunk of file for upload |
| VITE_GOOGLE_CLIENT_ID | Optional | | Client ID for Google authentication |
| GCS_FILE_CACHE | Optional | False | If set to True, will save the files to process into GCS. If set to False, will save the files locally |
Expand Down
2 changes: 1 addition & 1 deletion backend/src/QA_integration_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

def get_neo4j_retriever(graph, retrieval_query,document_names,mode,index_name="vector",keyword_index="keyword", search_k=CHAT_SEARCH_KWARG_K, score_threshold=CHAT_SEARCH_KWARG_SCORE_THRESHOLD):
try:
if mode == "fulltext" or mode == "fulltext+graph":
if mode == "fulltext" or mode == "graph + vector + fulltext":
neo_db = Neo4jVector.from_existing_graph(
embedding=EMBEDDING_FUNCTION,
index_name=index_name,
Expand Down
1 change: 0 additions & 1 deletion example.env
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ VITE_BLOOM_URL="https://workspace-preview.neo4j.io/workspace/explore?connectURL=
VITE_REACT_APP_SOURCES="local,youtube,wiki,s3,web"
VITE_LLM_MODELS="diffbot,openai-gpt-3.5,openai-gpt-4o" # ",ollama_llama3"
VITE_ENV="DEV"
VITE_TIME_PER_CHUNK=4
VITE_TIME_PER_PAGE=50
VITE_CHUNK_SIZE=5242880
VITE_GOOGLE_CLIENT_ID=""
Expand Down
3 changes: 1 addition & 2 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ ARG VITE_REACT_APP_SOURCES=""
ARG VITE_LLM_MODELS=""
ARG VITE_GOOGLE_CLIENT_ID=""
ARG VITE_BLOOM_URL="https://workspace-preview.neo4j.io/workspace/explore?connectURL={CONNECT_URL}&search=Show+me+a+graph&featureGenAISuggestions=true&featureGenAISuggestionsInternal=true"
ARG VITE_TIME_PER_CHUNK=4
ARG VITE_TIME_PER_PAGE=50
ARG VITE_LARGE_FILE_SIZE=5242880
ARG VITE_CHUNK_SIZE=5242880
Expand All @@ -23,8 +22,8 @@ RUN VITE_BACKEND_API_URL=$VITE_BACKEND_API_URL \
VITE_LLM_MODELS=$VITE_LLM_MODELS \
VITE_GOOGLE_CLIENT_ID=$VITE_GOOGLE_CLIENT_ID \
VITE_BLOOM_URL=$VITE_BLOOM_URL \
VITE_TIME_PER_CHUNK=$VITE_TIME_PER_CHUNK \
VITE_CHUNK_SIZE=$VITE_CHUNK_SIZE \
VITE_TIME_PER_PAGE=$VITE_TIME_PER_PAGE \
VITE_ENV=$VITE_ENV \
VITE_LARGE_FILE_SIZE=${VITE_LARGE_FILE_SIZE} \
VITE_CHAT_MODES=$VITE_CHAT_MODES \
Expand Down
1 change: 0 additions & 1 deletion frontend/example.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ VITE_BLOOM_URL="https://workspace-preview.neo4j.io/workspace/explore?connectURL=
VITE_REACT_APP_SOURCES="local,youtube,wiki,s3,web"
VITE_LLM_MODELS="diffbot,openai-gpt-3.5,openai-gpt-4o"
VITE_ENV="DEV"
VITE_TIME_PER_CHUNK=4
VITE_TIME_PER_PAGE=50
VITE_CHUNK_SIZE=5242880
VITE_LARGE_FILE_SIZE=5242880
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/API/Index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import axios from 'axios';
import { url } from '../utils/Utils';

const api = axios.create({
baseURL: url(),
});
export default api;
2 changes: 1 addition & 1 deletion frontend/src/components/ChatBot/ChatInfoModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ const ChatInfoModal: React.FC<chatInfoMessage> = ({
) : (
<Tabs size='large' fill='underline' onChange={onChangeTabs} value={activeTab}>
{mode != 'graph' ? <Tabs.Tab tabId={3}>Sources used</Tabs.Tab> : <></>}
{mode === 'graph+vector' || mode === 'graph' ? <Tabs.Tab tabId={4}>Top Entities used</Tabs.Tab> : <></>}
{mode === 'graph+vector' || mode === 'graph' || mode === 'graph+vector+fulltext' ? <Tabs.Tab tabId={4}>Top Entities used</Tabs.Tab> : <></>}
{mode === 'graph' && cypher_query?.trim().length ? (
<Tabs.Tab tabId={6}>Generated Cypher Query</Tabs.Tab>
) : (
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/components/ChatBot/ChatModeToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ export default function ChatModeToggle({
() =>
chatModes?.map((m) => {
return {
title: capitalize(m),
title: m.includes('+')
? m
.split('+')
.map((s) => capitalize(s))
.join('+')
: capitalize(m),
onClick: () => {
setchatMode(m);
},
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/components/Dropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Dropdown, Tip } from '@neo4j-ndl/react';
import { OptionType, ReusableDropdownProps } from '../types';
import { useMemo } from 'react';
import { useMemo, useReducer } from 'react';
import { capitalize } from '../utils/Utils';

const DropdownComponent: React.FC<ReusableDropdownProps> = ({
Expand All @@ -13,14 +13,15 @@ const DropdownComponent: React.FC<ReusableDropdownProps> = ({
isDisabled,
value,
}) => {
const [disableTooltip, toggleDisableState] = useReducer((state) => !state, false);
const handleChange = (selectedOption: OptionType | null | void) => {
onSelect(selectedOption);
};
const allOptions = useMemo(() => options, [options]);
return (
<>
<div className={view === 'ContentView' ? 'w-[150px]' : ''}>
<Tip allowedPlacements={['top']}>
<Tip allowedPlacements={['top']} isDisabled={disableTooltip}>
<Tip.Trigger>
<Dropdown
type='select'
Expand Down Expand Up @@ -49,6 +50,12 @@ const DropdownComponent: React.FC<ReusableDropdownProps> = ({
menuPlacement: 'auto',
isDisabled: isDisabled,
value: value,
onMenuOpen: () => {
toggleDisableState();
},
onMenuClose: () => {
toggleDisableState();
},
}}
size='medium'
fluid
Expand Down
78 changes: 45 additions & 33 deletions frontend/src/components/Graph/GraphViewModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,43 +196,50 @@ const GraphViewModal: React.FunctionComponent<GraphViewModalProps> = ({
}, [open]);

// The search and update nodes
const handleSearch = useCallback((value: string) => {
const query = value.toLowerCase();
const updatedNodes = nodes.map((node) => {
if (query === '') {
const handleSearch = useCallback(
(value: string) => {
const query = value.toLowerCase();
const updatedNodes = nodes.map((node) => {
if (query === '') {
return {
...node,
activated: false,
selected: false,
size: graphLabels.nodeSize,
};
}
const { id, properties, caption } = node;
const propertiesMatch = properties?.id?.toLowerCase().includes(query);
const match = id.toLowerCase().includes(query) || propertiesMatch || caption?.toLowerCase().includes(query);
return {
...node,
activated: match,
selected: match,
size:
match && viewPoint === graphLabels.showGraphView
? 100
: match && viewPoint !== graphLabels.showGraphView
? 50
: graphLabels.nodeSize,
};
});
// deactivating any active relationships
const updatedRelationships = relationships.map((rel) => {
return {
...rel,
activated: false,
selected: false,
size: graphLabels.nodeSize
};
}
const { id, properties, caption } = node;
const propertiesMatch = properties?.id?.toLowerCase().includes(query);
const match = id.toLowerCase().includes(query) || propertiesMatch || caption?.toLowerCase().includes(query);
return {
...node,
activated: match,
selected: match,
size: (match && viewPoint === graphLabels.showGraphView) ? 100 : (match && viewPoint !== graphLabels.showGraphView) ? 50 : graphLabels.nodeSize
};

});
// deactivating any active relationships
const updatedRelationships = relationships.map((rel) => {
return {
...rel,
activated: false,
selected: false,
};
});
setNodes(updatedNodes);
setRelationships(updatedRelationships);
}, [nodes]);
});
setNodes(updatedNodes);
setRelationships(updatedRelationships);
},
[nodes]
);

useEffect(() => {
handleSearch(debouncedQuery)
}, [debouncedQuery])
handleSearch(debouncedQuery);
}, [debouncedQuery]);

const initGraph = (
graphType: GraphType[],
Expand Down Expand Up @@ -340,7 +347,12 @@ const GraphViewModal: React.FunctionComponent<GraphViewModalProps> = ({
...node,
activated: isActive,
selected: isActive,
size: (isActive && viewPoint === graphLabels.showGraphView) ? 100 : (isActive && viewPoint !== graphLabels.showGraphView) ? 50 : graphLabels.nodeSize
size:
isActive && viewPoint === graphLabels.showGraphView
? 100
: isActive && viewPoint !== graphLabels.showGraphView
? 50
: graphLabels.nodeSize,
};
});
// deactivating any active relationships
Expand Down Expand Up @@ -372,7 +384,7 @@ const GraphViewModal: React.FunctionComponent<GraphViewModalProps> = ({
...node,
activated: false,
selected: false,
size: graphLabels.nodeSize
size: graphLabels.nodeSize,
};
});
if (searchQuery !== '') {
Expand Down Expand Up @@ -568,4 +580,4 @@ const GraphViewModal: React.FunctionComponent<GraphViewModalProps> = ({
</>
);
};
export default GraphViewModal;
export default GraphViewModal;
12 changes: 2 additions & 10 deletions frontend/src/components/Graph/LegendsChip.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import { LegendChipProps } from '../../types';
import Legend from '../UI/Legend';

export const LegendsChip: React.FunctionComponent<LegendChipProps> = ({
scheme,
label,
type,
count,
onClick,
}) => {
return (
<Legend title={label} count={count} bgColor={scheme[label]} type={type} onClick={onClick}/>
);
export const LegendsChip: React.FunctionComponent<LegendChipProps> = ({ scheme, label, type, count, onClick }) => {
return <Legend title={label} count={count} bgColor={scheme[label]} type={type} onClick={onClick} />;
};
2 changes: 1 addition & 1 deletion frontend/src/components/Layout/PageLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,4 @@ export default function PageLayoutNew({
/>
</div>
);
}
}
2 changes: 1 addition & 1 deletion frontend/src/components/Popups/DeletePopUp/DeletePopUp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ export default function DeletePopUp({
</Dialog.Actions>
</Dialog>
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,4 @@ export default function DeletePopUpForOrphanNodes({
</Flex>
</div>
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@ export default function GraphEnhancementDialog({
</Dialog.Content>
</Dialog>
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ const LargeFilesAlert: FC<LargefilesProps> = ({ largeFiles, handleToggle, checke
</Box>
);
};
export default LargeFilesAlert;
export default LargeFilesAlert;
2 changes: 1 addition & 1 deletion frontend/src/components/QuickStarter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ const QuickStarter: React.FunctionComponent = () => {
</UserCredentialsWrapper>
);
};
export default QuickStarter;
export default QuickStarter;
5 changes: 2 additions & 3 deletions frontend/src/services/CancelAPI.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import axios from 'axios';
import { url } from '../utils/Utils';
import { UserCredentials, commonserverresponse } from '../types';
import api from '../API/Index';

const cancelAPI = async (filenames: string[], source_types: string[]) => {
try {
Expand All @@ -14,7 +13,7 @@ const cancelAPI = async (filenames: string[], source_types: string[]) => {
}
formData.append('filenames', JSON.stringify(filenames));
formData.append('source_types', JSON.stringify(source_types));
const response = await axios.post<commonserverresponse>(`${url()}/cancelled_job`, formData);
const response = await api.post<commonserverresponse>(`/cancelled_job`, formData);
return response;
} catch (error) {
console.log('Error Posting the Question:', error);
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/services/ChunkEntitiesInfo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import axios from 'axios';
import { url } from '../utils/Utils';
import { ChatInfo_APIResponse, UserCredentials } from '../types';
import api from '../API/Index';

const chunkEntitiesAPI = async (userCredentials: UserCredentials, chunk_ids: string) => {
try {
Expand All @@ -10,7 +9,7 @@ const chunkEntitiesAPI = async (userCredentials: UserCredentials, chunk_ids: str
formData.append('password', userCredentials?.password ?? '');
formData.append('chunk_ids', chunk_ids);

const response: ChatInfo_APIResponse = await axios.post(`${url()}/chunk_entities`, formData, {
const response: ChatInfo_APIResponse = await api.post(`/chunk_entities`, formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/services/CommonAPI.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import axios, { AxiosResponse, Method } from 'axios';
import { AxiosResponse, Method } from 'axios';
import { UserCredentials, FormDataParams } from '../types';
import api from '../API/Index';

// API Call
const apiCall = async (
Expand All @@ -16,7 +17,7 @@ const apiCall = async (
for (const key in additionalParams) {
formData.append(key, additionalParams[key]);
}
const response: AxiosResponse = await axios({
const response: AxiosResponse = await api({
method: method,
url: url,
data: formData,
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/services/ConnectAPI.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import axios from 'axios';
import { url } from '../utils/Utils';
import api from '../API/Index';

const connectAPI = async (connectionURI: string, username: string, password: string, database: string) => {
try {
Expand All @@ -8,7 +7,7 @@ const connectAPI = async (connectionURI: string, username: string, password: str
formData.append('database', database ?? '');
formData.append('userName', username ?? '');
formData.append('password', password ?? '');
const response = await axios.post(`${url()}/connect`, formData, {
const response = await api.post(`/connect`, formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/services/DeleteFiles.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import axios from 'axios';
import { url } from '../utils/Utils';
import { CustomFile, UserCredentials } from '../types';
import api from '../API/Index';

const deleteAPI = async (userCredentials: UserCredentials, selectedFiles: CustomFile[], deleteEntities: boolean) => {
try {
Expand All @@ -14,7 +13,7 @@ const deleteAPI = async (userCredentials: UserCredentials, selectedFiles: Custom
formData.append('deleteEntities', JSON.stringify(deleteEntities));
formData.append('filenames', JSON.stringify(filenames));
formData.append('source_types', JSON.stringify(source_types));
const response = await axios.post(`${url()}/delete_document_and_entities`, formData);
const response = await api.post(`/delete_document_and_entities`, formData);
return response;
} catch (error) {
console.log('Error Posting the Question:', error);
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/services/DeleteOrphanNodes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import axios from 'axios';
import { url } from '../utils/Utils';
import { UserCredentials } from '../types';
import api from '../API/Index';

const deleteOrphanAPI = async (userCredentials: UserCredentials, selectedNodes: string[]) => {
try {
Expand All @@ -10,7 +9,7 @@ const deleteOrphanAPI = async (userCredentials: UserCredentials, selectedNodes:
formData.append('userName', userCredentials?.userName ?? '');
formData.append('password', userCredentials?.password ?? '');
formData.append('unconnected_entities_list', JSON.stringify(selectedNodes));
const response = await axios.post(`${url()}/delete_unconnected_nodes`, formData);
const response = await api.post(`/delete_unconnected_nodes`, formData);
return response;
} catch (error) {
console.log('Error Posting the Question:', error);
Expand Down
Loading