Skip to content

Commit 12a13d8

Browse files
committed
Merge branch 'feature/agent-chat-history' into 'develop'
Added chat history, updated new doc, fixed in-session chat memory, persistent chat session even when user leaves page See merge request genaiic-reusable-assets/engagement-artifacts/genaiic-idp-accelerator!412
2 parents 87fc504 + 69c5cdb commit 12a13d8

File tree

15 files changed

+1886
-529
lines changed

15 files changed

+1886
-529
lines changed

docs/agent-companion-chat.md

Lines changed: 426 additions & 384 deletions
Large diffs are not rendered by default.

lib/idp_common_pkg/pyproject.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,16 @@ appsync = ["requests==2.32.4"]
9595

9696
# Agents module dependencies
9797
agents = [
98-
"strands-agents>=1.0.0; python_version>='3.10'",
99-
"strands-agents-tools>=0.2.2; python_version>='3.10'",
98+
"strands-agents==1.14.0; python_version>='3.10'",
99+
"strands-agents-tools==0.2.13; python_version>='3.10'",
100100
"bedrock-agentcore>=0.1.1; python_version>='3.10'", # Specifically for the code interpreter tool
101101
]
102102

103103
# Code intelligence module dependencies
104104
code_intel = [
105105
"requests==2.32.4",
106-
"strands-agents>=1.0.0",
107-
"strands-agents-tools>=0.2.2",
106+
"strands-agents==1.14.0",
107+
"strands-agents-tools==0.2.13",
108108
"bedrock-agentcore>=0.1.1",
109109
"PyYAML>=6.0.0",
110110
"pathspec>=0.11.0",
@@ -153,14 +153,14 @@ all = [
153153
"pyarrow==20.0.0",
154154
"openpyxl==3.1.5",
155155
"python-docx==1.2.0",
156-
"strands-agents>=1.0.0; python_version>='3.10'",
157-
"strands-agents-tools>=0.2.2; python_version>='3.10'",
156+
"strands-agents==1.14.0; python_version>='3.10'",
157+
"strands-agents-tools==0.2.13; python_version>='3.10'",
158158
"bedrock-agentcore>=0.1.1; python_version>='3.10'",
159159
# "s3fs==2023.12.2" - - disabled till we fix package dependencies
160160
]
161161
agentic-extraction = [
162162
"jsonpatch==1.33",
163-
"strands-agents>=1.7.1 ; python_full_version >= '3.10'",
163+
"strands-agents==1.14.0 ; python_full_version >= '3.10'",
164164
"pandas>=2.2.3",
165165
"pymupdf==1.25.5", # Pinned to 1.25.5 - has pre-built ARM64 wheels, 1.26.x requires compilation
166166
"email-validator>=2.3.0",

lib/idp_common_pkg/setup.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"core": [],
1717
# Analytics agent dependencies
1818
"analytics": [
19-
"strands-agents>=1.0.0",
19+
"strands-agents==1.14.0", # Pin to exact working version
2020
"pandas>=2.0.0",
2121
],
2222
# Code intelligence module dependencies
@@ -87,8 +87,8 @@
8787
],
8888
# Agents module dependencies
8989
"agents": [
90-
"strands-agents>=1.0.0",
91-
"strands-agents-tools>=0.2.2",
90+
"strands-agents==1.14.0", # Pin to exact working version
91+
"strands-agents-tools==0.2.13", # Pin to exact working version
9292
"bedrock-agentcore>=0.1.1", # Specifically for the code interpreter tool
9393
"regex>=2024.0.0,<2026.0.0", # Pin regex version to avoid conflicts
9494
],
@@ -104,8 +104,8 @@
104104
"pyarrow==20.0.0",
105105
"openpyxl==3.1.5",
106106
"python-docx==1.2.0",
107-
"strands-agents>=1.0.0",
108-
"strands-agents-tools>=0.2.2",
107+
"strands-agents==1.14.0", # Pin to exact working version
108+
"strands-agents-tools==0.2.13", # Pin to exact working version
109109
"bedrock-agentcore>=0.1.1",
110110
"regex>=2024.0.0,<2026.0.0",
111111
],

