mirror of
https://github.com/katanemo/plano.git
synced 2026-06-02 14:35:14 +02:00
use openai standard response in arch-fc and in gradio client (#62)
* use openai standard response in arch-fc and in gradio client also fix code bug in usage * fix int test
This commit is contained in:
parent
ed6a9139e6
commit
2cd5ec5adf
6 changed files with 89 additions and 133 deletions
|
|
@ -21,7 +21,7 @@ use public_types::common_types::open_ai::{
|
|||
StreamOptions,
|
||||
};
|
||||
use public_types::common_types::{
|
||||
BoltFCResponse, BoltFCToolsCall, EmbeddingType, ToolParameter, ToolParameters, ToolsDefinition,
|
||||
BoltFCToolsCall, EmbeddingType, ToolParameter, ToolParameters, ToolsDefinition,
|
||||
ZeroShotClassificationRequest, ZeroShotClassificationResponse,
|
||||
};
|
||||
use public_types::configuration::{Overrides, PromptTarget, PromptType};
|
||||
|
|
@ -427,9 +427,9 @@ impl StreamContext {
|
|||
let body_str = String::from_utf8(body).unwrap();
|
||||
debug!("function_resolver response str: {:?}", body_str);
|
||||
|
||||
let mut boltfc_response: BoltFCResponse = serde_json::from_str(&body_str).unwrap();
|
||||
let boltfc_response: ChatCompletionsResponse = serde_json::from_str(&body_str).unwrap();
|
||||
|
||||
let boltfc_response_str = boltfc_response.message.content.as_ref().unwrap();
|
||||
let boltfc_response_str = boltfc_response.choices[0].message.content.as_ref().unwrap();
|
||||
|
||||
let tools_call_response: BoltFCToolsCall = match serde_json::from_str(boltfc_response_str) {
|
||||
Ok(fc_resp) => fc_resp,
|
||||
|
|
@ -439,7 +439,6 @@ impl StreamContext {
|
|||
// Let's send the response back to the user to initalize lightweight dialog for parameter collection
|
||||
|
||||
// add resolver name to the response so the client can send the response back to the correct resolver
|
||||
boltfc_response.resolver_name = Some(callout_context.prompt_target_name.unwrap());
|
||||
info!("some requred parameters are missing, sending response from Bolt FC back to user for parameter collection: {}", e);
|
||||
let bolt_fc_dialogue_message = serde_json::to_string(&boltfc_response).unwrap();
|
||||
self.send_http_response(
|
||||
|
|
@ -826,7 +825,7 @@ impl HttpContext for StreamContext {
|
|||
}
|
||||
};
|
||||
|
||||
self.response_tokens += chat_completions_response.usage.completions_tokens;
|
||||
self.response_tokens += chat_completions_response.usage.completion_tokens;
|
||||
}
|
||||
|
||||
debug!(
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ use proxy_wasm_test_framework::types::{
|
|||
Action, BufferType, LogLevel, MapType, MetricType, ReturnType,
|
||||
};
|
||||
use public_types::common_types::{
|
||||
open_ai::Message, BoltFCResponse, BoltFCToolsCall, IntOrString, ToolCallDetail,
|
||||
open_ai::{ChatCompletionsResponse, Choice, Message, Usage},
|
||||
BoltFCToolsCall, IntOrString, ToolCallDetail,
|
||||
};
|
||||
use public_types::{common_types::ZeroShotClassificationResponse, configuration::Configuration};
|
||||
use serial_test::serial;
|
||||
|
|
@ -426,16 +427,20 @@ fn request_ratelimited() {
|
|||
tool_calls: tool_call_detail,
|
||||
};
|
||||
|
||||
let bolt_fc_resp = BoltFCResponse {
|
||||
model: String::from("test"),
|
||||
message: Message {
|
||||
role: String::from("system"),
|
||||
content: Some(serde_json::to_string(&boltfc_tools_call).unwrap()),
|
||||
model: None,
|
||||
let bolt_fc_resp = ChatCompletionsResponse {
|
||||
usage: Usage {
|
||||
completion_tokens: 0,
|
||||
},
|
||||
done_reason: String::from("test"),
|
||||
done: true,
|
||||
resolver_name: None,
|
||||
choices: vec![Choice {
|
||||
finish_reason: "test".to_string(),
|
||||
index: 0,
|
||||
message: Message {
|
||||
role: "system".to_string(),
|
||||
content: Some(serde_json::to_string(&boltfc_tools_call).unwrap()),
|
||||
model: None,
|
||||
},
|
||||
}],
|
||||
model: String::from("test"),
|
||||
};
|
||||
|
||||
let bolt_fc_resp_str = serde_json::to_string(&bolt_fc_resp).unwrap();
|
||||
|
|
@ -535,16 +540,20 @@ fn request_not_ratelimited() {
|
|||
tool_calls: tool_call_detail,
|
||||
};
|
||||
|
||||
let bolt_fc_resp = BoltFCResponse {
|
||||
model: String::from("test"),
|
||||
message: Message {
|
||||
role: String::from("system"),
|
||||
content: Some(serde_json::to_string(&boltfc_tools_call).unwrap()),
|
||||
model: None,
|
||||
let bolt_fc_resp = ChatCompletionsResponse {
|
||||
usage: Usage {
|
||||
completion_tokens: 0,
|
||||
},
|
||||
done_reason: String::from("test"),
|
||||
done: true,
|
||||
resolver_name: None,
|
||||
choices: vec![Choice {
|
||||
finish_reason: "test".to_string(),
|
||||
index: 0,
|
||||
message: Message {
|
||||
role: "system".to_string(),
|
||||
content: Some(serde_json::to_string(&boltfc_tools_call).unwrap()),
|
||||
model: None,
|
||||
},
|
||||
}],
|
||||
model: String::from("test"),
|
||||
};
|
||||
|
||||
let bolt_fc_resp_str = serde_json::to_string(&bolt_fc_resp).unwrap();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue