Skip to content

Commit 564195c

Browse files
Merge pull request #42 from microsoft/adesousa_microsoft/support-citations
data scripts update
2 parents b00543a + 46fde79 commit 564195c

17 files changed

+324
-258
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ __pycache__/
77
.ipynb_checkpoints/
88

99
data
10-
static
10+
static
11+
12+
scripts/config.json
13+
venv

app.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ def init_ai_search_client():
163163
endpoint = app_settings.datasource.endpoint
164164
key_credential = app_settings.datasource.key
165165
index_name = app_settings.datasource.index
166-
167166
client = SearchClient(endpoint=endpoint, index_name=index_name, credential=AzureKeyCredential(key_credential))
168167
return client
169168
except Exception as e:
@@ -889,10 +888,10 @@ async def generate_section_content():
889888
logging.exception("Exception in /history/clear_messages")
890889
return jsonify({"error": str(e)}), 500
891890

892-
@bp.route("/document/<documentId>")
893-
async def get_document(documentId):
891+
@bp.route("/document/<filepath>")
892+
async def get_document(filepath):
894893
try:
895-
document = retrieve_document(documentId)
894+
document = retrieve_document(filepath)
896895
return jsonify(document), 200
897896
except Exception as e:
898897
logging.exception("Exception in /history/clear_messages")
@@ -1006,10 +1005,15 @@ async def generate_section_content(request_json):
10061005
except Exception as e:
10071006
raise e
10081007

1009-
def retrieve_document(id):
1008+
def retrieve_document(filepath):
10101009
try:
10111010
search_client = init_ai_search_client()
1012-
document = search_client.get_document(id)
1011+
search_query = f"filepath eq '{filepath}'"
1012+
# Execute the search query
1013+
results = search_client.search(search_query)
1014+
1015+
# Get the full_content of the first result
1016+
document = next(results)
10131017
return document
10141018
except Exception as e:
10151019
logging.exception("Exception in retrieve_document")

frontend/src/pages/chat/Chat.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ const Chat = ({ type = ChatType.Browse }: Props) => {
783783
}, [showLoadingMessage, processMessages])
784784

785785
const onShowCitation = (citation: Citation) => {
786-
const path = `/#/document/${citation.id}`
786+
const path = `/#/document/${citation.filepath}`;
787787

788788
// Instead of navigating within the app, use window.open to open in a new tab
789789
const url = window.location.origin + path

frontend/src/pages/document/Document.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useParams } from 'react-router-dom';
55
// Define the interface for the document data
66
interface DocumentData {
77
content: string;
8+
full_content: string;
89
}
910

1011
const Document = (): JSX.Element => {
@@ -19,7 +20,6 @@ const Document = (): JSX.Element => {
1920
try {
2021
const response = await documentRead(id);
2122
const data = await response.json();
22-
2323
setDocument(data);
2424
} catch (error) {
2525
console.error(error);
@@ -39,7 +39,7 @@ const Document = (): JSX.Element => {
3939
{isLoading ? ( // Step 4
4040
<p>Loading...</p>
4141
) : document ? (
42-
<p>{document.content}</p>
42+
<p>{document.full_content}</p>
4343
) : (
4444
<h1>Document not found. Please try again.</h1>
4545
)}

requirements-dev.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-r requirements.txt
2-
azure-ai-formrecognizer==3.2.1
2+
azure-ai-documentintelligence==1.0.0b2
33
Markdown==3.4.4
44
requests==2.32.3
55
tqdm==4.66.1
@@ -9,6 +9,8 @@ bs4==0.0.1
99
urllib3==2.2.2
1010
pytest==7.4.0
1111
pytest-asyncio==0.23.2
12+
PyMuPDF==1.24.5
1213
azure-storage-blob
1314
chardet
14-
azure-keyvault-secrets
15+
azure-keyvault-secrets
16+
coverage

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ quart==0.19.4
99
uvicorn==0.24.0
1010
aiohttp==3.9.2
1111
gunicorn==20.1.0
12-
pydantic-settings==2.2.1
13-
azure-search-documents
12+
pydantic-settings==2.2.1

scripts/auth_init.ps1

100755100644
File mode changed.

scripts/auth_init.sh

100755100644
File mode changed.

scripts/auth_update.py

100755100644
File mode changed.

scripts/auth_update.sh

100755100644
File mode changed.

0 commit comments

Comments
 (0)