Skip to content

Commit 1170010

Browse files
committed
cod
1 parent add1aee commit 1170010

File tree

3 files changed

+12
-65
lines changed

3 files changed

+12
-65
lines changed

.github/workflows/azure-dev.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# Run when commits are pushed to main
1+
# Run when commits are pushed to howie/load-chat-history
22
on:
33
workflow_dispatch:
44
push:
55
# Run when commits are pushed to mainline branch (main or master)
66
# Set this to the mainline branch you are using
77
branches:
8-
- main
8+
- howie/load-chat-history
99

1010
# Set up permissions for deploying with secretless Azure federated credentials
1111
# https://learn.microsoft.com/en-us/azure/developer/github/connect-from-azure?tabs=azure-portal%2Clinux#set-up-azure-login-with-openid-connect-authentication
@@ -50,6 +50,8 @@ jobs:
5050
AZURE_AI_EMBED_MODEL_NAME: ${{ vars.AZURE_AI_EMBED_MODEL_NAME }}
5151
AZURE_AI_EMBED_MODEL_FORMAT: ${{ vars.AZURE_AI_EMBED_MODEL_FORMAT }}
5252
AZURE_AI_EMBED_MODEL_VERSION: ${{ vars.AZURE_AI_EMBED_MODEL_VERSION }}
53+
AZURE_AI_EMBED_DIMENSIONS: ${{ vars.AZURE_AI_EMBED_DIMENSIONS }}
54+
AZURE_AI_SEARCH_INDEX_NAME: ${{ vars.AZURE_AI_SEARCH_INDEX_NAME }}
5355
AZURE_EXISTING_AIPROJECT_CONNECTION_STRING: ${{ vars.AZURE_EXISTING_AIPROJECT_CONNECTION_STRING }}
5456
steps:
5557
- name: Checkout

.github/workflows/template-validation.yml

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/api/routes.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def get_agent(request: Request) -> Agent:
5252
def serialize_sse_event(data: Dict) -> str:
5353
return f"data: {json.dumps(data)}\n\n"
5454

55-
async def get_completed_message(ai_client : AIProjectClient, message: ThreadMessage) -> Dict:
55+
async def get_message_and_annotations(ai_client : AIProjectClient, message: ThreadMessage) -> Dict:
5656
annotations = []
5757
# Get file annotations for the file search.
5858
for annotation in (a.as_dict() for a in message.file_citation_annotations):
@@ -72,8 +72,7 @@ async def get_completed_message(ai_client : AIProjectClient, message: ThreadMess
7272

7373
return {
7474
'content': message.text_messages[0].text.value,
75-
'annotations': annotations,
76-
'type': "completed_message"
75+
'annotations': annotations
7776
}
7877
class MyEventHandler(AsyncAgentEventHandler[str]):
7978
def __init__(self, ai_client: AIProjectClient):
@@ -92,7 +91,8 @@ async def on_thread_message(self, message: ThreadMessage) -> Optional[str]:
9291

9392
logger.info("MyEventHandler: Received completed message")
9493

95-
stream_data = await get_completed_message(self.ai_client, message)
94+
stream_data = await get_message_and_annotations(self.ai_client, message)
95+
stream_data['type'] = "completed_message"
9696
return serialize_sse_event(stream_data)
9797
except Exception as e:
9898
logger.error(f"Error in event handler for thread message: {e}", exc_info=True)
@@ -185,10 +185,11 @@ async def history(
185185
# Create a new message from the user's input.
186186
try:
187187
content = []
188-
for message in await ai_client.agents.list_messages(
188+
response = await ai_client.agents.list_messages(
189189
thread_id=thread_id,
190-
):
191-
content.append(await get_completed_message(ai_client, message))
190+
)
191+
for message in response.data:
192+
content.append(await get_message_and_annotations(ai_client, message))
192193

193194
logger.info(f"List message, thread ID: {thread_id}")
194195
response = JSONResponse(content=content)

0 commit comments

Comments
 (0)