Skip to content

Commit c594c4d

Browse files
committed
Latest styling updates
1 parent 564195c commit c594c4d

File tree

6 files changed

+288
-208
lines changed

6 files changed

+288
-208
lines changed

app.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ async def generate_section_content():
885885
template = await generate_section_content(request_json)
886886
return jsonify(template), 200
887887
except Exception as e:
888-
logging.exception("Exception in /history/clear_messages")
888+
logging.exception("Exception in /section/generate")
889889
return jsonify({"error": str(e)}), 500
890890

891891
@bp.route("/document/<filepath>")
@@ -894,7 +894,7 @@ async def get_document(filepath):
894894
document = retrieve_document(filepath)
895895
return jsonify(document), 200
896896
except Exception as e:
897-
logging.exception("Exception in /history/clear_messages")
897+
logging.exception("Exception in /document/<filepath>")
898898
return jsonify({"error": str(e)}), 500
899899

900900
async def generate_title(conversation_messages):
@@ -1002,8 +1002,9 @@ async def generate_section_content(request_json):
10021002

10031003
template = json.loads(response.choices[0].message.content)
10041004
return template
1005-
except Exception as e:
1006-
raise e
1005+
except Exception as ex:
1006+
logging.exception(ex)
1007+
return json.loads({"error": str(ex)})
10071008

10081009
def retrieve_document(filepath):
10091010
try:

frontend/src/api/api.ts

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
import { chatHistorySampleData } from '../constants/chatHistory'
22

3-
import { ChatMessage, Conversation, ConversationRequest, SectionGenerateRequest, CosmosDBHealth, CosmosDBStatus, UserInfo, ChatType } from './models'
3+
import {
4+
ChatMessage,
5+
Conversation,
6+
ConversationRequest,
7+
SectionGenerateRequest,
8+
CosmosDBHealth,
9+
CosmosDBStatus,
10+
UserInfo,
11+
ChatType
12+
} from './models'
413

5-
export async function conversationApi(options: ConversationRequest, abortSignal: AbortSignal, chatType: ChatType = ChatType.Browse): Promise<Response> {
14+
export async function conversationApi(
15+
options: ConversationRequest,
16+
abortSignal: AbortSignal,
17+
chatType: ChatType = ChatType.Browse
18+
): Promise<Response> {
619
const response = await fetch('/conversation', {
720
method: 'POST',
821
headers: {
@@ -116,7 +129,8 @@ export const historyRead = async (convId: string): Promise<ChatMessage[]> => {
116129
export const historyGenerate = async (
117130
options: ConversationRequest,
118131
abortSignal: AbortSignal,
119-
convId?: string, chatType: ChatType = ChatType.Browse
132+
convId?: string,
133+
chatType: ChatType = ChatType.Browse
120134
): Promise<Response> => {
121135
let body
122136
if (convId) {
@@ -357,22 +371,20 @@ export const historyMessageFeedback = async (messageId: string, feedback: string
357371
return response
358372
}
359373

360-
export const sectionGenerate = async (
361-
options: SectionGenerateRequest,
362-
): Promise<Response> => {
374+
export const sectionGenerate = async (options: SectionGenerateRequest): Promise<Response> => {
363375
// set timeout to 10 seconds
364376
const abortController = new AbortController()
365377
const abortSignal = abortController.signal
366378

367379
const timeout = setTimeout(() => {
368380
abortController.abort()
369381
}, 10000)
370-
382+
371383
let body = JSON.stringify({
372384
sectionTitle: options.sectionTitle,
373-
sectionDescription: options.sectionDescription,
385+
sectionDescription: options.sectionDescription
374386
})
375-
387+
376388
const response = await fetch('/section/generate', {
377389
method: 'POST',
378390
headers: {
@@ -388,9 +400,11 @@ export const sectionGenerate = async (
388400
.catch(_err => {
389401
clearTimeout(timeout)
390402
console.error('There was an issue fetching your data.')
391-
return new Response()
403+
return new Response(
404+
JSON.stringify({ section_content: 'There was an issue fetching your data. Please try again.' })
405+
)
392406
})
393-
407+
394408
return response
395409
}
396410

@@ -399,8 +413,12 @@ export const documentRead = async (docId: string): Promise<Response> => {
399413
method: 'GET',
400414
headers: { 'Content-Type': 'application/json' }
401415
})
402-
.then(res => { return res })
403-
.catch(_err => { throw new Error('There was an issue fetching your data.') })
416+
.then(res => {
417+
return res
418+
})
419+
.catch(_err => {
420+
throw new Error('There was an issue fetching your data.')
421+
})
404422

405423
return response
406424
}

0 commit comments

Comments
 (0)