From 428227d98ecd9e6b8307d267d7982be6e247b3f3 Mon Sep 17 00:00:00 2001 From: Adil Hafeez Date: Fri, 6 Dec 2024 11:54:50 -0800 Subject: [PATCH] move method to endpoint section and use Agent AI app name --- README.md | 6 +++--- arch/arch_config_schema.yaml | 10 +++++----- crates/common/src/configuration.rs | 16 ++++++++-------- crates/prompt_gateway/src/stream_context.rs | 2 +- demos/currency_exchange/arch_config.yaml | 4 ++++ demos/hr_agent/arch_config.yaml | 4 ++-- demos/insurance_agent/arch_config.yaml | 10 +++++----- demos/network_agent/arch_config.yaml | 4 ++-- demos/weather_forecast/arch_config.yaml | 4 ++-- demos/weather_forecast_signoz/arch_config.yaml | 4 ++-- docs/source/guides/includes/arch_config.yaml | 4 ++-- 11 files changed, 36 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index c09da285..bdad630e 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ To get in touch with us, please join our [discord server](https://discord.gg/pGZ ## Quickstart -Follow this quickstart guide to use arch gateway to build a simple Gen AI application. Laster in the section we will see how you can Arch Gateway to manage access keys, provide unified access to upstream LLMs and to provide e2e observability. +Follow this quickstart guide to use arch gateway to build a simple AI agent. Laster in the section we will see how you can Arch Gateway to manage access keys, provide unified access to upstream LLMs and to provide e2e observability. ### Prerequisites @@ -60,9 +60,9 @@ $ source venv/bin/activate # On Windows, use: venv\Scripts\activate $ pip install archgw==0.1.5 ``` -### Build Gen AI Application with Arch Gateway +### Build AI Agent with Arch Gateway -In following quickstart we will show you how easy it is to build gen ai application with Arch gateway. We will build a currency exchange agent using following simple steps. For this demo we will use `https://api.frankfurter.dev/` to fetch latest price for currencies and assume USD as base currency. +In following quickstart we will show you how easy it is to build AI agent with Arch gateway. We will build a currency exchange agent using following simple steps. For this demo we will use `https://api.frankfurter.dev/` to fetch latest price for currencies and assume USD as base currency. #### Step 1. Create arch config file diff --git a/arch/arch_config_schema.yaml b/arch/arch_config_schema.yaml index 82350152..6daa29e8 100644 --- a/arch/arch_config_schema.yaml +++ b/arch/arch_config_schema.yaml @@ -111,15 +111,15 @@ properties: type: string path: type: string + http_method: + type: string + enum: + - GET + - POST additionalProperties: false required: - name - path - http_method: - type: string - enum: - - GET - - POST system_prompt: type: string additionalProperties: false diff --git a/crates/common/src/configuration.rs b/crates/common/src/configuration.rs index 507ab569..0c998660 100644 --- a/crates/common/src/configuration.rs +++ b/crates/common/src/configuration.rs @@ -194,12 +194,6 @@ pub struct Parameter { pub in_path: Option, } -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct EndpointDetails { - pub name: String, - pub path: Option, -} - #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Default)] pub enum HttpMethod { #[default] @@ -218,13 +212,19 @@ impl Display for HttpMethod { } } +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct EndpointDetails { + pub name: String, + pub path: Option, + #[serde(rename = "http_method")] + pub method: Option, +} + #[derive(Debug, Clone, Serialize, Deserialize)] pub struct PromptTarget { pub name: String, pub default: Option, pub description: String, - #[serde(rename = "http_method")] - pub method: Option, pub endpoint: Option, pub parameters: Option>, pub system_prompt: Option, diff --git a/crates/prompt_gateway/src/stream_context.rs b/crates/prompt_gateway/src/stream_context.rs index e134e07c..96d82cc7 100644 --- a/crates/prompt_gateway/src/stream_context.rs +++ b/crates/prompt_gateway/src/stream_context.rs @@ -920,7 +920,7 @@ impl StreamContext { } }; - let http_method = prompt_target.method.unwrap_or_default().to_string(); + let http_method = endpoint.method.unwrap_or_default().to_string(); let mut headers = vec![ (ARCH_UPSTREAM_HOST_HEADER, endpoint.name.as_str()), (":method", &http_method), diff --git a/demos/currency_exchange/arch_config.yaml b/demos/currency_exchange/arch_config.yaml index b7d1aaed..64e0f253 100644 --- a/demos/currency_exchange/arch_config.yaml +++ b/demos/currency_exchange/arch_config.yaml @@ -46,3 +46,7 @@ endpoints: frankfurther_api: endpoint: api.frankfurter.dev:443 protocol: https + +tracing: + random_sampling: 100 + trace_arch_internal: true diff --git a/demos/hr_agent/arch_config.yaml b/demos/hr_agent/arch_config.yaml index 3685d32b..e7bf60f2 100644 --- a/demos/hr_agent/arch_config.yaml +++ b/demos/hr_agent/arch_config.yaml @@ -31,10 +31,10 @@ system_prompt: | prompt_targets: - name: workforce description: Get workforce data like headcount and satisfaction levels by region and staffing type - http_method: POST endpoint: name: app_server path: /agent/workforce + http_method: POST parameters: - name: staffing_type type: str @@ -50,10 +50,10 @@ prompt_targets: required: false description: the snapshot day for which you want workforce data. - name: slack_message - http_method: POST endpoint: name: app_server path: /agent/slack_message + http_method: POST description: sends a slack message on a channel parameters: - name: slack_message diff --git a/demos/insurance_agent/arch_config.yaml b/demos/insurance_agent/arch_config.yaml index 3b3b27d1..607c988a 100644 --- a/demos/insurance_agent/arch_config.yaml +++ b/demos/insurance_agent/arch_config.yaml @@ -26,19 +26,19 @@ endpoints: prompt_targets: - name: policy_qa - http_method: POST endpoint: name: app_server path: /policy/qa + http_method: POST description: Handle general Q/A related to insurance. default: true - name: get_policy_coverage description: Retrieve the coverage details for a given policy type (car, boat, house, motorcycle). - http_method: POST endpoint: name: app_server path: /policy/coverage + http_method: POST parameters: - name: policy_type type: str @@ -47,10 +47,10 @@ prompt_targets: required: true - name: initiate_policy - http_method: POST endpoint: name: app_server path: /policy/initiate + http_method: POST description: Start a policy coverage for car, boat, motorcycle or house. parameters: - name: policy_type @@ -64,10 +64,10 @@ prompt_targets: required: true - name: update_claim - http_method: POST endpoint: name: app_server path: /policy/claim + http_method: POST description: Update the notes on the claim parameters: - name: claim_id @@ -80,10 +80,10 @@ prompt_targets: required: false - name: update_deductible - http_method: POST endpoint: name: app_server path: /policy/deductible + http_method: POST description: Update the deductible amount for a specific policy coverage. parameters: - name: policy_id diff --git a/demos/network_agent/arch_config.yaml b/demos/network_agent/arch_config.yaml index 1d567e53..250a1037 100644 --- a/demos/network_agent/arch_config.yaml +++ b/demos/network_agent/arch_config.yaml @@ -19,10 +19,10 @@ system_prompt: | prompt_targets: - name: device_summary description: Retrieve network statistics for specific devices within a time range - http_method: POST endpoint: name: app_server path: /agent/device_summary + http_method: POST parameters: - name: device_ids type: list @@ -34,10 +34,10 @@ prompt_targets: default: "7" - name: reboot_devices description: Reboot a list of devices - http_method: POST endpoint: name: app_server path: /agent/device_reboot + http_method: POST parameters: - name: device_ids type: list diff --git a/demos/weather_forecast/arch_config.yaml b/demos/weather_forecast/arch_config.yaml index 6ae75df6..bd8bfb57 100644 --- a/demos/weather_forecast/arch_config.yaml +++ b/demos/weather_forecast/arch_config.yaml @@ -57,18 +57,18 @@ prompt_targets: description: the temperature unit, e.g., Celsius and Fahrenheit type: str default: Fahrenheit - http_method: POST endpoint: name: weather_forecast_service path: /weather + http_method: POST - name: default_target default: true description: This is the default target for all unmatched prompts. - http_method: POST endpoint: name: weather_forecast_service path: /default_target + http_method: POST system_prompt: | You are a helpful assistant! Summarize the user's request and provide a helpful response. # if it is set to false arch will send response that it received from this prompt target to the user diff --git a/demos/weather_forecast_signoz/arch_config.yaml b/demos/weather_forecast_signoz/arch_config.yaml index 1939f830..321309b6 100644 --- a/demos/weather_forecast_signoz/arch_config.yaml +++ b/demos/weather_forecast_signoz/arch_config.yaml @@ -51,18 +51,18 @@ prompt_targets: description: the temperature unit, e.g., Celsius and Fahrenheit type: str default: Fahrenheit - http_method: POST endpoint: name: weather_forecast_service path: /weather + http_method: POST - name: default_target default: true description: This is the default target for all unmatched prompts. - http_method: POST endpoint: name: weather_forecast_service path: /default_target + http_method: POST system_prompt: | You are a helpful assistant! Summarize the user's request and provide a helpful response. # if it is set to false arch will send response that it received from this prompt target to the user diff --git a/docs/source/guides/includes/arch_config.yaml b/docs/source/guides/includes/arch_config.yaml index e22f45ca..73fdff00 100644 --- a/docs/source/guides/includes/arch_config.yaml +++ b/docs/source/guides/includes/arch_config.yaml @@ -28,10 +28,10 @@ prompt_targets: - name: information_extraction default: true description: handel all scenarios that are question and answer in nature. Like summarization, information extraction, etc. - http_method: POST endpoint: name: app_server path: /agent/summary + http_method: POST # Arch uses the default LLM and treats the response from the endpoint as the prompt to send to the LLM auto_llm_dispatch_on_response: true # override system prompt for this prompt target @@ -39,10 +39,10 @@ prompt_targets: - name: reboot_network_device description: Perform device operations like rebooting a device. - http_method: POST endpoint: name: app_server path: /agent/action + http_method: POST parameters: - name: device_id type: str