mirror of
https://github.com/katanemo/plano.git
synced 2026-06-17 15:25:17 +02:00
add ability to specify custom http headers in api endpoint
This commit is contained in:
parent
a7feb6bffb
commit
a0db504fe4
4 changed files with 24 additions and 8 deletions
|
|
@ -131,6 +131,10 @@ properties:
|
|||
enum:
|
||||
- GET
|
||||
- POST
|
||||
http_headers:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: string
|
||||
additionalProperties: false
|
||||
required:
|
||||
- name
|
||||
|
|
|
|||
|
|
@ -242,6 +242,7 @@ pub struct EndpointDetails {
|
|||
pub path: Option<String>,
|
||||
#[serde(rename = "http_method")]
|
||||
pub method: Option<HttpMethod>,
|
||||
pub http_headers: Option<HashMap<String, String>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
|
|
|||
|
|
@ -317,27 +317,35 @@ impl StreamContext {
|
|||
};
|
||||
|
||||
let http_method = endpoint.method.unwrap_or_default().to_string();
|
||||
let mut headers = vec![
|
||||
let mut headers: HashMap<_, _> = [
|
||||
(ARCH_UPSTREAM_HOST_HEADER, endpoint.name.as_str()),
|
||||
(":method", &http_method),
|
||||
(":path", &path),
|
||||
(":authority", endpoint.name.as_str()),
|
||||
("content-type", "application/json"),
|
||||
("x-envoy-max-retries", "3"),
|
||||
];
|
||||
]
|
||||
.into_iter()
|
||||
.collect();
|
||||
|
||||
if self.request_id.is_some() {
|
||||
headers.push((REQUEST_ID_HEADER, self.request_id.as_ref().unwrap()));
|
||||
headers.insert(REQUEST_ID_HEADER, self.request_id.as_ref().unwrap());
|
||||
}
|
||||
|
||||
if self.traceparent.is_some() {
|
||||
headers.push((TRACE_PARENT_HEADER, self.traceparent.as_ref().unwrap()));
|
||||
headers.insert(TRACE_PARENT_HEADER, self.traceparent.as_ref().unwrap());
|
||||
}
|
||||
|
||||
// override http headers that are set in the prompt target
|
||||
let http_headers = endpoint.http_headers.unwrap_or_default();
|
||||
for (key, value) in http_headers.iter() {
|
||||
headers.insert(key.as_str(), value.as_str());
|
||||
}
|
||||
|
||||
let call_args = CallArgs::new(
|
||||
ARCH_INTERNAL_CLUSTER_NAME,
|
||||
&path,
|
||||
headers,
|
||||
headers.into_iter().collect(),
|
||||
Some(tool_params_json_str.as_bytes()),
|
||||
vec![],
|
||||
Duration::from_secs(5),
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ listener:
|
|||
|
||||
llm_providers:
|
||||
- name: gpt-4o
|
||||
access_key: $OPENAI_API_KEY
|
||||
access_key: $OPENAI_API_KEY1
|
||||
provider_interface: openai
|
||||
model: gpt-4o
|
||||
|
||||
|
|
@ -33,6 +33,8 @@ prompt_targets:
|
|||
endpoint:
|
||||
name: frankfurther_api
|
||||
path: /v1/latest?base=USD&symbols={currency_symbol}
|
||||
http_headers:
|
||||
Authorization: "Bearer $FRANKFURT_API_KEY"
|
||||
system_prompt: |
|
||||
You are a helpful assistant. Show me the currency symbol you want to convert from USD.
|
||||
|
||||
|
|
@ -41,11 +43,12 @@ prompt_targets:
|
|||
endpoint:
|
||||
name: frankfurther_api
|
||||
path: /v1/currencies
|
||||
http_headers:
|
||||
Authorization: "Bearer $FRANKFURT_API_KEY"
|
||||
|
||||
endpoints:
|
||||
frankfurther_api:
|
||||
endpoint: api.frankfurter.dev:443
|
||||
protocol: https
|
||||
endpoint: host.docker.internal:1122
|
||||
|
||||
tracing:
|
||||
random_sampling: 100
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue