@@ -211,6 +211,7 @@ def process_chat_message(
211
211
settings = settings ,
212
212
team_id = team_id ,
213
213
parent_id = parent_id ,
214
+ history = history ,
214
215
run_id = run .id ,
215
216
run_logs_manager = run_logs_manager ,
216
217
)
@@ -527,31 +528,20 @@ def run_conversational_agent(
527
528
settings : AccountSettings ,
528
529
run_id : UUID ,
529
530
run_logs_manager : RunLogsManager ,
531
+ history : PostgresChatMessageHistory ,
530
532
team_id : Optional [UUID ] = None ,
531
533
parent_id : Optional [UUID ] = None ,
532
534
):
533
- history = PostgresChatMessageHistory (
534
- session_id = session_id ,
535
- sender_account_id = sender_account_id ,
536
- sender_user_id = sender_user_id ,
537
- sender_name = sender_name ,
538
- parent_id = parent_id ,
539
- team_id = team_id ,
540
- agent_id = agent_with_configs .agent .id ,
541
- chat_id = None ,
542
- run_id = run_id ,
543
- )
544
-
545
- datasources = (
535
+ data_sources = (
546
536
db .session .query (DatasourceModel )
547
537
.filter (DatasourceModel .id .in_ (agent_with_configs .configs .datasources ))
548
538
.all ()
549
539
)
550
540
551
541
tool_callback_handler = run_logs_manager .get_tool_callback_handler ()
552
542
553
- datasource_tools = get_datasource_tools (
554
- datasources ,
543
+ data_source_tools = get_datasource_tools (
544
+ data_sources ,
555
545
settings ,
556
546
provider_account ,
557
547
agent_with_configs ,
@@ -570,12 +560,12 @@ def run_conversational_agent(
570
560
pre_retrieved_context = ""
571
561
572
562
if agent_with_configs .configs .source_flow == DataSourceFlow .PRE_RETRIEVAL .value :
573
- if len (datasource_tools ) != 0 :
574
- pre_retrieved_context = datasource_tools [0 ]._run (prompt )
563
+ if len (data_source_tools ) != 0 :
564
+ pre_retrieved_context = data_source_tools [0 ]._run (prompt )
575
565
576
566
tools = agent_tools
577
567
else :
578
- tools = datasource_tools + agent_tools
568
+ tools = data_source_tools + agent_tools
579
569
580
570
conversational = ConversationalAgent (sender_name , provider_account , session_id )
581
571
return conversational .run (
@@ -586,17 +576,13 @@ def run_conversational_agent(
586
576
prompt ,
587
577
history ,
588
578
human_message_id ,
589
- run_id ,
590
- sender_user_id ,
591
579
run_logs_manager ,
592
580
pre_retrieved_context ,
593
581
)
594
582
595
583
596
584
def create_and_send_chat_message (
597
585
session_id : str ,
598
- # account: AccountModel,
599
- # sender_user: UserModel,
600
586
sender_name : str ,
601
587
sender_user_id : str ,
602
588
sender_account_id : str ,
0 commit comments