glaiveai/glaive-function-calling-v2
Viewer • Updated • 113k • 61.6k • 508
How to use jacobbao/openbuddy-zephyr-7b-v14.1-code-orca-function-calling with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="jacobbao/openbuddy-zephyr-7b-v14.1-code-orca-function-calling") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("jacobbao/openbuddy-zephyr-7b-v14.1-code-orca-function-calling")
model = AutoModelForCausalLM.from_pretrained("jacobbao/openbuddy-zephyr-7b-v14.1-code-orca-function-calling")How to use jacobbao/openbuddy-zephyr-7b-v14.1-code-orca-function-calling with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "jacobbao/openbuddy-zephyr-7b-v14.1-code-orca-function-calling"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "jacobbao/openbuddy-zephyr-7b-v14.1-code-orca-function-calling",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/jacobbao/openbuddy-zephyr-7b-v14.1-code-orca-function-calling
How to use jacobbao/openbuddy-zephyr-7b-v14.1-code-orca-function-calling with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "jacobbao/openbuddy-zephyr-7b-v14.1-code-orca-function-calling" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "jacobbao/openbuddy-zephyr-7b-v14.1-code-orca-function-calling",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "jacobbao/openbuddy-zephyr-7b-v14.1-code-orca-function-calling" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "jacobbao/openbuddy-zephyr-7b-v14.1-code-orca-function-calling",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use jacobbao/openbuddy-zephyr-7b-v14.1-code-orca-function-calling with Docker Model Runner:
docker model run hf.co/jacobbao/openbuddy-zephyr-7b-v14.1-code-orca-function-calling
Use function calling prompt as fallows:
<|system|>
You are a helpful assistant with access to the following functions. Use them if required
- {
"name": "calculate_discount",
"description": "Calculate the discounted price based on original price and percentage",
"parameters": {
"type": "object",
"properties": {
"original_price": {
"type": "number",
"description": "The original price of the item"
},
"discount_percentage": {
"type": "number",
"description": "The percentage of discount to apply"
}
},
"required": ["original_price","discount_percentage"]
}
}
<|user|>
Hi, I saw a dress in a store that costs $200. They are offering a 20% discount. Can you tell me how much it will cost after the discount?
<|assistant|>
{"name": "calculate_discount", "arguments": {"original_price": 200, "discount_percentage": 20}}
<|function|>
{"discounted_price": 160}
<|assistant|>
The dress will cost you $160 after the 20% discount.
<|user|>
That's great! Thank you for the help.
<|assistant|>
You're welcome! If you have any other questions, feel free to ask.