Ver código fonte

fix: missing variables in agent prompt (#2395)

tags/0.5.4
Yeuoly 1 ano atrás
pai
commit
e1a9e0ac29
Nenhuma conta vinculada ao e-mail do autor do commit

+ 1
- 0
api/core/app_runner/assistant_app_runner.py Ver arquivo

conversation=conversation, conversation=conversation,
message=message, message=message,
query=query, query=query,
inputs=inputs,
) )
elif agent_entity.strategy == AgentEntity.Strategy.FUNCTION_CALLING: elif agent_entity.strategy == AgentEntity.Strategy.FUNCTION_CALLING:
assistant_fc_runner = AssistantFunctionCallApplicationRunner( assistant_fc_runner = AssistantFunctionCallApplicationRunner(

+ 19
- 1
api/core/features/assistant_cot_runner.py Ver arquivo

def run(self, conversation: Conversation, def run(self, conversation: Conversation,
message: Message, message: Message,
query: str, query: str,
inputs: Dict[str, str],
) -> Union[Generator, LLMResult]: ) -> Union[Generator, LLMResult]:
""" """
Run Cot agent application Run Cot agent application
if 'Observation' not in app_orchestration_config.model_config.stop: if 'Observation' not in app_orchestration_config.model_config.stop:
app_orchestration_config.model_config.stop.append('Observation') app_orchestration_config.model_config.stop.append('Observation')


# override inputs
inputs = inputs or {}
instruction = self.app_orchestration_config.prompt_template.simple_prompt_template
instruction = self._fill_in_inputs_from_external_data_tools(instruction, inputs)

iteration_step = 1 iteration_step = 1
max_iteration_steps = min(self.app_orchestration_config.agent.max_iteration, 5) + 1 max_iteration_steps = min(self.app_orchestration_config.agent.max_iteration, 5) + 1


tools=prompt_messages_tools, tools=prompt_messages_tools,
agent_scratchpad=agent_scratchpad, agent_scratchpad=agent_scratchpad,
agent_prompt_message=app_orchestration_config.agent.prompt, agent_prompt_message=app_orchestration_config.agent.prompt,
instruction=app_orchestration_config.prompt_template.simple_prompt_template,
instruction=instruction,
input=query input=query
) )


system_fingerprint='' system_fingerprint=''
), PublishFrom.APPLICATION_MANAGER) ), PublishFrom.APPLICATION_MANAGER)


def _fill_in_inputs_from_external_data_tools(self, instruction: str, inputs: dict) -> str:
"""
fill in inputs from external data tools
"""
for key, value in inputs.items():
try:
instruction = instruction.replace(f'{{{{{key}}}}}', str(value))
except Exception as e:
continue

return instruction

def _extract_response_scratchpad(self, content: str) -> AgentScratchpadUnit: def _extract_response_scratchpad(self, content: str) -> AgentScratchpadUnit:
""" """
extract response from llm response extract response from llm response

Carregando…
Cancelar
Salvar