pub struct Web { /* private fields */ }Expand description
A Plugin that gives a run web access: one tool that fetches a page and one that searches the web.
Its id is promptforge/web. promptforge/web/fetch fetches a URL
through a hardened HTTP client and returns its content as text, with
an HTML page rendered as markdown. promptforge/web/search runs a
search through the Host’s SearchProvider.
It needs two services: the search provider registered under the key
SEARCH_PROVIDER and the tokio runtime handle registered under the
key TOKIO_RUNTIME. A run that requires the Plugin is refused
when either service is missing. A run that declares it optional gets
the web tools only when both services are present.
Implementations§
Source§impl Web
impl Web
Sourcepub fn new() -> Web
pub fn new() -> Web
Builds the Plugin with the default fetch policy.
The HTTP client is built here, once, and every run’s fetch tool shares it.
§Panics
Panics only if the built-in Plugin id promptforge/web fails to
parse, or if the HTTP client fails to build for the default policy
because the TLS backend failed to initialize. Either would be a
defect outside the caller’s control.
Sourcepub fn with_fetch_config(self, config: FetchConfig) -> Result<Web, ConfigError>
pub fn with_fetch_config(self, config: FetchConfig) -> Result<Web, ConfigError>
Replaces the default fetch policy with a validated custom one.
§Errors
Returns ConfigError if the HTTP client fails to build for
config (for example a TLS backend that fails to initialize).
Trait Implementations§
Source§impl Plugin for Web
impl Plugin for Web
Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§fn needs(&self) -> &[ServiceId]
fn needs(&self) -> &[ServiceId]
RunServices]. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for Web
impl !UnwindSafe for Web
impl Freeze for Web
impl Send for Web
impl Sync for Web
impl Unpin for Web
impl UnsafeUnpin for Web
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more