tool
¶
ASSISTANT_ROLE
module-attribute
¶
ASSISTANT_ROLE = MessageRole(ASSISTANT)
The assistant role with name not specified.
MaybeOneOrMany
module-attribute
¶
A type that can be either a single item, a sequence of items, or None.
OneOrMany
module-attribute
¶
A type that can be either a single item or a sequence of items.
SYSTEM_ROLE
module-attribute
¶
SYSTEM_ROLE = MessageRole(SYSTEM)
The system role with name not specified.
StrOrImg
module-attribute
¶
A type that can be either a string or an image.
String
module-attribute
¶
String = Union[StringFuture, str]
String is a type alias for StringFuture or str.
BaseTool
¶
Bases: BaseModel
, ABC
The base class for a Tool.
Source code in src/appl/core/tool.py
examples
class-attribute
instance-attribute
¶
examples: List[str] = Field(
[], description="The examples of the Tool"
)
The examples of the Tool.
info
class-attribute
instance-attribute
¶
Additional information of the Tool.
long_desc
class-attribute
instance-attribute
¶
long_desc: str = Field(
"", description="The long description of the Tool"
)
The long description of the Tool.
name
class-attribute
instance-attribute
¶
name: str = Field(..., description='The name of the Tool')
The name of the Tool.
params
class-attribute
instance-attribute
¶
params: type[BaseModel] = Field(
..., description="The parameters of the Tool"
)
The parameters of the Tool.
raises
class-attribute
instance-attribute
¶
raises: List[Dict[str, Optional[str]]] = Field(
[], description="The exceptions raised by the Tool"
)
The exceptions raised by the Tool.
returns
class-attribute
instance-attribute
¶
returns: type[BaseModel] = Field(
..., description="The return of the Tool"
)
The return of the Tool.
short_desc
class-attribute
instance-attribute
¶
short_desc: str = Field(
"", description="The short description of the Tool"
)
The short description of the Tool.
parse_data
classmethod
¶
parse_data(
sig: Signature,
docstring: Optional[str],
predefined: Dict[str, Any],
) -> Dict[str, Any]
Parse data from the signature and docstring of a function.
Source code in src/appl/core/tool.py
CallFuture
¶
CallFuture(
func: Callable,
*args: Any,
use_process: bool = False,
lazy_eval: bool = False,
**kwargs: Any
)
Bases: FutureValue
Represent a function call that may not be ready yet.
Parameters:
-
func
(Callable
) –The function to call.
-
*args
(Any
, default:()
) –The arguments of the function.
-
use_process
(bool
, default:False
) –Whether to use a process pool executor.
-
lazy_eval
(bool
, default:False
) –Whether to delay the start of the call until needed.
-
**kwargs
(Any
, default:{}
) –The keyword arguments of the function.
Source code in src/appl/core/types/futures.py
CmpStringFuture
¶
CmpStringFuture(
a: StringFuture,
b: StringFuture,
op: Callable[[str, str], bool],
)
Bases: FutureValue
Represent a comparison between a StringFuture and another value.
Source code in src/appl/core/types/futures.py
ContentList
¶
Bases: BaseModel
Represent a list of contents containing text and images.
append
¶
append(content: StrOrImg) -> None
Append a content to the list.
If the last content is a string, it will be concatenated with the new content.
Source code in src/appl/core/types/content.py
extend
¶
get_contents
¶
get_contents() -> List[Dict[str, Any]]
Return the contents as a list of dictionaries.
Source code in src/appl/core/types/content.py
FutureValue
¶
Bases: ABC
Represents a value that may not be ready yet.
Image
¶
Bases: BaseModel
Represent an image in the message.
See the guide for more information about the detail level.
Source code in src/appl/core/types/content.py
from_file
classmethod
¶
Construct an image prompt from an image file.
from_image
classmethod
¶
Construct an image prompt from a PIL ImageFile.
Source code in src/appl/core/types/content.py
MessageRole
¶
ResponseType
¶
The type of generation response.
UNFINISHED
class-attribute
instance-attribute
¶
The response is not finished.
StringFuture
¶
StringFuture(content: Any = '', set_value: bool = False)
Bases: FutureValue
, BaseModel
StringFuture is a string that may not be ready yet.
Source code in src/appl/core/types/futures.py
from_list
classmethod
¶
from_list(content: List[Any]) -> StringFuture
join
¶
join(iterable: Iterable[StringFuture]) -> StringFuture
Concatenate any number of strings.
The StringFuture whose method is called is inserted in between each given StringFuture. The result is returned as a new StringFuture.
Source code in src/appl/core/types/futures.py
materialized
¶
materialized() -> StringFuture
Tool
¶
Tool(
func: Callable,
use_short_desc: bool = False,
**kwargs: Any
)
Bases: BaseTool
The Tool class that can be called by LLMs.
Parameters:
-
func
(Callable
) –The function to create the tool from.
-
use_short_desc
(bool
, default:False
) –Whether to use the short description instead of the full description.
-
kwargs
(Any
, default:{}
) –Additional arguments for the tool.
Source code in src/appl/core/tool.py
examples
class-attribute
instance-attribute
¶
examples: List[str] = Field(
[], description="The examples of the Tool"
)
The examples of the Tool.
info
class-attribute
instance-attribute
¶
Additional information of the Tool.
long_desc
class-attribute
instance-attribute
¶
long_desc: str = Field(
"", description="The long description of the Tool"
)
The long description of the Tool.
name
class-attribute
instance-attribute
¶
name: str = Field(..., description='The name of the Tool')
The name of the Tool.
params
class-attribute
instance-attribute
¶
params: type[BaseModel] = Field(
..., description="The parameters of the Tool"
)
The parameters of the Tool.
raises
class-attribute
instance-attribute
¶
raises: List[Dict[str, Optional[str]]] = Field(
[], description="The exceptions raised by the Tool"
)
The exceptions raised by the Tool.
returns
class-attribute
instance-attribute
¶
returns: type[BaseModel] = Field(
..., description="The return of the Tool"
)
The return of the Tool.
short_desc
class-attribute
instance-attribute
¶
short_desc: str = Field(
"", description="The short description of the Tool"
)
The short description of the Tool.
parse_data
classmethod
¶
parse_data(
sig: Signature,
docstring: Optional[str],
predefined: Dict[str, Any],
) -> Dict[str, Any]
Parse data from the signature and docstring of a function.
Source code in src/appl/core/tool.py
ToolCall
¶
Bases: BaseModel
The class representing a tool call.
args
class-attribute
instance-attribute
¶
args: str = Field(
...,
description="The arguments to call the function with.",
)
The arguments to call the function with.
id
class-attribute
instance-attribute
¶
id: str = Field(..., description="The ID of the tool call.")
The ID of the tool call.
name
class-attribute
instance-attribute
¶
name: str = Field(
..., description="The name of the function to call."
)
The name of the function to call.
from_dict
classmethod
¶
from_dict(call: Dict) -> ToolCall
Create a ToolCall from a dictionary in the OpenAI format.
Source code in src/appl/core/tool.py
from_openai_tool_call
classmethod
¶
from_openai_tool_call(
call: ChatCompletionMessageToolCall,
) -> ToolCall
Create a ToolCall from an OpenAI tool call.
get_dict
¶
Get the OpenAI format dictionary representation of the tool call.