Skip to content

Instantly share code, notes, and snippets.

@ricklamers
Created July 29, 2024 19:02
Show Gist options
  • Save ricklamers/fa769b79c06c6a5f072b45ca2800ed6b to your computer and use it in GitHub Desktop.
Save ricklamers/fa769b79c06c6a5f072b45ca2800ed6b to your computer and use it in GitHub Desktop.
curl https://api.groq.com/openai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $GROQ_API_KEY" \
-d '{
"model": "llama3-groq-70b-8192-tool-use-preview",
"messages": [
{
"role": "user",
"content": "I have a flight booked for July 14, 2024, the flight number is AA100. Please check the status for me."
}
],
"max_tokens": 2048,
"tools": [
{
"type": "function",
"function": {
"name": "get_flight_status",
"description": "Get the current status of a flight",
"parameters": {
"type": "object",
"properties": {
"flight_number": {
"type": "string",
"description": "The flight number, e.g., AA100"
},
"date": {
"type": "string",
"format": "date",
"description": "The date of the flight, e.g., 2024-06-17"
}
},
"required": ["flight_number", "date"]
}
}
}
],
"tool_choice": "auto"
}'
@ricklamers
Copy link
Author

{
  "id": "chatcmpl-02f0ec8c-4bc1-405a-af34-28201089bb7f",
  "object": "chat.completion",
  "created": 1722279740,
  "model": "llama3-groq-70b-8192-tool-use-preview",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "tool_calls": [
          {
            "id": "call_rv4b",
            "type": "function",
            "function": {
              "name": "get_flight_status",
              "arguments": "{\"date\": \"2024-07-14\", \"flight_number\": \"AA100\"}"
            }
          }
        ]
      },
      "logprobs": null,
      "finish_reason": "tool_calls"
    }
  ],
  "usage": {
    "prompt_tokens": 274,
    "prompt_time": 0.027714474,
    "completion_tokens": 40,
    "completion_time": 0.127195906,
    "total_tokens": 314,
    "total_time": 0.15491038
  },
  "system_fingerprint": "fp_ee4b521143",
  "x_groq": {
    "id": "req_01j3zxygt2ey9vwrr2g06q8bq7"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment