Skip to content

Commit

Permalink
Fix bug when there is more than one function call
Browse files Browse the repository at this point in the history
  • Loading branch information
nicovank committed Feb 20, 2024
1 parent bc86faa commit 5019270
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 1 addition & 5 deletions src/chatdbg/chatdbg_lldb.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import pathlib
import sys
import textwrap
from typing import Any, Optional, Tuple

import lldb
Expand All @@ -9,10 +9,7 @@
import llm_utils
import openai

import textwrap
from assistant.assistant import Assistant

sys.path.append(os.path.abspath(pathlib.Path(__file__).parent.resolve()))
import chatdbg_utils
import conversation

Expand All @@ -22,7 +19,6 @@


def __lldb_init_module(debugger: lldb.SBDebugger, internal_dict: dict) -> None:
# Update the prompt.
debugger.HandleCommand("settings set prompt '(ChatDBG lldb) '")


Expand Down
7 changes: 5 additions & 2 deletions src/chatdbg/conversation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,23 @@ def converse(client, args: argparse.Namespace):

choice = completion.choices[0]
if choice.finish_reason == "tool_calls":
responses = []
for tool_call in choice.message.tool_calls:
name = tool_call.function.name
arguments = json.loads(tool_call.function.arguments)
function_response = fns.dispatch(name, arguments)
if function_response:
conversation.append(choice.message)
conversation.append(
responses.append(
{
"tool_call_id": tool_call.id,
"role": "tool",
"name": tool_call.function.name,
"content": function_response,
}
)
if responses:
conversation.append(choice.message)
conversation.extend(responses)
elif choice.finish_reason == "stop":
text = completion.choices[0].message.content
return llm_utils.word_wrap_except_code_blocks(text)
Expand Down

0 comments on commit 5019270

Please sign in to comment.