Skip to content

Commit

Permalink
Merge pull request #63 from GPS-Solutions/main
Browse files Browse the repository at this point in the history
Merge main into dev
  • Loading branch information
smcazares authored Oct 28, 2024
2 parents 16e2983 + 95f222f commit 4064268
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 187 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ New features:
- Switched to using llama_index.core.node_parser.SentenceSplitter for chunking by default
- Updated default query generation model to Gemini Flash 1.5 - was set to Palm2
- Added Microsoft login in React frontend
- Add timestamps to logging

### Fixes
- Fixed download of PDFs from scraped sites
- Fixed deletion of query engines in React frontend; made hard delete the default


## v0.3.2
Expand Down
5 changes: 1 addition & 4 deletions components/common/src/common/models/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,7 @@ def soft_delete_by_id(cls, object_id, by_user=None):
obj = cls.collection.filter("id", "in",
[object_id]).filter("deleted_at_timestamp",
"==", None).get()
if obj is None:
raise ResourceNotFoundException(
f"{cls.collection_name} with id {object_id} is not found")
else:
if obj is not None:
obj.deleted_at_timestamp = datetime.datetime.utcnow()
obj.deleted_by = by_user
obj.update()
Expand Down
2 changes: 1 addition & 1 deletion components/common/src/common/utils/logging_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, name):
module_name = f"{folder}/{filename}"
self.logger = logging.getLogger(module_name)
handler = logging.StreamHandler(sys.stdout)
log_format = "%(levelname)s: [%(name)s:%(lineno)d - " \
log_format = "%(asctime)s:%(levelname)s: [%(name)s:%(lineno)d - " \
"%(funcName)s()] %(message)s"
handler.setFormatter(logging.Formatter(log_format))
self.logger.addHandler(handler)
Expand Down
11 changes: 11 additions & 0 deletions components/frontend_react/webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions components/frontend_react/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"@iconify-json/logos": "^1.1.37",
"@iconify-json/material-symbols": "^1.1.72",
"@iconify-json/mdi": "^1.1.54",
"@iconify-json/svg-spinners": "^1.2.1",
"@testing-library/jest-dom": "^6.1.3",
"@testing-library/react": "^14.0.0",
"@types/bluebird": "^3.5.39",
Expand Down
4 changes: 0 additions & 4 deletions components/frontend_react/webapp/src/routes/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ export const AuthAppRouter: React.FunctionComponent<AuthAppRouterProps> = ({
path="/queryengines/admin"
element={<QueryEngineAdmin token={token!} />}
/>
<Route
path="/queryengines/detail"
element={<QueryEngineDetail token={token!} />}
/>
<Route path="/about" element={<About />} />
<Route path="/aichat" element={<AIChatRoute />} />
<Route path="/aiquery" element={<AIQueryRoute />} />
Expand Down
156 changes: 0 additions & 156 deletions components/frontend_react/webapp/src/routes/QueryEngineDetail.tsx

This file was deleted.

46 changes: 35 additions & 11 deletions components/frontend_react/webapp/src/routes/QueryEngineEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ interface IQueryEngineProps {
}

const QueryEngineEdit: React.FC<IQueryEngineProps> = ({ token }) => {
const [isModalOpen, setIsModalOpen] = useState(false);
const [activeJob, setActiveJob] = useState(false)
const [formError, setFormError] = useState(false)
const [formSubmitted, setFormSubmitted] = useState(false)
const [deleting, setDeleting] = useState(false)
Expand All @@ -45,10 +47,20 @@ const QueryEngineEdit: React.FC<IQueryEngineProps> = ({ token }) => {

const [queryEngines, setQueryEngines] = useState<QueryEngine[]>([])
const [queryEngine, setQueryEngine] = useState<QueryEngine | null>(null)

const [createEngineIsMultimodal, setCreateEngineIsMultimodal] = useState(false)
const [createEngineEmbeddingOptions, setCreateEngineEmbeddingOptions] = useState<{ option: string; value: string; }[]>([])

const openDeleteModal = () => {
setIsModalOpen(true)
const modalToggle = document.getElementById('delete-queryEngine-modal')
modalToggle.checked = true
}
const closeDeleteModal = () => {
setIsModalOpen(false)
const modalToggle = document.getElementById('delete-queryEngine-modal')
modalToggle.checked = false
}

const { isLoading, data: engineList } = useQuery(
["QueryEngines"],
fetchAllEngines(token),
Expand Down Expand Up @@ -123,8 +135,9 @@ const QueryEngineEdit: React.FC<IQueryEngineProps> = ({ token }) => {

const deleteQueryEngineDetails = async () => {
if (!queryEngine) throw new Error("No id of queryEngine to delete")
setDeleting(true)

setDeleting(true)
setActiveJob(true)
deleteQEngine.mutate(
queryEngine,
{
Expand All @@ -136,13 +149,24 @@ const QueryEngineEdit: React.FC<IQueryEngineProps> = ({ token }) => {
durationMs: 4000,
})
}
setDeleting(false)
setActiveJob(false)
closeDeleteModal()
navigate("/queryengines")
},
onError: () => {
// TODO
setAlert({
message: "Error occurred deleting",
type: ALERT_TYPE.ERROR,
durationMs: 4000,
})
setDeleting(false)
setActiveJob(false)
closeDeleteModal()
navigate("/queryengines/admin")
}
}
)
navigate("/queryengines/admin")
}

useEffect(() => {
Expand Down Expand Up @@ -204,12 +228,9 @@ const QueryEngineEdit: React.FC<IQueryEngineProps> = ({ token }) => {
View Details
</button>
</Link>
<label
htmlFor="delete-queryEngine-modal"
className="absolute right-0 top-0 z-10"
>
<button className="absolute right-0 top-0 z-10" onClick={openDeleteModal}>
<TrashIcon className="text-dim hover:text-normal w-8 cursor-pointer text-error transition" />
</label>
</button>
</>
)}
<div className="flex flex-col">
Expand Down Expand Up @@ -247,9 +268,12 @@ const QueryEngineEdit: React.FC<IQueryEngineProps> = ({ token }) => {
</h3>
<p className="py-4">This action cannot be undone</p>
<div className="modal-action">
<label htmlFor="delete-queryEngine-modal" className="btn btn-outline">
{activeJob && (
<i className="i-svg-spinners-180-ring text-info group-hover:text-base-content/100 transition h-6 w-6 shrink-0"></i>
)}
<button className="btn btn-outline" onClick={closeDeleteModal}>
Cancel
</label>
</button>
<button
className="btn btn-error"
disabled={deleting}
Expand Down
2 changes: 2 additions & 0 deletions components/llm_service/src/routes/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def get_chat_llm_list(user_data: dict = Depends(validate_token),
"data": user_enabled_llms
}
except Exception as e:
Logger.error(e)
Logger.error(traceback.print_exc())
raise InternalServerError(str(e)) from e


Expand Down
16 changes: 9 additions & 7 deletions components/llm_service/src/routes/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ def update_query(query_id: str, input_query: UserQueryUpdateModel):
"/{query_id}",
name="Delete user query"
)
def delete_query(query_id: str, hard_delete=False):
"""Delete a user query. By default we do a soft delete.
def delete_query(query_id: str, hard_delete: bool = True):
"""Delete a user query. By default we do a hard delete.
Args:
query_id (str): Query ID
Expand All @@ -335,7 +335,7 @@ def delete_query(query_id: str, hard_delete=False):
NotFoundErrorResponseModel if the user query not found,
InternalServerErrorResponseModel if the update raises an exception
"""
Logger.info(f"Delete a user query by id={query_id}")
Logger.info(f"Delete a user query by id={query_id} hard_delete={hard_delete}")
existing_query = UserQuery.find_by_id(query_id)
if existing_query is None:
raise ResourceNotFoundException(f"Query {query_id} not found")
Expand All @@ -354,6 +354,7 @@ def delete_query(query_id: str, hard_delete=False):
raise ResourceNotFound(str(re)) from re
except Exception as e:
Logger.error(e)
Logger.error(traceback.print_exc())
raise InternalServerError(str(e)) from e

@router.put(
Expand Down Expand Up @@ -399,9 +400,9 @@ def update_query_engine(query_engine_id: str,
@router.delete(
"/engine/{query_engine_id}",
name="Delete a query engine")
def delete_query_engine(query_engine_id: str, hard_delete=False):
def delete_query_engine(query_engine_id: str, hard_delete: bool = True):
"""
Delete a query engine. By default we do a soft delete.
Delete a query engine. By default we do a hard delete.
Args:
query_engine_id (LLMQueryEngineModel)
Expand All @@ -419,9 +420,10 @@ def delete_query_engine(query_engine_id: str, hard_delete=False):
raise ResourceNotFoundException(f"Engine {query_engine_id} not found")

try:
Logger.info(f"Deleting q_engine=[{q_engine.name}]")
Logger.info(
f"Deleting q_engine=[{q_engine.name}] hard_delete=[{hard_delete}]")

delete_engine(q_engine, hard_delete)
delete_engine(q_engine, hard_delete=hard_delete)

Logger.info(f"Successfully deleted q_engine=[{q_engine.name}]")
except Exception as e:
Expand Down
Loading

0 comments on commit 4064268

Please sign in to comment.