use std::time::Duration;
use serde_json::{json, Value};
use super::openai_compat::{invoke_with_engine, OpenAiCompatOptions};
const ENGINE: &str = "meshllm";
const CHAT_INTENT: &str = "urn:iicp:intent:llm:chat:v1";
pub fn default_options() -> OpenAiCompatOptions {
OpenAiCompatOptions {
base_url: "http://localhost:9337/v1".into(),
model: None,
api_key: None,
timeout: Duration::from_secs(30),
}
}
pub async fn invoke(opts: &OpenAiCompatOptions, intent: &str, payload: &Value) -> Value {
if intent != CHAT_INTENT {
return json!({
"error_code": 400,
"error_message": "MeshLLM stable backend supports llm:chat:v1 only"
});
}
invoke_with_engine(ENGINE, opts, intent, payload).await
}