Skip to content

How to dynamically load tool descriptions #28013

Answered by Huyueeer
Huyueeer asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you very much for your patience and assistance, I checked it according to your idea, and then modified the code and found that it was OK. My final modification was:

def new_execute_sql_tao(sql: str, state: Annotated[dict, InjectedState]):
    print('\n', '【execute_sql_tool_node】')
    sql = sql.replace('```sql', "").replace('```', "")
    data = postgres_raw_sql_query(sql, db_key=selectSiteDB(state['site']))
    df = pd.DataFrame(data)
    data = df.to_markdown()
    return data

from langchain.tools import  StructuredTool
tools =  [StructuredTool.from_function(
    name="<name>",
    func=execute_sql_tao
    description=get_prompt_template_prompty("tools", "execute_sql")
)]

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@Huyueeer
Comment options

@feijoes
Comment options

@feijoes
Comment options

@Huyueeer
Comment options

Answer selected by Huyueeer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants