Skip to content
Merged

Staging #1104

Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 20 additions & 12 deletions backend/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,14 @@ async def create_source_knowledge_graph_url(
# Set the status "Success" becuase we are treating these error already handled by application as like custom errors.
json_obj = {'error_message':error_message, 'status':'Success','db_url':uri, 'userName':userName, 'database':database,'success_count':1, 'source_type': source_type, 'source_url':source_url, 'wiki_query':wiki_query, 'logging_time': formatted_time(datetime.now(timezone.utc)),'email':email}
logger.log_struct(json_obj, "INFO")
logging.exception(f'File Failed in upload: {e}')
return create_api_response('Failed',message=message + error_message[:80],error=error_message,file_source=source_type)
except Exception as e:
error_message = str(e)
message = f" Unable to create source node for source type: {source_type} and source: {source}"
json_obj = {'error_message':error_message, 'status':'Failed','db_url':uri, 'userName':userName, 'database':database,'failed_count':1, 'source_type': source_type, 'source_url':source_url, 'wiki_query':wiki_query, 'logging_time': formatted_time(datetime.now(timezone.utc)),'email':email}
logger.log_struct(json_obj, "ERROR")
logging.exception(f'Exception Stack trace:')
logging.exception(f'Exception Stack trace upload:{e}')
return create_api_response('Failed',message=message + error_message[:80],error=error_message,file_source=source_type)
finally:
gc.collect()
Expand Down Expand Up @@ -284,6 +285,7 @@ async def extract_knowledge_graph_from_file(
json_obj = {'api_name':'extract','message':error_message,'file_created_at':formatted_time(node_detail[0]['created_time']),'error_message':error_message, 'file_name': file_name,'status':'Completed',
'db_url':uri, 'userName':userName, 'database':database,'success_count':1, 'source_type': source_type, 'source_url':source_url, 'wiki_query':wiki_query, 'logging_time': formatted_time(datetime.now(timezone.utc)),'email':email}
logger.log_struct(json_obj, "INFO")
logging.exception(f'File Failed in extraction: {e}')
return create_api_response("Failed", message = error_message, error=error_message, file_name=file_name)
except Exception as e:
message=f"Failed To Process File:{file_name} or LLM Unable To Parse Content "
Expand All @@ -295,26 +297,32 @@ async def extract_knowledge_graph_from_file(
json_obj = {'api_name':'extract','message':message,'file_created_at':formatted_time(node_detail[0]['created_time']),'error_message':error_message, 'file_name': file_name,'status':'Failed',
'db_url':uri, 'userName':userName, 'database':database,'failed_count':1, 'source_type': source_type, 'source_url':source_url, 'wiki_query':wiki_query, 'logging_time': formatted_time(datetime.now(timezone.utc)),'email':email}
logger.log_struct(json_obj, "ERROR")
logging.exception(f'File Failed in extraction: {e}')
return create_api_response('Failed', message=message + error_message[:100], error=error_message, file_name = file_name)
finally:
gc.collect()

@app.get("/sources_list")
async def get_source_list(uri:str=None, userName:str=None, password:str=None, email:str=None, database:str=None):
@app.post("/sources_list")
async def get_source_list(
uri=Form(None),
userName=Form(None),
password=Form(None),
database=Form(None),
email=Form(None)):
"""
Calls 'get_source_list_from_graph' which returns list of sources which already exist in databse
"""
try:
start = time.time()
if password is not None and password != "null":
decoded_password = decode_password(password)
else:
decoded_password = None
userName = None
database = None
if " " in uri:
uri = uri.replace(" ","+")
result = await asyncio.to_thread(get_source_list_from_graph,uri,userName,decoded_password,database)
# if password is not None and password != "null":
# decoded_password = decode_password(password)
# else:
# decoded_password = None
# userName = None
# database = None
# if " " in uri:
# uri = uri.replace(" ","+")
result = await asyncio.to_thread(get_source_list_from_graph,uri,userName,password,database)
end = time.time()
elapsed_time = end - start
json_obj = {'api_name':'sources_list','db_url':uri, 'userName':userName, 'database':database, 'logging_time': formatted_time(datetime.now(timezone.utc)), 'elapsed_api_time':f'{elapsed_time:.2f}','email':email}
Expand Down
2 changes: 1 addition & 1 deletion backend/src/document_sources/gcs_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def merge_file_gcs(bucket_name, original_file_name: str, folder_name_sha1_hashed
if blob.exists():
logging.info(f'Blob Name: {blob.name}')
chunks.append(blob.download_as_bytes())
blob.delete()
blob.delete()

merged_file = b"".join(chunks)
file_name_with__hashed_folder = folder_name_sha1_hashed +'/'+original_file_name
Expand Down
7 changes: 4 additions & 3 deletions backend/src/graphDB_dataAccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ def update_exception_db(self, file_name, exp_msg, retry_condition):
try:
job_status = "Failed"
result = self.get_current_status_document_node(file_name)
is_cancelled_status = result[0]['is_cancelled']
if bool(is_cancelled_status) == True:
job_status = 'Cancelled'
if len(result) > 0:
is_cancelled_status = result[0]['is_cancelled']
if bool(is_cancelled_status) == True:
job_status = 'Cancelled'
if retry_condition is not None:
retry_condition = None
self.graph.query("""MERGE(d:Document {fileName :$fName}) SET d.status = $status, d.errorMessage = $error_msg, d.retry_condition = $retry_condition""",
Expand Down
36 changes: 16 additions & 20 deletions backend/src/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,24 +194,20 @@ async def get_graph_document_list(
return graph_document_list

async def get_graph_from_llm(model, chunkId_chunkDoc_list, allowedNodes, allowedRelationship, chunks_to_combine, additional_instructions=None):
try:
llm, model_name = get_llm(model)
combined_chunk_document_list = get_combined_chunks(chunkId_chunkDoc_list, chunks_to_combine)

llm, model_name = get_llm(model)
combined_chunk_document_list = get_combined_chunks(chunkId_chunkDoc_list, chunks_to_combine)

if allowedNodes is None or allowedNodes=="":
allowedNodes =[]
else:
allowedNodes = allowedNodes.split(',')
if allowedRelationship is None or allowedRelationship=="":
allowedRelationship=[]
else:
allowedRelationship = allowedRelationship.split(',')

if allowedNodes is None or allowedNodes=="":
allowedNodes =[]
else:
allowedNodes = allowedNodes.split(',')
if allowedRelationship is None or allowedRelationship=="":
allowedRelationship=[]
else:
allowedRelationship = allowedRelationship.split(',')

graph_document_list = await get_graph_document_list(
llm, combined_chunk_document_list, allowedNodes, allowedRelationship, additional_instructions
)
return graph_document_list
except Exception as e:
err = f"Error during extracting graph with llm: {e}"
logging.error(err)
raise
graph_document_list = await get_graph_document_list(
llm, combined_chunk_document_list, allowedNodes, allowedRelationship, additional_instructions
)
return graph_document_list
12 changes: 6 additions & 6 deletions backend/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ async def extract_graph_from_file_local_file(uri, userName, password, database,
file_name, pages, file_extension = get_documents_from_file_by_path(merged_file_path,fileName)
if pages==None or len(pages)==0:
raise LLMGraphBuilderException(f'File content is not available for file : {file_name}')
return await processing_source(uri, userName, password, database, model, file_name, pages, allowedNodes, allowedRelationship, token_chunk_size, chunk_overlap, chunks_to_combine, True, merged_file_path)
return await processing_source(uri, userName, password, database, model, file_name, pages, allowedNodes, allowedRelationship, token_chunk_size, chunk_overlap, chunks_to_combine, True, merged_file_path, additional_instructions=additional_instructions)
else:
return await processing_source(uri, userName, password, database, model, fileName, [], allowedNodes, allowedRelationship, token_chunk_size, chunk_overlap, chunks_to_combine, True, merged_file_path, retry_condition, additional_instructions=additional_instructions)

Expand All @@ -247,7 +247,7 @@ async def extract_graph_from_file_s3(uri, userName, password, database, model, s

if pages==None or len(pages)==0:
raise LLMGraphBuilderException(f'File content is not available for file : {file_name}')
return await processing_source(uri, userName, password, database, model, file_name, pages, allowedNodes, allowedRelationship, token_chunk_size, chunk_overlap, chunks_to_combine)
return await processing_source(uri, userName, password, database, model, file_name, pages, allowedNodes, allowedRelationship, token_chunk_size, chunk_overlap, chunks_to_combine, additional_instructions=additional_instructions)
else:
return await processing_source(uri, userName, password, database, model, file_name, [], allowedNodes, allowedRelationship, token_chunk_size, chunk_overlap, chunks_to_combine, retry_condition=retry_condition, additional_instructions=additional_instructions)

Expand All @@ -256,7 +256,7 @@ async def extract_graph_from_web_page(uri, userName, password, database, model,
file_name, pages = get_documents_from_web_page(source_url)
if pages==None or len(pages)==0:
raise LLMGraphBuilderException(f'Content is not available for given URL : {file_name}')
return await processing_source(uri, userName, password, database, model, file_name, pages, allowedNodes, allowedRelationship, token_chunk_size, chunk_overlap, chunks_to_combine)
return await processing_source(uri, userName, password, database, model, file_name, pages, allowedNodes, allowedRelationship, token_chunk_size, chunk_overlap, chunks_to_combine, additional_instructions=additional_instructions)
else:
return await processing_source(uri, userName, password, database, model, file_name, [], allowedNodes, allowedRelationship, token_chunk_size, chunk_overlap, chunks_to_combine, retry_condition=retry_condition, additional_instructions=additional_instructions)

Expand All @@ -266,7 +266,7 @@ async def extract_graph_from_file_youtube(uri, userName, password, database, mod

if pages==None or len(pages)==0:
raise LLMGraphBuilderException(f'Youtube transcript is not available for file : {file_name}')
return await processing_source(uri, userName, password, database, model, file_name, pages, allowedNodes, allowedRelationship, token_chunk_size, chunk_overlap, chunks_to_combine)
return await processing_source(uri, userName, password, database, model, file_name, pages, allowedNodes, allowedRelationship, token_chunk_size, chunk_overlap, chunks_to_combine, additional_instructions=additional_instructions)
else:
return await processing_source(uri, userName, password, database, model, file_name, [], allowedNodes, allowedRelationship, token_chunk_size, chunk_overlap, chunks_to_combine, retry_condition=retry_condition, additional_instructions=additional_instructions)

Expand All @@ -275,7 +275,7 @@ async def extract_graph_from_file_Wikipedia(uri, userName, password, database, m
file_name, pages = get_documents_from_Wikipedia(wiki_query, language)
if pages==None or len(pages)==0:
raise LLMGraphBuilderException(f'Wikipedia page is not available for file : {file_name}')
return await processing_source(uri, userName, password, database, model, file_name, pages, allowedNodes, allowedRelationship, token_chunk_size, chunk_overlap, chunks_to_combine)
return await processing_source(uri, userName, password, database, model, file_name, pages, allowedNodes, allowedRelationship, token_chunk_size, chunk_overlap, chunks_to_combine, additional_instructions=additional_instructions)
else:
return await processing_source(uri, userName, password, database, model, file_name,[], allowedNodes, allowedRelationship, token_chunk_size, chunk_overlap, chunks_to_combine, retry_condition=retry_condition, additional_instructions=additional_instructions)

Expand All @@ -284,7 +284,7 @@ async def extract_graph_from_file_gcs(uri, userName, password, database, model,
file_name, pages = get_documents_from_gcs(gcs_project_id, gcs_bucket_name, gcs_bucket_folder, gcs_blob_filename, access_token)
if pages==None or len(pages)==0:
raise LLMGraphBuilderException(f'File content is not available for file : {file_name}')
return await processing_source(uri, userName, password, database, model, file_name, pages, allowedNodes, allowedRelationship, token_chunk_size, chunk_overlap, chunks_to_combine)
return await processing_source(uri, userName, password, database, model, file_name, pages, allowedNodes, allowedRelationship, token_chunk_size, chunk_overlap, chunks_to_combine, additional_instructions=additional_instructions)
else:
return await processing_source(uri, userName, password, database, model, file_name, [], allowedNodes, allowedRelationship, token_chunk_size, chunk_overlap, chunks_to_combine, retry_condition=retry_condition, additional_instructions=additional_instructions)

Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ services:
# - LLM_MODEL_CONFIG_bedrock_claude_3_5_sonnet=${LLM_MODEL_CONFIG_bedrock_claude_3_5_sonnet-}
# - LLM_MODEL_CONFIG_fireworks_qwen_72b=${LLM_MODEL_CONFIG_fireworks_qwen_72b-}
- LLM_MODEL_CONFIG_ollama_llama3=${LLM_MODEL_CONFIG_ollama_llama3-}
# env_file:
# - ./backend/.env
container_name: backend
extra_hosts:
- host.docker.internal:host-gateway
Expand Down
36 changes: 0 additions & 36 deletions example.env

This file was deleted.

12 changes: 6 additions & 6 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@
"uuid": "^9.0.1"
},
"devDependencies": {
"@tailwindcss/postcss": "^4.0.7",
"@types/node": "^20.11.10",
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@vitejs/plugin-react": "^4.0.3",
"autoprefixer": "^10.4.17",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-react-refresh": "^0.4.3",
"postcss": "^8.4.33",
"prettier": "^2.7.1",
"react-dropzone": "^14.2.3",
"tailwindcss": "^4.0.6",
"typescript": "^5.0.2",
"react-dropzone": "^14.3.5",
"tailwindcss": "^4.0.7",
"typescript": "^5.7.3",
"vite": "^4.5.3"
}
}
3 changes: 1 addition & 2 deletions frontend/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
'@tailwindcss/postcss': {},
},
}
7 changes: 6 additions & 1 deletion frontend/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@
.layout-wrapper{
display: grid;
grid-template-rows: auto;
grid-template-columns: 64px 1fr minmax(min-content,4fr) 1.4fr 64px;
grid-template-columns: 64px 1fr minmax(min-content,4fr) 1.1fr 64px;
max-height: calc(100vh - 58px);
max-width: 100%;
}
Expand All @@ -356,3 +356,8 @@
position: relative;
height: 100%;
}
.sidenav-container{
height: calc(100vh - 58px);
min-height: 200px;
display: flex
}
8 changes: 4 additions & 4 deletions frontend/src/components/ChatBot/Chatbot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ const Chatbot: FC<ChatbotProps> = (props) => {
className='-ml-4'
hasStatus
name='KM'
size='x-large'
size='large'
source={ChatBotAvatar}
status={connectionStatus ? 'online' : 'offline'}
shape='square'
Expand All @@ -447,7 +447,7 @@ const Chatbot: FC<ChatbotProps> = (props) => {
className=''
hasStatus
name='KM'
size='x-large'
size='large'
status={connectionStatus ? 'online' : 'offline'}
shape='square'
type='image'
Expand All @@ -457,7 +457,7 @@ const Chatbot: FC<ChatbotProps> = (props) => {
<Widget
header=''
isElevated={true}
className={`p-4 self-start ${isFullScreen ? 'max-w-[55%]' : ''} ${
className={`p-3! self-start ${isFullScreen ? 'max-w-[55%]' : ''} ${
chat.user === 'chatbot' ? 'n-bg-palette-neutral-bg-strong' : 'n-bg-palette-primary-bg-weak'
}`}
>
Expand Down Expand Up @@ -612,7 +612,7 @@ const Chatbot: FC<ChatbotProps> = (props) => {
}}
>
<ArrowDownTrayIconOutline className='n-size-token-7' />
<TextLink ref={downloadLinkRef} className='!hidden'>
<TextLink ref={downloadLinkRef} className='hidden!'>
""
</TextLink>
</IconButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const ExpandedChatButtonContainer: React.FC<IconProps> = ({ closeChatBot, delete
menuAnchor={chatAnchor}
isRoot={false}
/>
<div className='!h-[48px] mx-2 flex items-center'>
<div className='h-[48px]! mx-2 flex items-center'>
<div ref={chatAnchor}>
<IconButtonWithToolTip
onClick={() => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/ChatBot/MultiModeMetrics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ export default function MultiModeMetrics({
}}
isAutoResizingColumns={true}
isLoading={metricsLoading}
// rootProps={{ className: isWithAdditionalMetrics === false ? '!w-[465px]' : 'auto' }}
// rootProps={{ className: isWithAdditionalMetrics === false ? 'w-[465px]!' : 'auto' }}
components={{
Body: () => (
<DataGridComponents.Body
Expand Down
Loading
Loading