entities.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. from enum import Enum
  2. from typing import Any, Literal, Optional, Union
  3. from pydantic import BaseModel
  4. class AgentToolEntity(BaseModel):
  5. """
  6. Agent Tool Entity.
  7. """
  8. provider_type: Literal["builtin", "api"]
  9. provider_id: str
  10. tool_name: str
  11. tool_parameters: dict[str, Any] = {}
  12. class AgentPromptEntity(BaseModel):
  13. """
  14. Agent Prompt Entity.
  15. """
  16. first_prompt: str
  17. next_iteration: str
  18. class AgentScratchpadUnit(BaseModel):
  19. """
  20. Agent First Prompt Entity.
  21. """
  22. class Action(BaseModel):
  23. """
  24. Action Entity.
  25. """
  26. action_name: str
  27. action_input: Union[dict, str]
  28. agent_response: Optional[str] = None
  29. thought: Optional[str] = None
  30. action_str: Optional[str] = None
  31. observation: Optional[str] = None
  32. action: Optional[Action] = None
  33. class AgentEntity(BaseModel):
  34. """
  35. Agent Entity.
  36. """
  37. class Strategy(Enum):
  38. """
  39. Agent Strategy.
  40. """
  41. CHAIN_OF_THOUGHT = 'chain-of-thought'
  42. FUNCTION_CALLING = 'function-calling'
  43. provider: str
  44. model: str
  45. strategy: Strategy
  46. prompt: Optional[AgentPromptEntity] = None
  47. tools: list[AgentToolEntity] = None
  48. max_iteration: int = 5