Functions
prompt​
Decorator for creating a prompt.Parameters
func
(Optional
[Callable
[~P
,~T
]]) - The function to decorate. Default:None
name
(Optional
[str
]) - The name of the prompt. Default:None
sources
(Optional
[List
[FeatureView
]]) - The sources of the prompt. Default:None
rtfv_kwargs
(Any
) -
Returns
Callable
[~P
, ~T
]Example
# The simplest form without a feature dependencyfrom tecton_gen_ai.fco import prompt@prompt()def simple_prompt() -> str:return "Hello, world!"# With parameters but not a featurefrom tecton_gen_ai.utils.tecton import make_request_sourceparams = make_request_source(zip=str)@prompt(sources=[params])def prompt_with_params(params) -> str:return "Hello, you zip code " + params["zip"]# With a feature dependencyfrom tecton_gen_ai.testing import make_local_batch_feature_viewmy_bfv = make_local_batch_feature_view("my_bfv",{"user_id":"u1", "name":"Bob"},["user_id"],description="User information",)@prompt(sources=[params, my_bfv])def sys_prompt(params, my_bfv) -> str:return "Hello, " + my_bfv["name"] + " with zip code " + params["zip"]# Serve the promptfrom tecton_gen_ai.fco import AgentServiceservice = AgentService("my_service",prompts=[sys_prompt],)# Test locallyfrom tecton_gen_ai.fco import AgentClientclient = AgentClient.from_local(service)with client.set_context({"zip": "10065", "user_id": "u1"}):res = client.invoke_prompt("sys_prompt")
tool​
Decorator for creating a tool. The tool can be used by different LLMs and frameworks such as Langchain and LlamaIndex.Parameters
func
(Optional
[Callable
[~P
,~T
]]) - The function to decorate. Default:None
name
(Optional
[str
]) - The name of the tool. Default:None
sources
(Optional
[List
[FeatureView
]]) - The sources of the tool. Default:None
descripton
(Optional
[str
]) - The description of the tool. Default:None
subtype
(str
) - The subtype of the tool. Default:tool
rtfv_kwargs
(Any
) -
Returns
Callable
[~P
, ~T
]Example
# The simplest form without a feature dependencyfrom tecton_gen_ai.fco import tool@tool()def get_months_in_a_year() -> int:'''The total number months of a year'''return 12# With parameters but not a feature@tool()def add(a: int, b: int) -> int:'''Add two numbersArgs:a (int): The first numberb (int): The second numberReturns:int: The sum of the two numbers'''return a + b# With a feature dependencyfrom tecton_gen_ai.testing import make_local_batch_feature_viewmy_bfv = make_local_batch_feature_view("my_bfv",{"user_id":"u1", "name":"Bob"},["user_id"],description="User information",)@tool(sources=[my_bfv])def get_name(prefix:str, user_id:str, my_bfv) -> str:'''Get the name of a user with a prefixArgs:prefix (str): The prefix of the nameuser_id (str): The user IDReturns:str: The name of the user with the prefix'''return prefix + " " + my_bfv["name"]# Serve the toolfrom tecton_gen_ai.fco import AgentServiceservice = AgentService("my_service",tools=[get_name],)# Test locallyfrom tecton_gen_ai.fco import AgentClientclient = AgentClient.from_local(service)with client.set_context({"user_id": "u1", "prefix": "Hello"}):res = client.invoke_tool("get_name")