Query database
call_rag(query, message_history_id)
Sends a query to a RAG (Retrieval-Augmented Generation) system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query
|
str
|
The user's input query. |
required |
message_history_id
|
int
|
The ID of the message history session. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
The response from the RAG system. |
Source code in app/ui/pages/query_database.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
get_historic_message(message_history_id)
Retrieves the historic messages associated with a given message history ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message_history_id
|
int
|
The ID of the message history session. |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
A list of previous messages in the conversation. |
Source code in app/ui/pages/query_database.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
get_new_message_history_id()
Generates a new random message history ID.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
A randomly generated integer ID. |
Source code in app/ui/pages/query_database.py
111 112 113 114 115 116 117 118 119 |
|
return_historic()
Retrieves the chat history from Streamlit's session state.
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
The stored message history, or an empty list if no history is found. |
Source code in app/ui/pages/query_database.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
return_last_message()
Retrieves the last message stored in Streamlit's session state.
Returns:
Type | Description |
---|---|
list | dict
|
list | dict: The last message, or an empty list if no message is stored. |
Source code in app/ui/pages/query_database.py
155 156 157 158 159 160 161 162 163 |
|
update_historic(q_and_a)
Updates the chat history stored in Streamlit's session state.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
q_and_a
|
list[dict]
|
A list of messages to be added to the session history. |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Source code in app/ui/pages/query_database.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
|
update_last_message(msg)
Updates the last message stored in Streamlit's session state.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg
|
dict
|
The message to be stored. |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Source code in app/ui/pages/query_database.py
141 142 143 144 145 146 147 148 149 150 151 152 |
|
verify_sql_injection(query)
Checks if a given SQL query is vulnerable to SQL injection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query
|
str
|
The SQL query to be checked. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The security status of the query ("Secure" or "Insecure"). |
Source code in app/ui/pages/query_database.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
write_user_and_assistant_messages(q_and_a)
Displays chat messages for both the user and assistant in a Streamlit app.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
q_and_a
|
list[dict]
|
A list of messages with 'role' and 'content' keys. |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Source code in app/ui/pages/query_database.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
|