Skip to content

Commit bf44cc7

Browse files
committed
fix: Reduce token usage in e2e_tests to avoid Bedrock token throttling
1 parent c440dc0 commit bf44cc7

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

e2e_tests/python/chat_session.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ async def start(self) -> None:
6868
messages = []
6969

7070
for i, user_input in enumerate(self.user_utterances):
71+
# To reduce token use, clear out past messages for each utterance
72+
messages = []
73+
7174
print(f"\nYou: {user_input}")
7275

7376
messages.append({"role": "user", "content": [{"text": user_input}]})

e2e_tests/python/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ async def main() -> None:
8888
"Hello!",
8989
"What is the current time in Seattle?",
9090
"Are there any weather alerts right now?",
91-
"What documentation sources can you use to answer questions?",
91+
"List your available documentation sources.",
9292
"Tell me a cat fact.",
9393
"Who is Tom Cruise?",
9494
]

e2e_tests/typescript/src/chat_session.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ export class ChatSession {
8282
const messages: Message[] = [];
8383

8484
for (const [i, userInput] of this.userUtterances.entries()) {
85+
// To reduce token use, clear out past messages for each utterance
86+
messages.length = 0;
87+
8588
console.log(`\You: ${userInput}`);
8689

8790
messages.push({ role: "user", content: [{ text: userInput }] });

e2e_tests/typescript/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async function main(): Promise<void> {
3333
"Hello!",
3434
"What is the current time in Seattle?",
3535
"Are there any weather alerts right now?",
36-
"What documentation sources can you use to answer questions?",
36+
"List your available documentation sources.",
3737
"Tell me a cat fact.",
3838
"Who is Tom Cruise?",
3939
];

0 commit comments

Comments
 (0)