aien-sovereign-core-mv
AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.
Brought by drakestapleton
aien-sovereign-core-mv / crates / aien-inference-service / tests / protocol_tests.rs
| 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | // Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | |
| 16 | use aien_inference_service::{InferenceEvent, InferenceRequest}; |
| 17 | |
| 18 | #[test] |
| 19 | fn test_inference_request_builder_and_defaults() { |
| 20 | let req = InferenceRequest::new("Hello from Sovereign Core") |
| 21 | .with_system_prompt("You are Atlas") |
| 22 | .with_max_tokens(512) |
| 23 | .with_temperature(0.2); |
| 24 | |
| 25 | assert_eq!(req.prompt, "Hello from Sovereign Core"); |
| 26 | assert_eq!(req.system_prompt.as_deref(), Some("You are Atlas")); |
| 27 | assert_eq!(req.limits.max_tokens, 512); |
| 28 | assert_eq!(req.limits.temperature, 0.2); |
| 29 | |
| 30 | let json = serde_json::to_string(&req).expect("serialize request"); |
| 31 | let deserialized: InferenceRequest = serde_json::from_str(&json).expect("deserialize request"); |
| 32 | assert_eq!(deserialized.prompt, req.prompt); |
| 33 | } |
| 34 | |
| 35 | #[test] |
| 36 | fn test_inference_event_variants() { |
| 37 | let tok_evt = InferenceEvent::Token("fragment".to_string()); |
| 38 | let json = serde_json::to_string(&tok_evt).expect("serialize token event"); |
| 39 | assert!(json.contains("\"type\":\"Token\"")); |
| 40 | |
| 41 | let comp_evt = InferenceEvent::Completed { |
| 42 | total_tokens: 10, |
| 43 | prompt_tokens: 4, |
| 44 | completion_tokens: 6, |
| 45 | }; |
| 46 | let json = serde_json::to_string(&comp_evt).expect("serialize completed event"); |
| 47 | assert!(json.contains("\"type\":\"Completed\"")); |
| 48 | } |