llama-cpp-python icon indicating copy to clipboard operation
llama-cpp-python copied to clipboard

`function_call` and `tool_choice` didn't have "auto" feature implemented

Open MoeBuTa opened this issue 1 year ago • 4 comments

Prerequisites

Please answer the following questions for yourself before submitting an issue.

  • [x] I am running the latest code. Development is very rapid so there are no tagged versions as of now.
  • [x] I carefully followed the README.md.
  • [x] I searched using keywords relevant to my issue to make sure that I am creating a new issue that is not already open (or closed).
  • [x] I reviewed the Discussions, and have a new bug or useful enhancement to share.

Expected Behavior

Please provide a detailed written description of what you were trying to do, and what you expected llama-cpp-python to do.

Current Behavior

Please provide a detailed written description of what llama-cpp-python did, instead.

Environment and Context

Please provide detailed information about your computer setup. This is important in case the issue is not reproducible except for under certain specific conditions.

  • Physical (or virtual) hardware you are using, e.g. for Linux:

$ lscpu

  • Operating System, e.g. for Linux:

$ uname -a

  • SDK version, e.g. for Linux:
$ python3 --version
$ make --version
$ g++ --version

Failure Information (for bugs)

Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.

Steps to Reproduce

Please provide detailed steps for reproducing the issue. We are not sitting in front of your screen, so the more detail the better.

  1. step 1
  2. step 2
  3. step 3
  4. etc.

Note: Many issues seem to be regarding functional or performance issues / differences with llama.cpp. In these cases we need to confirm that you're comparing against the version of llama.cpp that was built with your python package, and which parameters you're passing to the context.

Try the following:

  1. git clone https://github.com/abetlen/llama-cpp-python
  2. cd llama-cpp-python
  3. rm -rf _skbuild/ # delete any old builds
  4. python -m pip install .
  5. cd ./vendor/llama.cpp
  6. Follow llama.cpp's instructions to cmake llama.cpp
  7. Run llama.cpp's ./main with the same arguments you previously passed to llama-cpp-python and see if you can reproduce the issue. If you can, log an issue with llama.cpp

Failure Logs

Please include any relevant log snippets or files. If it works under one configuration but not under another, please provide logs for both configurations and their corresponding outputs so it is easy to see where behavior changes.

Also, please try to avoid using screenshots if at all possible. Instead, copy/paste the console output and use Github's markdown to cleanly format your logs for easy readability.

Example environment info:

llama-cpp-python$ git log | head -1
commit 47b0aa6e957b93dbe2c29d53af16fbae2dd628f2

llama-cpp-python$ python3 --version
Python 3.10.10

llama-cpp-python$ pip list | egrep "uvicorn|fastapi|sse-starlette|numpy"
fastapi                  0.95.0
numpy                    1.24.3
sse-starlette            1.3.3
uvicorn                  0.21.1

llama-cpp-python/vendor/llama.cpp$ git log | head -3
commit 66874d4fbcc7866377246efbcee938e8cc9c7d76
Author: Kerfuffle <[email protected]>
Date:   Thu May 25 20:18:01 2023 -0600

MoeBuTa avatar Apr 09 '24 11:04 MoeBuTa

@MoeBuTa can you elaborate a little more, which chat format, maybe a code sample?

It should be noted that because "auto" requires the LLM to choose the appropriate tool and requires some special parsing, currently it only works for some models like "functionary".

abetlen avatar Apr 09 '24 16:04 abetlen

Hi @abetlen ,

It is at the line 561 of https://github.com/abetlen/llama-cpp-python/blob/main/llama_cpp/llama_chat_format.py. I would like to use the tool_choice="auto" feature to automatically call the appropriate tool I passed to the tools parameter and expected a convert_completion_to_chat_function response, but it appears that line 561 doesn't take tool_choice="auto" into consideration and do something for it. Thus the tool will be None and won't go into the convert_completion_to_chat_function.

The code example I used is what you provided in the readme.md, I only changed the tool_choice="auto" and it gave me a normal chat message response instead of chat function response

MoeBuTa avatar Apr 10 '24 00:04 MoeBuTa

Still no updates? I believe we should collaborate somehow to improve the code. That breaks user experience on adjusting llama_cpp for agents

Sm1Ling avatar Jun 20 '24 15:06 Sm1Ling

wow, no update after months and months ?!!

issamovitch avatar Feb 20 '25 21:02 issamovitch