Find answers from the community

Home
Members
Rfinity
R
Rfinity
Offline, last seen 3 months ago
Joined September 25, 2024
R
Rfinity
·

Tool

Hello, have what is hopefully a simple high-level question. What is the best way I can define an instance of BaseTool which simply takes in a string and executes a prompt against an LLM? e.g. I assume I could do something like
Plain Text
def run_prompt(input: str):
    prompt = f"Considering that the user is allergic to {input}, what are some alternatives?"
    response = someLlamaIndexFunctionToInvokeLLMDirectly.execute(prompt)
    return response.text

tool = FunctionTool.from_defaults(fn=run_prompt)

But wondering if there is a better way to accomplish this. The goal is to define an agent which uses some RetrieverTools and FunctionTools, but there are some actions I want to define which simply need to execute some pre-defined prompt template, so just not sure what the best practice would be here.
2 comments
R
L