Elffuss BraidHub

kikocis/llama-stack public

5ede92d96ce6 · 1.4 KiBRawPermalink
1# Copyright (c) Meta Platforms, Inc. and affiliates.
2# All rights reserved.
3#
4# This source code is licensed under the terms described in the LICENSE file in
5# the root directory of this source tree.
6
7from typing import Dict
8
9from llama_models.llama3.api.datatypes import ToolParamDefinition
10from llama_stack.tools.custom.datatypes import SingleMessageCustomTool
11
12
13class GetBoilingPointTool(SingleMessageCustomTool):
14 """Tool to give boiling point of a liquid
15 Returns the correct value for water in Celcius and Fahrenheit
16 and returns -1 for other liquids
17
18 """
19
20 def get_name(self) -> str:
21 return "get_boiling_point"
22
23 def get_description(self) -> str:
24 return "Get the boiling point of a imaginary liquids (eg. polyjuice)"
25
26 def get_params_definition(self) -> Dict[str, ToolParamDefinition]:
27 return {
28 "liquid_name": ToolParamDefinition(
29 param_type="string", description="The name of the liquid", required=True
30 ),
31 "celcius": ToolParamDefinition(
32 param_type="boolean",
33 description="Whether to return the boiling point in Celcius",
34 required=False,
35 ),
36 }
37
38 async def run_impl(self, liquid_name: str, celcius: bool = True) -> int:
39 if liquid_name.lower() == "polyjuice":
40 if celcius:
41 return -100
42 else:
43 return -212
44 else:
45 return -1