llmsmith.agent.function package
Subpackages
- llmsmith.agent.function.options package
- Submodules
- llmsmith.agent.function.options.openai module
OpenAIAssistantOptionsOpenAIAssistantOptions.descriptionOpenAIAssistantOptions.extra_bodyOpenAIAssistantOptions.extra_headersOpenAIAssistantOptions.extra_queryOpenAIAssistantOptions.metadataOpenAIAssistantOptions.modelOpenAIAssistantOptions.nameOpenAIAssistantOptions.response_formatOpenAIAssistantOptions.system_promptOpenAIAssistantOptions.temperatureOpenAIAssistantOptions.timeoutOpenAIAssistantOptions.tool_resourcesOpenAIAssistantOptions.top_p
- Module contents
Submodules
llmsmith.agent.function.cohere module
- class llmsmith.agent.function.cohere.CohereFunctionAgent(name: str, llm: AsyncClient, llm_options: CohereTextGenOptions, tools: List[CohereTool] = [], max_turns: int = 5)
Bases:
Task[str,str]Agent based on function calling capability of Cohere LLMs. Agent will loop until one of the conditions are met:
If the LLM does not choose any tools (function) and simply returns text content in the response.
If maximum number of turns are reached in the agent loop.
- Parameters:
name (str) – The name of the task.
llm (
cohere.AsyncClient) – An instance of the Cohere client.llm_options (
llmsmith.task.textgen.options.cohere.CohereTextGenOptions, optional) – A dictionary of options to pass to the Cohere LLM.tools (
llmsmith.agent.tool.cohere.CohereTool) – List of tools (functions) which can be used by the Cohere LLMs. Each tool contains both the declaration and the actual callable.max_turns (str) – Maximum number of turns allowed in the agent loop. Defaults to 5.
- Raises:
ValueError – If the name is empty or if max_turns is less than 1.
- async execute(task_input: TaskInput[str]) TaskOutput[str]
Executes the agent by running the loop. The agent exits the loop and returns the LLM response only if no more function calls are required.
- Parameters:
task_input (
llmsmith.task.models.TaskInput[str]) – The input to the agent task.- Raises:
ValueError – If the content of the task input is not a string.
PromptBlockedError – If the prompt is blocked by the AI.
TextGenFailedError – If AI fails to generate text based on the prompt.
MaxTurnsReachedException – If maximum number of turns are reached in the agent loop.
- Returns:
The output of the task.
- Return type:
llmsmith.task.models.TaskOutput[str]
llmsmith.agent.function.gemini module
- class llmsmith.agent.function.gemini.GeminiFunctionAgent(name: str, llm: GenerativeModel, llm_options: GeminiTextGenOptions, tools: List[GeminiTool] = [], max_turns: int = 5)
Bases:
Task[str,str]Agent based on function calling capability of Gemini LLMs. Agent will loop until one of the conditions are met:
If the LLM does not choose any tools (function) and simply returns text content in the response.
If maximum number of turns are reached in the agent loop.
- Parameters:
name (str) – The name of the task.
llm (
google.generativeai.GenerativeModel) – An instance of the Gemini client.llm_options (
llmsmith.task.textgen.options.gemini.GeminiTextGenOptions, optional) – A dictionary of options to pass to the Gemini LLM.tools (
llmsmith.agent.tool.gemini.GeminiTool) – List of tools (functions) which can be used by the Gemini LLMs. Each tool contains both the declaration and the actual callable.max_turns (str) – Maximum number of turns allowed in the agent loop. Defaults to 5.
- Raises:
ValueError – If the name is empty or if max_turns is less than 1.
- async execute(task_input: TaskInput[str]) TaskOutput[str]
Executes the agent by running the loop. The agent exits the loop and returns the LLM response only if no more function calls are required.
- Parameters:
task_input (
llmsmith.task.models.TaskInput[str]) – The input to the agent task.- Raises:
ValueError – If the content of the task input is not a string.
PromptBlockedError – If the prompt is blocked by the AI.
TextGenFailedError – If AI fails to generate text based on the prompt.
MaxTurnsReachedException – If maximum number of turns are reached in the agent loop.
- Returns:
The output of the task.
- Return type:
llmsmith.task.models.TaskOutput[str]
llmsmith.agent.function.groq module
- class llmsmith.agent.function.groq.GroqFunctionAgent(name: str, llm: AsyncGroq, llm_options: GroqTextGenOptions, tools: List[GroqTool] = [], max_turns: int = 5)
Bases:
Task[str,str]Agent based on function calling capability of LLMs in Groq. Agent will loop until one of the conditions are met:
If the LLM does not choose any tools (function) and simply returns text content in the response.
If maximum number of turns are reached in the agent loop.
- Parameters:
name (str) – The name of the task.
llm (
groq.AsyncGroq) – An instance of the async Groq client.llm_options (
llmsmith.task.textgen.options.groq.GroqTextGenOptions, optional) – A dictionary of options to pass to the LLM in Groq.tools (
llmsmith.agent.tool.groq.GroqTool) – List of tools (functions) which can be used by the LLMs in Groq. Each tool contains both the declaration and the actual callable.max_turns (str) – Maximum number of turns allowed in the agent loop. Defaults to 5.
- Raises:
ValueError – If the name is empty or if max_turns is less than 1.
- async execute(task_input: TaskInput[str]) TaskOutput[str]
Executes the agent by running the loop. The agent exits the loop and returns the LLM response only if no more function calls are required.
- Parameters:
task_input (
llmsmith.task.models.TaskInput[str]) – The input to the agent task.- Raises:
ValueError – If the content of the task input is not a string.
PromptBlockedError – If the prompt is blocked by the AI.
TextGenFailedError – If AI fails to generate text based on the prompt.
MaxTurnsReachedException – If maximum number of turns are reached in the agent loop.
- Returns:
The output of the task.
- Return type:
llmsmith.task.models.TaskOutput[str]
llmsmith.agent.function.openai module
- class llmsmith.agent.function.openai.OpenAIFunctionAgent(name: str, llm: AsyncOpenAI, assistant: Assistant, tools: List[OpenAIAssistantTool] = [], max_turns: int = 5)
Bases:
Task[str,str]Agent based on function calling capability of OpenAI LLMs. Agent will loop until one of the conditions are met:
If the LLM does not choose any tools and simply returns text content in the response.
If maximum number of turns are reached in the agent loop.
- Parameters:
name (str) – The name of the task.
llm (
openai.AsyncOpenAI) – An instance of the async OpenAI client.assistant (
openai.types.beta.Assistant) – The OpenAI assistant.tools (List[
llmsmith.agent.tool.openai.OpenAIAssistantTool]) – List of tools (file search, code interpreter, functions) which can be used by the OpenAI LLMs. Tools of function type should have the actual callable too.max_turns (str) – Maximum number of turns allowed in the agent loop. Defaults to 5.
- Raises:
ValueError – If the name is empty or if max_turns is less than 1.
- async classmethod create(name: str, llm: AsyncOpenAI, assistant_options: OpenAIAssistantOptions, tools: List[OpenAIAssistantTool] = [], max_turns: int = 5)
Factory method for creating an instance of OpenAIFunctionAgent.
- Parameters:
name (str) – The name of the task.
llm (
openai.AsyncOpenAI) – An instance of the async OpenAI client.assistant_options (
llmsmith.agent.function.options.openai.OpenAIAssistantOptions, optional) – A dictionary of options to pass to the OpenAI assistant.tools (List[
llmsmith.agent.tool.openai.OpenAIAssistantTool]) – List of tools (file search, code interpreter, functions) which can be used by the OpenAI LLMs. Tools of function type should have the actual callable too.max_turns (str) – Maximum number of turns allowed in the agent loop. Defaults to 5.
- Raises:
ValueError – If the name is empty or if max_turns is less than 1.
- async execute(task_input: TaskInput[str]) TaskOutput[str]
Executes the agent by running the loop. The agent exits the loop and returns the LLM response only if no more function calls are required.
- Parameters:
task_input (
llmsmith.task.models.TaskInput[str]) – The input to the agent task.- Raises:
ValueError – If the content of the task input is not a string.
TextGenFailedError – If AI fails to generate text based on the prompt.
MaxTurnsReachedException – If maximum number of turns are reached in the agent loop.
- Returns:
The output of the task.
- Return type:
llmsmith.task.models.TaskOutput[str]