llmweb
是一个 Rust 库,它将无头浏览器(Headless Chrome)、Rust 的高性能异步能力与大语言模型(LLM)的强大理解力结合在一起。你只需要提供一个网址和一个你想要的数据结构(JSON Schema),llmweb
就能自动访问网页,像人一样"阅读"页面内容,并为你返回结构化的、干净的数据。
use llmweb::LlmWeb;
use serde::{Deserialize, Serialize};
use serde_json::json;
#[derive(Debug, Serialize, Deserialize)]
struct Story {
title: String,
points: f32,
by: Option<String>,
comments_url: Option<String>,
}
#[tokio::main]
async fn main() {
let schema_json = json!({
"type": "array",
"items": {
"type": "object",
"properties": {
"by": { "type": "string" },
"comments_url": { "type": "string" },
"points": { "type": "number" },
"title": { "type": "string" }
},
"required": ["by", "comments_url", "points", "title"]
}
});
let llmweb = LlmWeb::new("gemini-2.0-flash");
let structed_value: Vec<Story> = llmweb
.completion("https://news.ycombinator.com", schema_json)
.await
.unwrap();
println!("{:#?}", structed_value);
}
Github: https://github.com/zTgx/llmweb
Ext Link: https://github.com/zTgx/llmweb
1
共 0 条评论, 1 页
评论区
写评论还没有评论