Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tool calling for chatgpt-based math agent #116

Merged
merged 2 commits into from
May 11, 2024

Conversation

dongyuanjushi
Copy link
Collaborator

  1. add tool calling for chatgpt-based math agent
  2. refactor and wrap the LLM request with the Message object and wrap the LLM response with the Response object

@dongyuanjushi dongyuanjushi added feature request New feature or request refactor refactor code structure labels May 11, 2024
@dongyuanjushi dongyuanjushi requested a review from TataKKKL May 11, 2024 01:50
@TataKKKL
Copy link
Contributor

could you log more information on function calling, consider these information

function_name = tool_call.function.name
function_to_call = available_functions[function_name]
function_args = json.loads(tool_call.function.arguments)
function_response = function_to_call(**function_args)

messages.append(
    {
        "tool_call_id": tool_call.id,
        "role": "tool",
        "name": function_name,
        "content": str(function_response),
    }

@TataKKKL
Copy link
Contributor

TataKKKL commented May 11, 2024

Currently, you are modifying the output of a function call using natural language and some heuristics. However, ChatGPT has a workaround below, which will need to be modified later.

for tool_call in tool_calls:
    function_name = tool_call.function.name
    function_to_call = available_functions[function_name]
    function_args = json.loads(tool_call.function.arguments)
    function_response = function_to_call(**function_args)
  
    messages.append(
        {
            "tool_call_id": tool_call.id,
            "role": "tool",
            "name": function_name,
            "content": str(function_response),
        }
    )  # extend conversation with function response
second_response = client.chat.completions.create(
  model="gpt-4-1106-preview",
  messages=messages,
)  # get a new response from the model where it can see the function response

@TataKKKL TataKKKL merged commit d7cf089 into agiresearch:main May 11, 2024
@TataKKKL TataKKKL mentioned this pull request May 11, 2024
31 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request refactor refactor code structure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants