Closed stevegrubb closed 2 weeks ago
The issue you're encountering, where the second function call outputs <|end_of_text|>
, could be related to several factors, including recent changes or specific configurations in the llama-index-llms-openai-like
, llama-index-agent-openai
, or llama-index-core
modules.
Logging and Error Handling:
Recent Changes:
Configuration:
is_function_calling_model
field is set to True
in your OpenAILike
model configuration. This field is crucial for enabling function calling capabilities [5].FunctionTool Configuration:
Here is an example configuration that ensures the is_function_calling_model
field is set correctly and the strict
parameter is used:
from llama_index.llms.openai_like import OpenAILike
from llama_index.agent.openai import OpenAIAgent
from llama_index.core.tools import FunctionTool
def multiply(a: int, b: int) -> int:
return a * b
def add(a: int, b: int) -> int:
return a + b
multiply_tool = FunctionTool.from_defaults(fn=multiply)
add_tool = FunctionTool.from_defaults(fn=add)
llm = OpenAILike(
model="hermes",
api_base="http://localhost:8080/v1",
api_key="fake",
is_chat_model=True,
context_window=122880,
is_function_calling_model=True
)
agent = OpenAIAgent.from_tools([multiply_tool, add_tool], llm=llm, verbose=True)
question = "What is 2 * 215"
print(question)
print(str(agent.chat(question)))
question = "What is 213 + 123"
print(question)
print(str(agent.chat(question)))
By ensuring the correct configuration and utilizing the logging and error handling mechanisms, you should be able to diagnose and resolve the issue with the second function call outputting <|end_of_text|>
.
To continue talking to Dosu, mention @dosu.
After looking into this a little more, mistralai and openai have similar but different tool calling formats, but Hermes is different. That is likely to be the difference. The format is different and parsed different. There might need to be a way to specify a tool calling format.
Looks like a recent update fixed this. Closing.
Bug Description
I was following the custom tool calling example with the add and multiply functions. Whatever function gets used first, the results are printed. Whichever function is second, it outputs <|end_of_text|>. The setup is using vLLM 0.6.1post1 in server mode using the Hermes-3-Llama-3.1-8B.Q5_K_M.gguf model. Both support tool calling. See below for verbose mode output. Let me know if there is anything else that could help pinpoint the issue.
Version
llama-index-llms-openai-like 0.2.0, llama-index-agent-openai 0.3.1, llama-index-core 0.11.8
Steps to Reproduce
from llama_index.llms.openai_like import OpenAILike from llama_index.agent.openai import OpenAIAgent from llama_index.core.tools import FunctionTool
def multiply(a: int, b: int) -> int: """Multiple two integers and returns the result integer""" return(a * b)
multiply_tool = FunctionTool.from_defaults(fn=multiply)
def add(a: int, b: int) -> int: """Add two integers and returns the result integer""" return(a + b)
add_tool = FunctionTool.from_defaults(fn=add)
llm = OpenAILike(model="hermes", api_base="http://localhost:8080/v1", api_key="fake", is_chat_model=True, context_window=122880, is_function_calling_model=True)
agent = OpenAIAgent.from_tools([multiply_tool, add_tool], llm=llm, verbose=True)
question = "What is 2 * 215" print(question) print( str(agent.chat(question)) )
question = "What is 213 + 123" print(question) print( str(agent.chat(question)) )
Relevant Logs/Tracbacks