o
    fh=                     @   s   d dl mZ d dlmZ d dlmZ d dlmZmZ d dl	m
Z
 d dlmZ G dd deZeed	Zd
Zejede idZeeB eB ZddedededB fddZdS )    )llm)ChatPromptTemplate)JsonOutputParser)	BaseModelField)RunnableParallel)CHARACTER_TEMPLATEc                   @   sH   e Zd ZU eddZeed< eddZeed< eddZedB ed< dS )	AssistantResponsez0The natural language response to the user query.)descriptionresponsez5The related action ID from the input action ID array.	action_idz:The destination if specified by the user; otherwise, null.Ndestination)	__name__
__module____qualname__r   r   str__annotations__r   r    r   r   Y/var/www/html/aiverses.in/BackEnd/Ai_Agents/services/llm_functions/get_action_response.pyr	      s   
 r	   )pydantic_objecta  
You are an intelligent assistant. Based on the user input, the list of possible actions, 
and optionally the distances to various destinations, determine the most relevant action ID and generate an appropriate response.

If distances are provided and the user specifies a movement or want to see a destination but doesn't mention the mode (car or walk), decide based on the distance:
- Use "Move by walk" if the distance is <= 2 km.
- Use "Move by car" if the distance is > 2 km.

If distances are not provided, make a logical decision based only on the user input.

Input: "{user_input}"
Actions: {actions}
Distances: {distances}

Output format:
{format_instructions}

Example with distances:
Input: "Take me to Park Area"
Actions: ["Move by car", "Move by walk", "Stop", "Start Tour", "End Tour"]
Distances: {{"Park Area": 24, "Premium Villa": 45, "Playground": 1.5}}
Response: "Okay, I will take you to the Park Area."
Action ID: "Move by car"
Destination: "Park Area"

Example without distances:
Input: "End the tour for today."
Actions: ["Move by car", "Move by walk", "Stop", "Start Tour", "End Tour"]
Distances: null
Response: "Ending the tour for today."
Action ID: "End Tour"
Destination: null
format_instructions)templatepartial_variablesN
user_inputactions	distancesc                 C   s&   |dur|nd}t | ||d}|S )zVGet the response from the LLM based on user input, action IDs, and optional distances.Nnull)r   r   r   )chaininvoke)r   r   r   resultr   r   r   get_action_responseI   s   r    )N)Ai_Agents.models.language_modelr   langchain.promptsr   langchain_core.output_parsersr   pydanticr   r   langchain_core.runnablesr   /Ai_Agents.services.templates.character_templater   r	   parserprompt_templatefrom_templateget_format_instructionspromptr   r   listdictr    r   r   r   r   <module>   s   
"
 