Elffuss BraidHub

kikocis/Based-Agent public

a87f47c62cfe · 1.1 KiBRawPermalink
1from openai.types.chat import ChatCompletionMessage
2from openai.types.chat.chat_completion_message_tool_call import (
3 ChatCompletionMessageToolCall,
4 Function,
5)
6from typing import List, Callable, Union, Optional
7
8# Third-party imports
9from pydantic import BaseModel
10
11AgentFunction = Callable[[], Union[str, "Agent", dict]]
12
13
14class Agent(BaseModel):
15 name: str = "Agent"
16 model: str = "gpt-4o"
17 instructions: Union[str, Callable[[], str]] = "You are a helpful agent."
18 functions: List[AgentFunction] = []
19 tool_choice: str = None
20 parallel_tool_calls: bool = True
21
22
23class Response(BaseModel):
24 messages: List = []
25 agent: Optional[Agent] = None
26 context_variables: dict = {}
27
28
29class Result(BaseModel):
30 """
31 Encapsulates the possible return values for an agent function.
32
33 Attributes:
34 value (str): The result value as a string.
35 agent (Agent): The agent instance, if applicable.
36 context_variables (dict): A dictionary of context variables.
37 """
38
39 value: str = ""
40 agent: Optional[Agent] = None
41 context_variables: dict = {}