Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,93 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: llama3
|
| 3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: llama3
|
| 3 |
+
---
|
| 4 |
+
## Usage From Our SDK
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
``` python
|
| 8 |
+
pip install scalegen-function-calling
|
| 9 |
+
```
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
``` python
|
| 13 |
+
from scalegen_function_calling import CustomOpenAIClient
|
| 14 |
+
from openai import OpenAI
|
| 15 |
+
|
| 16 |
+
tools = [
|
| 17 |
+
{
|
| 18 |
+
"type":"function",
|
| 19 |
+
"function":{
|
| 20 |
+
"name":"Expense",
|
| 21 |
+
"description":"",
|
| 22 |
+
"parameters":{
|
| 23 |
+
"type":"object",
|
| 24 |
+
"properties":{
|
| 25 |
+
"description":{
|
| 26 |
+
"type":"string"
|
| 27 |
+
},
|
| 28 |
+
"net_amount":{
|
| 29 |
+
"type":"number"
|
| 30 |
+
},
|
| 31 |
+
"gross_amount":{
|
| 32 |
+
"type":"number"
|
| 33 |
+
},
|
| 34 |
+
"tax_rate":{
|
| 35 |
+
"type":"number"
|
| 36 |
+
},
|
| 37 |
+
"date":{
|
| 38 |
+
"type":"string",
|
| 39 |
+
"format":"date-time"
|
| 40 |
+
}
|
| 41 |
+
},
|
| 42 |
+
"required":[
|
| 43 |
+
"description",
|
| 44 |
+
"net_amount",
|
| 45 |
+
"gross_amount",
|
| 46 |
+
"tax_rate",
|
| 47 |
+
"date"
|
| 48 |
+
]
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
},
|
| 52 |
+
{
|
| 53 |
+
"type":"function",
|
| 54 |
+
"function":{
|
| 55 |
+
"name":"ReportTool",
|
| 56 |
+
"description":"",
|
| 57 |
+
"parameters":{
|
| 58 |
+
"type":"object",
|
| 59 |
+
"properties":{
|
| 60 |
+
"report":{
|
| 61 |
+
"type":"string"
|
| 62 |
+
}
|
| 63 |
+
},
|
| 64 |
+
"required":[
|
| 65 |
+
"report"
|
| 66 |
+
]
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
}
|
| 70 |
+
]
|
| 71 |
+
|
| 72 |
+
model_name = "ScaleGenAI/Llama3-70B-Function-Calling"
|
| 73 |
+
api_key = "<YOUR_API_KEY>"
|
| 74 |
+
api_endpint = "<YOUR_API_ENDPOINT>"
|
| 75 |
+
|
| 76 |
+
messages = [
|
| 77 |
+
{"role":"user", "content": 'I have spend 5$ on a coffee today please track my expense. The tax rate is 0.2. plz add to expense'}
|
| 78 |
+
]
|
| 79 |
+
|
| 80 |
+
client = OpenAI(
|
| 81 |
+
api_key=api_key,
|
| 82 |
+
base_url=api_endpoint,
|
| 83 |
+
)
|
| 84 |
+
|
| 85 |
+
custom_client = CustomOpenAIClient(client) #patch the client
|
| 86 |
+
|
| 87 |
+
response = custom_client.chat.completions.create(
|
| 88 |
+
model=model_name,
|
| 89 |
+
messages=messages,
|
| 90 |
+
tools=tools,
|
| 91 |
+
stream=False
|
| 92 |
+
)
|
| 93 |
+
```
|