Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
jinyang628 committed May 18, 2024
1 parent 5af4a8b commit cc4bd29
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions app/llm/open_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ async def send_message(self, system_message: str, user_message: str, config: Pro
key_concepts_lst: list = []
for key_concept in json_response[SummaryFunctions.KEY_CONCEPTS]:
key_concepts_lst.append({
SummaryFunctions.KEY_CONCEPT_TITLE.value: key_concept[SummaryFunctions.KEY_CONCEPT_TITLE],
SummaryFunctions.KEY_CONCEPT_HEADER.value: key_concept[SummaryFunctions.KEY_CONCEPT_HEADER],
SummaryFunctions.KEY_CONCEPT_CONTENT.value: key_concept[SummaryFunctions.KEY_CONCEPT_CONTENT],
SummaryFunctions.KEY_CONCEPT_CODE_EXAMPLE.value: key_concept[SummaryFunctions.KEY_CONCEPT_CODE_EXAMPLE]
SummaryFunctions.KEY_CONCEPT_CODE_EXAMPLE.value: key_concept.get(SummaryFunctions.KEY_CONCEPT_CODE_EXAMPLE)
})


Expand Down
1 change: 0 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ async def generate_notes(input: InferenceInput) -> JSONResponse:
conversations=input.conversation
)
practice: dict[str, Any] = await generate_practice(summary=summary)

return JSONResponse(
status_code=200,
content={"summary": summary, "practice": practice, "token_sum": token_sum},
Expand Down
10 changes: 5 additions & 5 deletions app/prompts/summariser/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SummaryFunctions(StrEnum):

KEY_CONCEPTS = "key_concepts"
# List of tuples containing these 3 elements
KEY_CONCEPT_TITLE = "key_concept_header"
KEY_CONCEPT_HEADER = "key_concept_header"
KEY_CONCEPT_CONTENT = "key_concept_content"
KEY_CONCEPT_CODE_EXAMPLE = "key_concept_code_example"

Expand Down Expand Up @@ -40,20 +40,20 @@ def get_summary_functions() -> list[dict[str, Any]]:
"items": {
"type": "object",
"properties": {
SummaryFunctions.KEY_CONCEPT_TITLE: {
SummaryFunctions.KEY_CONCEPT_HEADER: {
"type": "string",
"description": "The title of the key concept."
},
SummaryFunctions.KEY_CONCEPT_CONTENT: {
"type": "string",
"description": "The explanation of the key concept in one or two sentences."
"description": "State the key concept in one or two sentences."
},
SummaryFunctions.KEY_CONCEPT_CODE_EXAMPLE: {
"type": "string",
"description": "A short code example illustrating the key concept."
"description": "A short code example illustrating the key concept if necessary."
}
},
"required": [SummaryFunctions.KEY_CONCEPT_TITLE, SummaryFunctions.KEY_CONCEPT_CONTENT, SummaryFunctions.KEY_CONCEPT_CODE_EXAMPLE]
"required": [SummaryFunctions.KEY_CONCEPT_HEADER, SummaryFunctions.KEY_CONCEPT_CONTENT]
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion app/prompts/summariser/open_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def generate_open_ai_summariser_system_message():
1. State the topic which the revision notes cover
2. State the goal of the revision notes and what users should learn after reading through the notes.
3. Provide an overview of the key ideas present in the revision notes.
4. List 2-4 key concepts present in the conversation. Each key concept should have a title, an explanation in one or two sentences, and a short code example illustrating every key concept.
4. List 2-4 key concepts present in the conversation. Each key concept should have a title, an explanation in one or two sentences. If useful, provide a short code example illustrating the corresponding key concept.
"""
return system_message

Expand Down
4 changes: 2 additions & 2 deletions app/scripts/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ async def generate_summary(
summary_tasks = [
summariser.summarise(conversation=conversation) for conversation in conversation_lst
]
summary = await asyncio.gather(*summary_tasks, return_exceptions=True)
results = await asyncio.gather(*summary_tasks, return_exceptions=True)

for i, result in enumerate(summary):
for i, result in enumerate(results):
if isinstance(result, Exception):
# TODO: Handle exceptions individually
log.error(
Expand Down

0 comments on commit cc4bd29

Please sign in to comment.