11"""Manages the shared state and workflow for Willa chatbots."""
2- import re
32from typing import Any , Optional , Annotated , NotRequired
43from typing_extensions import TypedDict
54
@@ -23,8 +22,6 @@ class WillaChatbotState(TypedDict):
2322 search_query : NotRequired [str ]
2423 tind_metadata : NotRequired [str ]
2524 documents : NotRequired [list [Any ]]
26- citations : NotRequired [list [dict [str , Any ]]]
27-
2825
2926class GraphManager : # pylint: disable=too-few-public-methods
3027 """Manages the shared LangGraph workflow for all chatbot instances."""
@@ -143,22 +140,12 @@ def _generate_response(self, state: WillaChatbotState) -> dict[str, list[AnyMess
143140 # Get response from model
144141 response = model .invoke (
145142 messages ,
146- additional_model_request_fields = {"documents" : documents },
147- additional_model_response_field_paths = ["/citations" ]
143+ additional_model_request_fields = {"documents" : documents }
148144 )
149- citations = response .response_metadata .get ('additionalModelResponseFields' ).get ('citations' ) if response .response_metadata else None
150145
151146 # Create clean response content
152147 response_content = str (response .content ) if hasattr (response , 'content' ) else str (response )
153148
154- if citations :
155- state ['citations' ] = citations
156- response_content += "\n \n Citations:\n "
157- for citation in citations :
158- doc_ids = list (dict .fromkeys ([re .sub (r'_\d*$' , '' , doc_id )
159- for doc_id in citation .get ('document_ids' , [])]))
160- response_content += f"- { citation .get ('text' , '' )} ({ ', ' .join (doc_ids )} )\n "
161-
162149 response_messages : list [AnyMessage ] = [AIMessage (content = response_content ),
163150 ChatMessage (content = tind_metadata , role = 'TIND' ,
164151 response_metadata = {'tind' : True })]
0 commit comments