Fixed multiline handling, and did a cargo fmt.

This commit is contained in:
Micheal Smith
2025-10-31 05:34:34 -05:00
parent 138df60661
commit 9719d9203c
4 changed files with 16 additions and 17 deletions

View File

@@ -31,10 +31,7 @@ pub struct Chat {
// Need: owners, channels, username, nick, server, password
#[instrument]
pub async fn new(
settings: &MainConfig,
handle: &LLMHandle,
) -> Result<Chat> {
pub async fn new(settings: &MainConfig, handle: &LLMHandle) -> Result<Chat> {
// Going to just assign and let the irc library handle errors for now, and
// add my own checking if necessary.
let port: u16 = settings.get("port")?;
@@ -81,13 +78,20 @@ impl Chat {
if let Command::PRIVMSG(channel, message) = message.command
&& message.starts_with("!gem")
{
let msg = self.llm_handle.send_request(message).await?;
event!(Level::INFO, "Message received.");
let msg = self.llm_handle.send_request(&message).await?;
event!(Level::INFO, "Asked: {}", message);
event!(Level::INFO, "Answered: {}", msg);
// Send responses as one PRIVMSG per line.
let mut lines = msg.lines();
while let Some(line) = lines.next() {
client
.send_privmsg(channel, msg)
.send_privmsg(&channel, line)
.wrap_err("Couldn't send response to channel.")?;
}
}
}
Ok(())
}

View File

@@ -1,6 +1,7 @@
use color_eyre::Result;
use std::{
path::{Path, PathBuf},
use std::path::{
Path,
PathBuf,
};
#[derive(Clone, Debug)]

View File

@@ -43,7 +43,6 @@ async fn main() -> Result<()> {
fs::chroot(&chroot_path)
.wrap_err_with(|| format!("Failed setting chroot '{}'", chroot_path))?;
std::env::set_current_dir("/").wrap_err("Couldn't change directory after chroot.")?;
}
// Setup root path for commands.

View File

@@ -70,11 +70,6 @@ impl LLMHandle {
while let Some(Ok(stream_event)) = stream.next().await {
if let ChatStreamEvent::Chunk(StreamChunk { content }) = stream_event {
text.push_str(&content);
} else if let ChatStreamEvent::End(end) = stream_event {
let texts = end.captured_texts().unwrap();
for text in texts.into_iter() {
info!("An answer: {}", text);
}
}
}