Implement chat and markdown views, enhance status bar, and add workflow panel

- Added `chat.rs` for rendering chat messages with timestamps and roles.
- Introduced `markdown.rs` for rendering markdown content with styling.
- Created `status.rs` to display the application status bar with session and message counts.
- Developed `workflow.rs` to show the current workflow status, including tool calls and active jobs.
- Established a `theme.rs` for centralized color management across the UI.
- Updated `mod.rs` to include new modules and manage rendering logic.
This commit is contained in:
asepharyana
2026-07-11 13:16:10 +07:00
parent 7cb4ae6708
commit cc03bd79b6
131 changed files with 10994 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
pub mod openrouter;
+53
View File
@@ -0,0 +1,53 @@
use anyhow::Result;
use serde_json::Value;
pub struct OpenRouterClient {
pub client: reqwest::blocking::Client,
pub api_key: String,
pub base_url: String,
pub model: String,
}
impl OpenRouterClient {
pub fn new(api_key: String, model: String) -> Self {
OpenRouterClient {
client: reqwest::blocking::Client::new(),
api_key,
base_url: "https://openrouter.ai/api/v1".to_string(),
model,
}
}
pub fn chat(&self, messages: &[crate::dto::chat::message::ChatMessage]) -> Result<String> {
let req = crate::dto::openrouter::request::ChatRequest {
model: self.model.clone(),
messages: messages.to_vec(),
max_tokens: Some(4096),
temperature: Some(0.7),
tools: None,
stream: Some(false),
top_p: None,
stop: None,
};
let resp = self.client
.post(format!("{}/chat/completions", self.base_url))
.header("Authorization", format!("Bearer {}", self.api_key))
.header("Content-Type", "application/json")
.json(&req)
.send()?;
if !resp.status().is_success() {
let status = resp.status();
let body = resp.text().unwrap_or_default();
anyhow::bail!("OpenRouter API error {}: {}", status, body);
}
let data: Value = resp.json()?;
let content = data["choices"][0]["message"]["content"]
.as_str()
.unwrap_or("")
.to_string();
Ok(content)
}
}