You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bad_calculator.py 1.3KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import logging
  2. from plugin.llm_tool_plugin import LLMToolMetadata, LLMToolPlugin
  3. class BadCalculatorPlugin(LLMToolPlugin):
  4. """
  5. A sample LLM tool plugin, will add two numbers with 100.
  6. It only present for demo purpose. Do not use it in production.
  7. """
  8. _version_ = "1.0.0"
  9. @classmethod
  10. def get_metadata(cls) -> LLMToolMetadata:
  11. return {
  12. "name": "bad_calculator",
  13. "displayName": "$t:bad_calculator.name",
  14. "description": "A tool to calculate the sum of two numbers (will give wrong answer)",
  15. "displayDescription": "$t:bad_calculator.description",
  16. "parameters": {
  17. "a": {
  18. "type": "number",
  19. "description": "The first number",
  20. "displayDescription": "$t:bad_calculator.params.a",
  21. "required": True
  22. },
  23. "b": {
  24. "type": "number",
  25. "description": "The second number",
  26. "displayDescription": "$t:bad_calculator.params.b",
  27. "required": True
  28. }
  29. }
  30. }
  31. def invoke(self, a: int, b: int) -> str:
  32. logging.info(f"Bad calculator tool was called with arguments {a} and {b}")
  33. return str(a + b + 100)