Pass a list of options to a tool's arg #27089
Replies: 3 comments 24 replies
-
To handle a list of options and return the position of an item in LangChain, you can iterate over the list and find the index of the desired item. Since you want to return the position starting from 1, you can add 1 to the index. Here's how you can modify your tool to achieve this: @tool
def input_animais_secados(
cdfazenda: Optional[str] = None,
numero: Optional[list[str]] = None,
data: Optional[list[str]] = None,
motivo_secagem: Optional[list[str]] = None,
peso: Optional[list[str]] = None,
ecc: Optional[list[str]] = None,
observacao: Optional[list[str]] = None
):
"""FERRAMENTA DE INPUT. Utilizar a ferramenta quando o usuário informar que quer enviar/lançar/subir informações sobre secagem (parar de dar leite) de um animal ou uma lista de animais. Esta ferramenta fará a atualização da [base - banco de dados - sistema - ideagri] do usuário. Se for inserido informações de mais de um animal, sempre coloque os dados na ordem que o usuário inseriu. Informe sempre apenas as variáveis obrigatórias para o usuário.
Args:
cdfazenda: é o código da fazenda. O formato é composto apenas por números. É uma variável obrigatória. SEMPRE solicite caso nao tenha esta variável.ou se esta variável for None ou Null é OBRIGATÓRIO SOLICITAR o cdfazenda
data: É a data no qual foi realizado a secagem. É uma variável obrigatória. Transforme no seguinte formato %d/%m/%Y. Caso o formato seja ambiguo, informe para o usuário passar a data no formato %d/%m/%Y.
numero: Nome do animal a secar. Esta informação não deve ser vazia
motivo_secagem: Motivo da secagem. Retorne a posição da lista que será informado para o usuário. Retorne apenas a posição sendo a primeira como 1.
peso: É o peso do animal, apenas o valor. Esta variável não é obrigatória. Se o usuário não informou a variável coloque ela como ''(vazio) nunca deixe ela como null ou sem registros.
ecc: É o escore de condição corporal do animal deve ser um número de 1 a 9. Esta variável não é obrigatória. Se o usuário não informou a variável coloque ela como ''(vazio) nunca deixe ela como null ou sem registros.
observacao: Observação que o usuário queira colocar. Esta variável não é obrigatória. Se o usuário não informou a variável coloque ela como ''(vazio) nunca deixe ela como null ou sem registros.
"""
if motivo_secagem:
# Example: Find the position of a specific reason in the list
specific_reason = "some_reason" # Replace with the actual reason you're looking for
if specific_reason in motivo_secagem:
position = motivo_secagem.index(specific_reason) + 1
return f"The position of the reason '{specific_reason}' is {position}."
else:
return "The specified reason is not in the list."
else:
return "No drying reasons provided." Replace |
Beta Was this translation helpful? Give feedback.
-
@dosu Is there any way to format the args text to include the list of reasons |
Beta Was this translation helpful? Give feedback.
-
@dosu |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
I want to pass a list of options in the drying reasons variable, so that the agent identifies the position in the list and returns it to be able to use the variable in an insertion case.
System Info
windows
python 3.11
Beta Was this translation helpful? Give feedback.
All reactions