src/api/schema.graphql

Lines changed: 103 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
interface DynamoDbBase {
2-
PK: ID!
3-
SK: ID!
4-
ExpiresAfter: AWSTimestamp
2+
PK: ID!
3+
SK: ID!
4+
ExpiresAfter: AWSTimestamp
55
}
66

77
type Document implements DynamoDbBase @aws_cognito_user_pools @aws_iam {
@@ -30,7 +30,7 @@ type Document implements DynamoDbBase @aws_cognito_user_pools @aws_iam {
3030

3131
type Section @aws_cognito_user_pools @aws_iam {
3232
Id: String
33-
PageIds: [ Int ]
33+
PageIds: [Int]
3434
Class: String
3535
OutputJSONUri: String
3636
ConfidenceThresholdAlerts: [ConfidenceThresholdAlert]
@@ -51,18 +51,18 @@ type Page @aws_cognito_user_pools @aws_iam {
5151
}
5252

5353
type DocumentList @aws_cognito_user_pools @aws_iam {
54-
Documents: [DocumentListItem]
55-
nextToken: String
54+
Documents: [DocumentListItem]
55+
nextToken: String
5656
}
5757

5858
type DocumentListItem implements DynamoDbBase @aws_cognito_user_pools @aws_iam {
59-
PK: ID!
60-
SK: ID!
61-
ObjectKey: ID
62-
InitialEventTime: AWSDateTime
63-
ExpiresAfter: AWSTimestamp
64-
HITLStatus: String
65-
HITLReviewURL: String
59+
PK: ID!
60+
SK: ID!
61+
ObjectKey: ID
62+
InitialEventTime: AWSDateTime
63+
ExpiresAfter: AWSTimestamp
64+
HITLStatus: String
65+
HITLReviewURL: String
6666
}
6767

6868
type ValidationError @aws_cognito_user_pools @aws_iam {
@@ -104,7 +104,6 @@ type DiscoveryJobListItem @aws_cognito_user_pools @aws_iam {
104104
createdAt: String
105105
updatedAt: String
106106
errorMessage: String
107-
108107
}
109108

110109
input CreateDocumentInput {
@@ -155,7 +154,7 @@ input UpdateDocumentInput {
155154

156155
input SectionInput {
157156
Id: String
158-
PageIds: [ Int ]
157+
PageIds: [Int]
159158
Class: String
160159
OutputJSONUri: String
161160
ConfidenceThresholdAlerts: [ConfidenceThresholdAlertInput]
@@ -225,7 +224,7 @@ type StepFunctionExecutionResponse @aws_cognito_user_pools @aws_iam {
225224
steps: [StepFunctionExecutionStep]
226225
}
227226

228-
type DiscoveryJob @aws_cognito_user_pools @aws_iam {
227+
type DiscoveryJob @aws_cognito_user_pools @aws_iam {
229228
jobId: ID!
230229
status: String!
231230
errorMessage: String
@@ -240,14 +239,14 @@ type Agent @aws_cognito_user_pools @aws_iam {
240239

241240
type AgentJob @aws_cognito_user_pools @aws_iam {
242241
jobId: ID!
243-
status: String! # "PENDING", "PROCESSING", "COMPLETED", "FAILED"
242+
status: String! # "PENDING", "PROCESSING", "COMPLETED", "FAILED"
244243
query: String!
245-
agentIds: String # JSON string containing list of agent IDs used
244+
agentIds: String # JSON string containing list of agent IDs used
246245
createdAt: AWSDateTime!
247246
completedAt: AWSDateTime
248247
result: String
249248
error: String
250-
agent_messages: String # JSON string containing agent conversation messages
249+
agent_messages: String # JSON string containing agent conversation messages
251250
}
252251

253252
type AgentJobConnection @aws_cognito_user_pools @aws_iam {
@@ -263,6 +262,20 @@ type AgentChatMessage @aws_cognito_user_pools @aws_iam {
263262
sessionId: String
264263
}
265264

265+
type ChatSession @aws_cognito_user_pools @aws_iam {
266+
sessionId: ID!
267+
title: String!
268+
createdAt: AWSDateTime!
269+
updatedAt: AWSDateTime!
270+
messageCount: Int!
271+
lastMessage: String
272+
}
273+
274+
type ChatSessionConnection @aws_cognito_user_pools @aws_iam {
275+
items: [ChatSession]
276+
nextToken: String
277+
}
278+
266279
type MessageContent {
267280
text: String
268281
}
@@ -271,42 +284,95 @@ type Mutation {
271284
createDocument(input: CreateDocumentInput!): CreateDocumentOutput @aws_iam
272285
updateDocument(input: UpdateDocumentInput!): Document @aws_iam
273286
deleteDocument(objectKeys: [String!]!): Boolean! @aws_cognito_user_pools
274-
updateConfiguration(customConfig: AWSJSON!): UpdateConfigurationResponse @aws_cognito_user_pools
275-
uploadDocument(fileName: String!, contentType: String, prefix: String, bucket: String): PresignedUrlResponse! @aws_cognito_user_pools
276-
uploadDiscoveryDocument(fileName: String!, contentType: String, prefix: String, bucket: String, groundTruthFileName: String): DisPresignedUrlResponse! @aws_cognito_user_pools
277-
copyToBaseline(objectKey: String!): CopyToBaselineResponse! @aws_cognito_user_pools
287+
updateConfiguration(customConfig: AWSJSON!): UpdateConfigurationResponse
288+
@aws_cognito_user_pools
289+
uploadDocument(
290+
fileName: String!
291+
contentType: String
292+
prefix: String
293+
bucket: String
294+
): PresignedUrlResponse! @aws_cognito_user_pools
295+
uploadDiscoveryDocument(
296+
fileName: String!
297+
contentType: String
298+
prefix: String
299+
bucket: String
300+
groundTruthFileName: String
301+
): DisPresignedUrlResponse! @aws_cognito_user_pools
302+
copyToBaseline(objectKey: String!): CopyToBaselineResponse!
303+
@aws_cognito_user_pools
278304
reprocessDocument(objectKeys: [String!]!): Boolean! @aws_cognito_user_pools
279-
processChanges(objectKey: String!, modifiedSections: [ModifiedSectionInput!]!): ProcessChangesResponse! @aws_cognito_user_pools
280-
updateAgentJobStatus(jobId: ID!, status: String!, userId: String!, result: String): Boolean @aws_iam
281-
updateDiscoveryJobStatus(jobId: ID!, status: String!, errorMessage: String): DiscoveryJob @aws_iam
305+
processChanges(
306+
objectKey: String!
307+
modifiedSections: [ModifiedSectionInput!]!
308+
): ProcessChangesResponse! @aws_cognito_user_pools
309+
updateAgentJobStatus(
310+
jobId: ID!
311+
status: String!
312+
userId: String!
313+
result: String
314+
): Boolean @aws_iam
315+
updateDiscoveryJobStatus(
316+
jobId: ID!
317+
status: String!
318+
errorMessage: String
319+
): DiscoveryJob @aws_iam
282320
deleteAgentJob(jobId: ID!): Boolean @aws_cognito_user_pools
283-
sendAgentChatMessage(prompt: String!, sessionId: String, method: String, enableCodeIntelligence: Boolean): AgentChatMessage @aws_cognito_user_pools @aws_iam
284-
updateAgentChatMessage(sessionId: ID!, content: String!): AgentChatMessage @aws_cognito_user_pools @aws_iam
321+
sendAgentChatMessage(
322+
prompt: String!
323+
sessionId: String
324+
method: String
325+
enableCodeIntelligence: Boolean
326+
): AgentChatMessage @aws_cognito_user_pools @aws_iam
327+
updateAgentChatMessage(sessionId: ID!, content: String!): AgentChatMessage
328+
@aws_cognito_user_pools
329+
@aws_iam
330+
deleteChatSession(sessionId: ID!): Boolean @aws_cognito_user_pools @aws_iam
331+
updateChatSessionTitle(sessionId: ID!, title: String!): ChatSession
332+
@aws_cognito_user_pools
333+
@aws_iam
285334
}
286335

287336
type Query @aws_cognito_user_pools @aws_iam {
288337
getDocument(ObjectKey: ID!): Document
289-
listDocuments(startDateTime: AWSDateTime, endDateTime: AWSDateTime): DocumentList
338+
listDocuments(
339+
startDateTime: AWSDateTime
340+
endDateTime: AWSDateTime
341+
): DocumentList
290342
listDocumentsDateHour(date: AWSDate, hour: Int): DocumentList
291-
listDocumentsDateShard(date: AWSDate, shard: Int): DocumentList
343+
listDocumentsDateShard(date: AWSDate, shard: Int): DocumentList
292344
getFileContents(s3Uri: String!): FileContentsResponse
293345
getConfiguration: ConfigurationResponse
294346
listDiscoveryJobs: DiscoveryJobList
295347
queryKnowledgeBase(input: String!, sessionId: String): String
296-
chatWithDocument(s3Uri: String!, prompt: String!, history: AWSJSON!, modelId: String!): String
348+
chatWithDocument(
349+
s3Uri: String!
350+
prompt: String!
351+
history: AWSJSON!
352+
modelId: String!
353+
): String
297354
getStepFunctionExecution(executionArn: String!): StepFunctionExecutionResponse
298355
listAvailableAgents: [Agent] @aws_cognito_user_pools @aws_iam
299-
submitAgentQuery(query: String!, agentIds: [String!]!): AgentJob @aws_cognito_user_pools
356+
submitAgentQuery(query: String!, agentIds: [String!]!): AgentJob
357+
@aws_cognito_user_pools
300358
getAgentJobStatus(jobId: ID!): AgentJob @aws_cognito_user_pools
301-
listAgentJobs(limit: Int, nextToken: String): AgentJobConnection @aws_cognito_user_pools
302-
getAgentChatMessages(sessionId: ID!): [AgentChatMessage] @aws_cognito_user_pools @aws_iam
359+
listAgentJobs(limit: Int, nextToken: String): AgentJobConnection
360+
@aws_cognito_user_pools
361+
getAgentChatMessages(sessionId: ID!): [AgentChatMessage]
362+
@aws_cognito_user_pools
363+
@aws_iam
364+
listChatSessions(limit: Int, nextToken: String): ChatSessionConnection
365+
@aws_cognito_user_pools
366+
@aws_iam
367+
getChatMessages(sessionId: ID!): [AgentChatMessage]
368+
@aws_cognito_user_pools
369+
@aws_iam
303370
}
304371

305372
type Subscription @aws_cognito_user_pools @aws_iam {
306373
onCreateDocument: CreateDocumentOutput
307-
@aws_subscribe(mutations: ["createDocument"])
308-
onUpdateDocument: Document
309-
@aws_subscribe(mutations: ["updateDocument"])
374+
@aws_subscribe(mutations: ["createDocument"])
375+
onUpdateDocument: Document @aws_subscribe(mutations: ["updateDocument"])
310376
onAgentJobComplete(jobId: ID!): Boolean
311377
@aws_subscribe(mutations: ["updateAgentJobStatus"])
312378
onDiscoveryJobStatusChange(jobId: ID!): DiscoveryJob

0 commit comments

Comments
 (0)