mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-12 05:49:00 +08:00
feat(rust-sdk): add agent options
This commit is contained in:
parent
f2c01340d1
commit
ec3d679c5b
@ -6,6 +6,14 @@ use serde_json::Value;
|
||||
|
||||
use crate::{FirecrawlApp, FirecrawlError, API_VERSION};
|
||||
|
||||
/// Agent options for extract requests
|
||||
#[derive(Deserialize, Serialize, Debug, Default, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AgentOptionsExtract {
|
||||
/// Model to use for the agent
|
||||
pub model: String,
|
||||
}
|
||||
|
||||
/// Parameters for extract requests
|
||||
#[serde_with::skip_serializing_none]
|
||||
#[derive(Deserialize, Serialize, Debug, Default, Clone)]
|
||||
@ -50,6 +58,9 @@ pub struct ExtractParams {
|
||||
/// Maximum number of URLs to process
|
||||
pub limit: Option<u32>,
|
||||
|
||||
/// Agent options
|
||||
pub agent: Option<AgentOptionsExtract>,
|
||||
|
||||
/// Experimental: Stream steps information
|
||||
#[serde(rename = "__experimental_streamSteps")]
|
||||
pub experimental_stream_steps: Option<bool>,
|
||||
|
@ -37,22 +37,42 @@ pub enum ScrapeFormats {
|
||||
|
||||
/// Will result in the results of an LLM extraction.
|
||||
///
|
||||
/// See `ScrapeOptions.extract` for more options.
|
||||
#[serde(rename = "extract")]
|
||||
Extract,
|
||||
/// See `ScrapeOptions.json_options` for more options.
|
||||
#[serde(rename = "json")]
|
||||
Json,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug, Default, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AgentOptionsJson {
|
||||
pub model: String,
|
||||
pub prompt: Option<String>,
|
||||
}
|
||||
|
||||
#[serde_with::skip_serializing_none]
|
||||
#[derive(Deserialize, Serialize, Debug, Default, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ExtractOptions {
|
||||
pub struct JsonOptions {
|
||||
/// Schema the output should adhere to, provided in JSON Schema format.
|
||||
pub schema: Option<Value>,
|
||||
|
||||
/// System prompt to send to the LLM agent along with the page content.
|
||||
pub system_prompt: Option<String>,
|
||||
|
||||
/// Extraction prompt to send to the LLM agent along with the page content.
|
||||
pub prompt: Option<String>,
|
||||
|
||||
/// Agent options for JSON extraction.
|
||||
pub agent: Option<AgentOptionsJson>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug, Default, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AgentOptions {
|
||||
pub model: String,
|
||||
pub prompt: Option<String>,
|
||||
pub session_id: Option<String>,
|
||||
pub wait_before_closing_ms: Option<u32>,
|
||||
}
|
||||
|
||||
#[serde_with::skip_serializing_none]
|
||||
@ -84,8 +104,11 @@ pub struct ScrapeOptions {
|
||||
// Timeout before returning an error, in milliseconds. (default: `60000`)
|
||||
pub timeout: Option<u32>,
|
||||
|
||||
/// Extraction options, to be used in conjunction with `ScrapeFormats::Extract`.
|
||||
pub extract: Option<ExtractOptions>,
|
||||
/// JSON extraction options, to be used in conjunction with `ScrapeFormats::Json`.
|
||||
pub json_options: Option<JsonOptions>,
|
||||
|
||||
/// Agent options for smart scrape.
|
||||
pub agent: Option<AgentOptions>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug, Default)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user