ShishirPatil / gorilla

Gorilla: Training and Evaluating LLMs for Function Calls (Tool Calls)
https://gorilla.cs.berkeley.edu/
Apache License 2.0
11.52k stars 1.01k forks source link

[bug] Hosted Gorilla: MULTIPLE FUNCTIONS calls #152

Open HAL9KKK opened 11 months ago

HAL9KKK commented 11 months ago

Describe the bug I am using gorilla-openfunctions-v1 to allow multiple function calling but it calls just the first one in the list

To Reproduce Steps to reproduce the behavior: I tried the following code using LMStudio as inference for Gorilla on port 1234:

import openai
import urllib.parse
import json

# Query Gorilla server
def get_gorilla_response(prompt="", model="gorilla-openfunctions-v1", functions=[]):
  openai.api_key = "EMPTY" 
  openai.api_base = "http://localhost:1234/v1"
  try:
    prompt = f'<<question>> {prompt} <<function>> {json.dumps(functions)}'
    completion = openai.ChatCompletion.create(
      model="gorilla-openfunctions-v1",
      temperature=0.0,
      messages=[{"role": "user", "content": prompt}],
      functions=functions,
    )
    return completion.choices[0].message.content
  except Exception as e:
    print(e, model, prompt)

here the query:

#query = "Call me an Uber ride type confort in Rome hotel in 10 minutes"
query= "send a message to Jhon using the email john@gmail.com and tell him that I need some money to buy a gift"
functions = [
    {
        "name": "Uber Carpool",
        "api_name": "uber.ride",
        "description": "Find suitable ride for customers given the location, type of ride, and the amount of time the customer is willing to wait as parameters",
        "parameters":  [{"name": "loc", "description": "location of the starting place of the uber ride"}, {"name":"type", "enum": ["plus", "comfort", "black"], "description": "types of uber ride user is ordering"}, {"name": "time", "description": "the amount of time in minutes the customer is willing to wait"}]
    },
    {
        "name": "Send Message",
        "api_name": "send.message",
        "description": "Send an email message to the destinatary",
        "parameters":  [{"name": "dest", "description": "email address, example mario@gmail.com"}, {"name":"message", "description": "body of the message, here you have to summarize the content of the message to be sent"}]
    }
]
get_gorilla_response(query, functions=functions)

I was expecting to call the function for sending a message But i got: 'uber.ride(loc="LOCATION", type="TYPE", time=30)'

devasheeshG commented 11 months ago

image not able to reproduce

HAL9KKK commented 11 months ago

how to make multiple function call with "gorilla-openfunctions-v1"? Let's suppose we have a list function call:

Or simply reply to a question without involving a function call

CHIRU98 commented 11 months ago

Hi @HAL9KKK you got the solution for the multiple function?

HAL9KKK commented 11 months ago

Hi @CHIRU98 unfortunately not....I do not know why this multiple function feature is not working! @ShishirPatil can you please explain how to use your code to make 2 function calls and the LLM should understand how to classify the call based on the context?

liyoung1992 commented 10 months ago

The same problem, only one function can be called each time.

benhe0 commented 9 months ago

Hey @HAL9KKK were you able to solve this? I'm having the same problem..