remove method type (#101)

This commit is contained in:
Adil Hafeez 2024-09-30 17:59:29 -07:00 committed by GitHub
parent f154bc3741
commit 2207021b9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 3 additions and 61 deletions

View file

@ -524,32 +524,17 @@ impl StreamContext {
debug!("tool_params: {}", tool_params_json_str);
let endpoint = prompt_target.endpoint.unwrap();
let mut path = endpoint.path.unwrap_or(String::from("/"));
let method = endpoint
.method
.unwrap_or(public_types::configuration::Method::Post);
let mut body = Some(tool_params_json_str.as_bytes());
if method == public_types::configuration::Method::Post {
let mut query_params = vec![];
for (key, value) in tool_params {
query_params.push(format!("{}={}", key, format!("{:?}", value)));
}
let path_args = &query_params.join("&");
path.push_str("?");
path.push_str(path_args);
} else {
body = None;
}
let path: String = endpoint.path.unwrap_or(String::from("/"));
let token_id = match self.dispatch_http_call(
&endpoint.name,
vec![
(":method", method.to_string().as_str()),
(":method", "POST"),
(":path", path.as_ref()),
(":authority", endpoint.name.as_str()),
("content-type", "application/json"),
("x-envoy-max-retries", "3"),
],
body,
Some(tool_params_json_str.as_bytes()),
vec![],
Duration::from_secs(5),
) {

View file

@ -94,7 +94,6 @@ prompt_targets:
endpoint:
name: app_server
path: "/agent/summary"
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

View file

@ -165,44 +165,6 @@ pub struct Parameter {
pub struct EndpointDetails {
pub name: String,
pub path: Option<String>,
pub method: Option<Method>,
}
#[derive(Debug, Clone, Serialize, PartialEq, Eq, Hash)]
#[serde(rename_all = "UPPERCASE")]
pub enum Method {
Get,
Post,
Put,
Delete,
}
impl ToString for Method {
fn to_string(&self) -> String {
match self {
Method::Get => "GET".to_string(),
Method::Post => "POST".to_string(),
Method::Put => "PUT".to_string(),
Method::Delete => "DELETE".to_string(),
}
}
}
impl<'de> Deserialize<'de> for Method {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
match s.to_uppercase().as_str() {
"GET" => Ok(Method::Get),
"POST" => Ok(Method::Post),
"PUT" => Ok(Method::Put),
"DELETE" => Ok(Method::Delete),
_ => Err(serde::de::Error::custom(format!("Invalid enum variant: {}", s))),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@ -284,10 +246,6 @@ mod test {
prompt_target.endpoint.as_ref().unwrap().path,
Some("/agent/summary".to_string())
);
assert_eq!(
prompt_target.endpoint.as_ref().unwrap().method.as_ref().unwrap().to_string(),
"POST".to_string()
);
let error_target = config.error_target.as_ref().unwrap();
assert_eq!(