Skip to content

Files

Latest commit

cde1497 · Mar 15, 2025

History

History

node-tool-currency-converter

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Dec 31, 2024
Mar 8, 2025
Mar 15, 2025
Dec 31, 2024
Dec 31, 2024

LLM Function Calling - Currency Converter

This is a serverless function for converting currency from USD to other currencies and vice versa.

You can grab your api-key from Exchange Rate API for free, then, add it to your .env file:

YOMO_SFN_NAME=my_first_llm_function_tool
YOMO_SFN_ZIPPER=zipper.vivgrid.com:9000
YOMO_SFN_CREDENTIAL=<your-yomo-sfn-credential>
OPENEXCHANGERATES_API_KEY=<your-openexchangerates.org-api-key>

Other environment variables can be found in the vivgrid console serverless page

Development

1. Install YoMo CLI

curl -fsSL https://get.yomo.run | sh

Detail usages of the cli can be found on Doc: YoMo CLI.

2. Attach this function calling to your LLM Bridge

yomo run app.ts -n llm-tool-currency-converter

3. Trigger the function calling

Test in your terminal:

curl https://api.vivgrid.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <token>" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {
        "role": "user",
        "content": "I have $10. Can I afford sunglasses that cost 1,499 yen?"
      }
    ]
  }'

Based on the real time weather ifo, you may get response like:

{
  "id": "chatcmpl-Acss0I5tuh2ibDWr13E2p0X3LHVrG",
  "object": "chat.completion",
  "created": 1733830748,
  "model": "gpt-4o-2024-08-06",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "With $10, you have approximately 1,510.25 yen (using an exchange rate of about 151.02 JPY per USD). Since the sunglasses cost 1,499 yen, you can afford them."
      },
      "finish_reason": "stop",
      "content_filter_results": {
        "hate": {
          "filtered": false,
          "severity": "safe"
        },
        "self_harm": {
          "filtered": false,
          "severity": "safe"
        },
        "sexual": {
          "filtered": false,
          "severity": "safe"
        },
        "violence": {
          "filtered": false,
          "severity": "safe"
        },
        "jailbreak": {
          "filtered": false,
          "detected": false
        },
        "profanity": {
          "filtered": false,
          "detected": false
        }
      }
    }
  ],
  "usage": {
    "prompt_tokens": 226,
    "completion_tokens": 118,
    "total_tokens": 240,
    "prompt_tokens_details": null,
    "completion_tokens_details": null
  },
  "system_fingerprint": "fp_04751d0b65",
  "prompt_filter_results": [
    {
      "index": 0,
      "content_filter_results": {
        "hate": {
          "filtered": false,
          "severity": "safe"
        },
        "self_harm": {
          "filtered": false,
          "severity": "safe"
        },
        "sexual": {
          "filtered": false,
          "severity": "safe"
        },
        "violence": {
          "filtered": false,
          "severity": "safe"
        },
        "jailbreak": {
          "filtered": false,
          "detected": false
        },
        "profanity": {
          "filtered": false,
          "detected": false
        }
      }
    }
  ]
}