Views
No views yet
| model | functionality |
|---|---|
| gorilla-openfunctions-v0 | Given a function, and user intent, returns properly formatted json with the right arguments |
| gorilla-openfunctions-v1 | + Parallel functions, and can choose between functions |
!pip install openai==0.28.11import openai
2
3def get_gorilla_response(prompt="Call me an Uber ride type \"Plus\" in Berkeley at zipcode 94704 in 10 minutes", model="gorilla-openfunctions-v0", functions=[]):
4 openai.api_key = "EMPTY"
5 openai.api_base = "http://luigi.millennium.berkeley.edu:8000/v1"
6 try:
7 completion = openai.ChatCompletion.create(
8 model="gorilla-openfunctions-v1",
9 temperature=0.0,
10 messages=[{"role": "user", "content": prompt}],
11 functions=functions,
12 )
13 return completion.choices[0].message.content
14 except Exception as e:
15 print(e, model, prompt)1query = "Call me an Uber ride type \"Plus\" in Berkeley at zipcode 94704 in 10 minutes"
2functions = [
3 {
4 "name": "Uber Carpool",
5 "api_name": "uber.ride",
6 "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",
7 "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"}]
8 }
9]
10get_gorilla_response(query, functions=functions)uber.ride(loc="berkeley", type="plus", time=10)