Closed MarkHmnv closed 3 weeks ago
Hello, @MarkHmnv! I'm here to assist you with any bugs, questions, or contributions you have.
To resolve the TableTransactionError
that occurs when using AzureChatStore
with ReActAgent
on the second call, you need to ensure that the transaction operations are correctly formed and that the entities being deleted or created do not conflict.
The set_messages
method in AzureChatStore
performs a transaction that deletes existing messages and inserts new ones. If the second call results in a TableTransactionError
, it could be due to conflicts or issues with the entities being processed.
Here is the relevant code snippet from the set_messages
method:
def set_messages(self, key: str, messages: List[ChatMessage]) -> None:
"""Set messages for a key."""
# Delete existing messages and insert new messages in one transaction
chat_client = self._table_service_client.create_table_if_not_exists(
self.chat_table_name
)
entities = chat_client.query_entities(f"PartitionKey eq '{key}'")
delete_operations = (
(TransactionOperation.DELETE, entity) for entity in entities
)
create_operations = (
(
TransactionOperation.CREATE,
serialize(
self.service_mode,
{
"PartitionKey": key,
"RowKey": self._to_row_key(idx),
**message.dict(),
},
),
)
for idx, message in enumerate(messages)
)
chat_client.submit_transaction(chain(delete_operations, create_operations))
# Update metadata
metadata_client = self._table_service_client.create_table_if_not_exists(
self.metadata_table_name
)
messages_len = len(messages)
metadata_client.upsert_entity(
{
"PartitionKey": self.metadata_partition_key,
"RowKey": key,
"LastMessageRowKey": self._to_row_key(messages_len - 1),
"MessageCount": messages_len,
},
UpdateMode.REPLACE,
)
To troubleshoot and resolve the TableTransactionError
, consider the following steps:
RowKey
values for the new messages are unique and do not conflict with existing ones.If the issue persists, you may need to add logging or debugging statements to inspect the entities being processed in the transaction to identify any conflicts or issues [1].
To continue talking to Dosu, mention @dosu.
Bug Description
When trying to use AzureChatStore together with ReActAgent, a TableTransactionError occurs
Version
0.11.1
Steps to Reproduce
Create agent:
At the first call everything is ok, the data is entered into the table:
But if you try to use the agent for the second time, the TableTransactionError occurs
Relevant Logs/Tracbacks
P.S. Everythinkg works fine with RedisChatStore, so this error is in the llama-index-storage-chat-store-azure library