Skip to content

Function calling and connections #3425

Answered by 0mza987
anderl80 asked this question in Q&A
Discussion options

You must be logged in to vote

Basically I think your workaround is fine. If you don't like the ugly hard-coding, you can wrap the function with prepared connections:

from functools import partial

@tool
def run_function(response_message: dict, db_conn: CustomConnection, aoai_conn: AzureOpenAIConnection) -> str:
    functions = globals()
    functions["run_db_lookup"] = partial(run_db_lookup, db_conn=db_conn, aoai_conn=aoai_conn)
    ...

In this way you can use the original result = globals()[function_name](**function_args) to call the function with connection.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@anderl80
Comment options

@0mza987
Comment options

@anderl80
Comment options

@0mza987
Comment options

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