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

[Bug]: Mistral function calling is not working with LM Studio #1225

Open
rjambrecic opened this issue Mar 4, 2025 · 0 comments
Open

[Bug]: Mistral function calling is not working with LM Studio #1225

rjambrecic opened this issue Mar 4, 2025 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@rjambrecic
Copy link
Collaborator

rjambrecic commented Mar 4, 2025

Describe the bug

If we register a function to agent with Mistral llm config, the conversation will raise BadRequestError

Steps to reproduce

from autogen import ConversableAgent, register_function

llm_config = {
    "config_list": [
        {
            "model": "lmstudio-community/mistral-7b-instruct-v0.3",
            "base_url": "http://localhost:1234/v1",
            "api_key": "lm-studio",
            "price":[0.0,0.0],
        },
    ],
    "cache_seed": None,  # Disable caching.
}

agent = ConversableAgent(
    name="Agent",
    llm_config=llm_config,
)

executor = ConversableAgent(
    name="user_proxy",
    human_input_mode="NEVER",
)

def get_airplane_ticket_price():
    return "Ticket is 100€"

register_function(
    get_airplane_ticket_price,
    caller=agent,
    executor=executor,
    description="Get the price of an airplane ticket",
)


executor.initiate_chat(
    recipient=agent,
    message="I need to buy a plane ticket for Paris",
)
user_proxy (to Agent):

I need to buy a plane ticket for Paris

--------------------------------------------------------------------------------

>>>>>>>> USING AUTO REPLY...
---------------------------------------------------------------------------
BadRequestError                           Traceback (most recent call last)
Cell In[1], [line 36](vscode-notebook-cell:?execution_count=1&line=36)
     [26](vscode-notebook-cell:?execution_count=1&line=26)     return "Ticket is 100€"
     [28](vscode-notebook-cell:?execution_count=1&line=28) register_function(
     [29](vscode-notebook-cell:?execution_count=1&line=29)     get_airplane_ticket_price,
     [30](vscode-notebook-cell:?execution_count=1&line=30)     caller=agent,
     [31](vscode-notebook-cell:?execution_count=1&line=31)     executor=executor,
     [32](vscode-notebook-cell:?execution_count=1&line=32)     description="Get the price of an airplane ticket",
     [33](vscode-notebook-cell:?execution_count=1&line=33) )
---> [36](vscode-notebook-cell:?execution_count=1&line=36) executor.initiate_chat(
     [37](vscode-notebook-cell:?execution_count=1&line=37)     recipient=agent,
     [38](vscode-notebook-cell:?execution_count=1&line=38)     message="I need to buy a plane ticket for Paris",
     [39](vscode-notebook-cell:?execution_count=1&line=39) )

File ~/projects/ag2/autogen/agentchat/conversable_agent.py:1499, in ConversableAgent.initiate_chat(self, recipient, clear_history, silent, cache, max_turns, summary_method, summary_args, message, **kwargs)
   [1497](https://file+.vscode-resource.vscode-cdn.net/Users/robert/projects/ag2/~/projects/ag2/autogen/agentchat/conversable_agent.py:1497)     else:
   [1498](https://file+.vscode-resource.vscode-cdn.net/Users/robert/projects/ag2/~/projects/ag2/autogen/agentchat/conversable_agent.py:1498)         msg2send = self.generate_init_message(message, **kwargs)
-> [1499](https://file+.vscode-resource.vscode-cdn.net/Users/robert/projects/ag2/~/projects/ag2/autogen/agentchat/conversable_agent.py:1499)     self.send(msg2send, recipient, silent=silent)
   [1500](https://file+.vscode-resource.vscode-cdn.net/Users/robert/projects/ag2/~/projects/ag2/autogen/agentchat/conversable_agent.py:1500) summary = self._summarize_chat(
   [1501](https://file+.vscode-resource.vscode-cdn.net/Users/robert/projects/ag2/~/projects/ag2/autogen/agentchat/conversable_agent.py:1501)     summary_method,
   [1502](https://file+.vscode-resource.vscode-cdn.net/Users/robert/projects/ag2/~/projects/ag2/autogen/agentchat/conversable_agent.py:1502)     summary_args,
   [1503](https://file+.vscode-resource.vscode-cdn.net/Users/robert/projects/ag2/~/projects/ag2/autogen/agentchat/conversable_agent.py:1503)     recipient,
   [1504](https://file+.vscode-resource.vscode-cdn.net/Users/robert/projects/ag2/~/projects/ag2/autogen/agentchat/conversable_agent.py:1504)     cache=cache,
   [1505](https://file+.vscode-resource.vscode-cdn.net/Users/robert/projects/ag2/~/projects/ag2/autogen/agentchat/conversable_agent.py:1505) )
...
   (...)
   [1079](https://file+.vscode-resource.vscode-cdn.net/Users/robert/projects/ag2/~/projects/ag2/.venv/lib/python3.11/site-packages/openai/_base_client.py:1079)     retries_taken=retries_taken,
   [1080](https://file+.vscode-resource.vscode-cdn.net/Users/robert/projects/ag2/~/projects/ag2/.venv/lib/python3.11/site-packages/openai/_base_client.py:1080) )

BadRequestError: Error code: 400 - {'error': 'Error rendering prompt with jinja template: Error: Only user and assistant roles are supported!'}

Model Used

No response

Expected Behavior

No response

Screenshots and logs

No response

Additional Information

No response

@rjambrecic rjambrecic added the bug Something isn't working label Mar 4, 2025
@rjambrecic rjambrecic self-assigned this Mar 4, 2025
@rjambrecic rjambrecic added this to ag2 Mar 4, 2025
@rjambrecic rjambrecic moved this to Todo in ag2 Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

1 participant