pub struct CloudflareAgent { /* private fields */ }Expand description
AI Agent for Cloudflare Workers
Provides chat functionality with optional KV-based conversation persistence.
Implementations§
Source§impl CloudflareAgent
impl CloudflareAgent
Sourcepub fn new(config: CloudflareConfig) -> Self
pub fn new(config: CloudflareConfig) -> Self
Create a new Cloudflare agent with the given configuration
Sourcepub async fn chat(
&mut self,
message: &str,
) -> Result<AgentResponse, CloudflareError>
pub async fn chat( &mut self, message: &str, ) -> Result<AgentResponse, CloudflareError>
Send a message and get a response (non-streaming)
Sourcepub async fn chat_with_session(
&mut self,
session_id: &str,
message: &str,
) -> Result<AgentResponse, CloudflareError>
pub async fn chat_with_session( &mut self, session_id: &str, message: &str, ) -> Result<AgentResponse, CloudflareError>
Send a message with session persistence
Sourcepub async fn chat_stream(
&mut self,
message: &str,
) -> Result<Response, CloudflareError>
pub async fn chat_stream( &mut self, message: &str, ) -> Result<Response, CloudflareError>
Send a message and get a streaming response
Sourcepub fn clear_history(&mut self)
pub fn clear_history(&mut self)
Clear conversation history (keeps system prompt)
Auto Trait Implementations§
impl Freeze for CloudflareAgent
impl RefUnwindSafe for CloudflareAgent
impl Send for CloudflareAgent
impl Sync for CloudflareAgent
impl Unpin for CloudflareAgent
impl UnsafeUnpin for CloudflareAgent
impl UnwindSafe for CloudflareAgent
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
Mutably borrows from an owned value. Read more