diff --git a/agentune_simulate/agentune/simulate/outcome_detection/rag/prompt.py b/agentune_simulate/agentune/simulate/outcome_detection/rag/prompt.py index d2835afc..b081ed04 100644 --- a/agentune_simulate/agentune/simulate/outcome_detection/rag/prompt.py +++ b/agentune_simulate/agentune/simulate/outcome_detection/rag/prompt.py @@ -108,7 +108,7 @@ def format_examples(examples: list[tuple[Document, float]]) -> str: for i, (doc, _) in enumerate(examples): messages_data = doc.metadata.get('full_conversation', '') - messages = converter.structure(messages_data, list[Message]) + messages = converter.loads(messages_data, list[Message]) conversation_text = indexing_and_retrieval.format_conversation(messages) outcome_info = doc.metadata.get('outcome', 'No outcome information available') diff --git a/agentune_simulate/agentune/simulate/rag/indexing_and_retrieval.py b/agentune_simulate/agentune/simulate/rag/indexing_and_retrieval.py index ff9ebaa8..17aec66e 100644 --- a/agentune_simulate/agentune/simulate/rag/indexing_and_retrieval.py +++ b/agentune_simulate/agentune/simulate/rag/indexing_and_retrieval.py @@ -152,6 +152,12 @@ async def get_similar_finished_conversations( # Sort by similarity score (highest first) retrieved_docs.sort(key=lambda x: x[1], reverse=True) + # If there is an exact match between the current conversation and one of the examples, remove it + retrieved_docs = [ + (doc, score) for doc, score in retrieved_docs + if doc.metadata.get('conversation_hash') != hash(conversation.messages) + ] + return retrieved_docs diff --git a/agentune_simulate/streamlit/pages/Agentune_Simulate_Runner.py b/agentune_simulate/streamlit/pages/Agentune_Simulate_Runner.py index 8ed0920c..22f63b54 100644 --- a/agentune_simulate/streamlit/pages/Agentune_Simulate_Runner.py +++ b/agentune_simulate/streamlit/pages/Agentune_Simulate_Runner.py @@ -337,7 +337,7 @@ async def run_simulation( """Run the conversation simulation.""" # Get logging callback tracer - callbacks = get_llm_callbacks(config['session_name']) + callbacks = get_llm_callbacks() # Initialize models with logging callbacks agent_model = ChatOpenAI(**config['agent_model_kwargs'], callbacks=callbacks)