summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-07-17 18:30:05 +0800
committerGitHub <noreply@github.com>2024-07-17 18:30:05 +0800
commit6fdaabf9a83e8187a2443371f2615c867d4362c2 (patch)
treeb2412b425b768b4e9240fd72b385caa42b9af8c3 /src
parente81b215696b8941acbe47a449c19f6967133e551 (diff)
downloadaichat-6fdaabf9a83e8187a2443371f2615c867d4362c2.tar.gz
refactor: fetch html as markdown (#723)
Diffstat (limited to 'src')
-rw-r--r--src/config/input.rs2
-rw-r--r--src/utils/request.rs9
2 files changed, 9 insertions, 2 deletions
diff --git a/src/config/input.rs b/src/config/input.rs
index 1f00efd..46e1e74 100644
--- a/src/config/input.rs
+++ b/src/config/input.rs
@@ -73,7 +73,7 @@ impl Input {
texts.push(String::new());
}
for (path, contents) in files {
- texts.push(format!("{path}:\n``````\n{contents}\n``````\n"));
+ texts.push(format!("<!-- include: {path} -->\n\n{contents}\n"));
}
let (role, with_session, with_agent) = resolve_role(&config.read(), role);
Ok(Self {
diff --git a/src/utils/request.rs b/src/utils/request.rs
index 039bf75..585018d 100644
--- a/src/utils/request.rs
+++ b/src/utils/request.rs
@@ -108,7 +108,14 @@ pub async fn fetch(
}
None => {
let contents = res.text().await?;
- (contents, extension)
+ if extension == "html" {
+ (
+ html2text::from_read(contents.as_bytes(), usize::MAX),
+ "md".into(),
+ )
+ } else {
+ (contents, extension)
+ }
}
}
};