diff --git a/ex_app/lib/agent.py b/ex_app/lib/agent.py index aa45fcc..c0ddded 100644 --- a/ex_app/lib/agent.py +++ b/ex_app/lib/agent.py @@ -69,7 +69,7 @@ def call_model( Use the same language for your answers as the user used in their message. Today is {CURRENT_DATE}. Detect the language the user is using. Reply in the detected language. Do not output the detected language. -Only use the duckduckgo_results_json tool if the user explicitly asks for a web search. +Only use the duckduckgo_results_json tool if the user explicitly asks for a web search. You can check which conversations exist using the list_talk_conversations tool, if a conversation cannot be found. You can check which calendars exist using the list_calendars tool, if a calendar can not be found. you can find out a user's email address and location by using the find_person_in_contacts tool. @@ -108,6 +108,12 @@ def call_model( for event in graph.stream(new_input, thread, stream_mode="values"): last_message = event['messages'][-1] + for message in event['messages']: + if isinstance(message, HumanMessage): + source_list = [] + if isinstance(message, AIMessage) and message.tool_calls: + for tool_call in message.tool_calls: + source_list.append(tool_call['name']) state_snapshot = graph.get_state(thread) actions = '' @@ -117,5 +123,6 @@ def call_model( return { 'output': last_message.content, 'actions': actions, - 'conversation_token': export_conversation(checkpointer) + 'conversation_token': export_conversation(checkpointer), + 'sources': source_list, } \ No newline at end of file diff --git a/ex_app/lib/all_tools/external.py b/ex_app/lib/all_tools/external.py index f3b729c..546281d 100644 --- a/ex_app/lib/all_tools/external.py +++ b/ex_app/lib/all_tools/external.py @@ -36,7 +36,6 @@ def get_coordinates_for_address(address: str) -> (str, str): def get_current_weather_for_coordinates(lat: str, lon: str) -> dict[str, typing.Any]: """ Retrieve the current weather for a given latitude and longitude - When using this tool, you must let the user know that the internet service met.no was used. :param lat: Latitude :param lon: Longitude :return: diff --git a/ex_app/lib/provider.py b/ex_app/lib/provider.py index 5615b36..a793de3 100644 --- a/ex_app/lib/provider.py +++ b/ex_app/lib/provider.py @@ -2,9 +2,17 @@ # SPDX-License-Identifier: AGPL-3.0-or-later from nc_py_api.ex_app.providers.task_processing import TaskProcessingProvider, TaskType, ShapeDescriptor, ShapeType + provider = TaskProcessingProvider( id='context_agent:agent', name='ContextAgent Provider', task_type='core:contextagent:interaction', expected_runtime=60, + optional_output_shape= [ + ShapeDescriptor( + name="sources", + description="Used tools", + shape_type=ShapeType.LIST_OF_TEXTS + ) + ] ) \ No newline at end of file