2024-10-06 16:54:34 -07:00
.. _arch_agent_guide:
2024-09-25 23:43:34 -07:00
2024-10-06 16:54:34 -07:00
Agentic Workflow
2024-09-24 13:54:17 -07:00
==============================
2024-09-30 14:54:01 -07:00
Arch helps you easily personalize your applications by calling application-specific (API) functions
via user prompts. This involves any predefined functions or APIs you want to expose to users to perform tasks,
2024-10-10 22:30:54 -07:00
gather information, or manipulate data. This capability is generally referred to as :ref: `function calling <function_calling>` , where
2024-09-30 14:54:01 -07:00
you have the flexibility to support “agentic” apps tailored to specific use cases - from updating insurance
claims to creating ad campaigns - via prompts.
2024-09-24 13:54:17 -07:00
2024-09-30 14:54:01 -07:00
Arch analyzes prompts, extracts critical information from prompts, engages in lightweight conversation with
2024-09-24 13:54:17 -07:00
the user to gather any missing parameters and makes API calls so that you can focus on writing business logic.
2024-10-10 22:30:54 -07:00
Arch does this via its purpose-built `Arch-Function <https://huggingface.co/collections/katanemo/arch-function-66f209a693ea8df14317ad68> `_ - the fastest (200ms p90 - 10x faser than GPT-4o)
and cheapest (100x than GPT-4o) function calling LLM that matches performance with frontier models.
2024-09-24 13:54:17 -07:00
2024-10-06 16:54:34 -07:00
.. image :: includes/agent/function-calling-flow.jpg
2024-09-25 23:43:34 -07:00
:width: 100%
:align: center
2024-09-24 13:54:17 -07:00
Single Function Call
--------------------
2024-09-30 14:54:01 -07:00
In the most common scenario, users will request a single action via prompts, and Arch efficiently processes the
2024-09-24 13:54:17 -07:00
request by extracting relevant parameters, validating the input, and calling the designated function or API. Here
is how you would go about enabling this scenario with Arch:
2024-10-08 13:18:34 -07:00
Step 1: Define Prompt Targets
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2024-09-24 13:54:17 -07:00
2024-10-06 16:54:34 -07:00
.. literalinclude :: includes/agent/function-calling-agent.yaml
2024-09-24 13:54:17 -07:00
:language: yaml
:linenos:
2024-10-10 22:30:54 -07:00
:emphasize-lines: 19-49
2024-10-08 13:18:34 -07:00
:caption: Prompt Target Example Configuration
2024-09-24 13:54:17 -07:00
2024-10-08 13:18:34 -07:00
Step 2: Process Request Parameters
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2024-09-24 13:54:17 -07:00
2024-09-30 14:54:01 -07:00
Once the prompt targets are configured as above, handling those parameters is
2024-09-24 13:54:17 -07:00
2024-10-06 16:54:34 -07:00
.. literalinclude :: includes/agent/parameter_handling.py
2024-09-24 13:54:17 -07:00
:language: python
:linenos:
2024-10-06 16:54:34 -07:00
:caption: Parameter handling with Flask
2024-09-24 13:54:17 -07:00
2024-10-08 13:18:34 -07:00
Parallel & Multiple Function Calling
------------------------------------
2024-09-30 14:54:01 -07:00
In more complex use cases, users may request multiple actions or need multiple APIs/functions to be called
simultaneously or sequentially. With Arch, you can handle these scenarios efficiently using parallel or multiple
2024-09-24 13:54:17 -07:00
function calling. This allows your application to engage in a broader range of interactions, such as updating
different datasets, triggering events across systems, or collecting results from multiple services in one prompt.
2024-09-30 14:54:01 -07:00
Arch-FC1B is built to manage these parallel tasks efficiently, ensuring low latency and high throughput, even
2024-09-24 13:54:17 -07:00
when multiple functions are invoked. It provides two mechanisms to handle these cases:
2024-10-08 13:18:34 -07:00
Step 1: Define Prompt Targets
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2024-09-24 13:54:17 -07:00
2024-09-30 14:54:01 -07:00
When enabling multiple function calling, define the prompt targets in a way that supports multiple functions or
API calls based on the user's prompt. These targets can be triggered in parallel or sequentially, depending on
2024-09-24 13:54:17 -07:00
the user's intent.
2024-09-25 23:43:34 -07:00
Example of Multiple Prompt Targets in YAML:
2024-10-06 16:54:34 -07:00
.. literalinclude :: includes/agent/function-calling-agent.yaml
2024-09-25 23:43:34 -07:00
:language: yaml
:linenos:
2024-10-10 22:30:54 -07:00
:emphasize-lines: 19-49
2024-10-08 13:18:34 -07:00
:caption: Prompt Target Example Configuration