pub struct RhaiScriptPromptPlugin { /* private fields */ }Expand description
基于 Rhai 脚本的 Prompt 模板插件
Implementations§
Source§impl RhaiScriptPromptPlugin
impl RhaiScriptPromptPlugin
Sourcepub fn new(script_path: impl Into<PathBuf>) -> RhaiScriptPromptPlugin
pub fn new(script_path: impl Into<PathBuf>) -> RhaiScriptPromptPlugin
创建新的 Rhai 脚本 Prompt 模板插件
Sourcepub async fn set_active_scenario(&self, scenario: impl Into<String>)
pub async fn set_active_scenario(&self, scenario: impl Into<String>)
设置当前活动的场景
Sourcepub async fn get_current_template(&self) -> Option<Arc<PromptTemplate>>
pub async fn get_current_template(&self) -> Option<Arc<PromptTemplate>>
获取当前活动场景的模板
Sourcepub fn script_path(&self) -> &PathBuf
pub fn script_path(&self) -> &PathBuf
获取脚本文件夹路径
Trait Implementations§
Source§impl AgentPlugin for RhaiScriptPromptPlugin
impl AgentPlugin for RhaiScriptPromptPlugin
Source§fn metadata(&self) -> &PluginMetadata
fn metadata(&self) -> &PluginMetadata
获取插件元数据
Source§fn state(&self) -> PluginState
fn state(&self) -> PluginState
获取插件状态
Source§fn load<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
RhaiScriptPromptPlugin: 'async_trait,
fn load<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
RhaiScriptPromptPlugin: 'async_trait,
插件加载(分配资源)
Source§fn init_plugin<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
RhaiScriptPromptPlugin: 'async_trait,
fn init_plugin<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
RhaiScriptPromptPlugin: 'async_trait,
插件初始化(配置初始化)
Source§fn start<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
RhaiScriptPromptPlugin: 'async_trait,
fn start<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
RhaiScriptPromptPlugin: 'async_trait,
插件启动
Source§fn stop<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
RhaiScriptPromptPlugin: 'async_trait,
fn stop<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
RhaiScriptPromptPlugin: 'async_trait,
插件停止
Source§fn unload<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
RhaiScriptPromptPlugin: 'async_trait,
fn unload<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
RhaiScriptPromptPlugin: 'async_trait,
插件卸载(释放资源)
Source§fn execute<'life0, 'async_trait>(
&'life0 mut self,
input: String,
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
RhaiScriptPromptPlugin: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 mut self,
input: String,
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
RhaiScriptPromptPlugin: 'async_trait,
执行插件功能
Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
转换为可变 Any
Source§fn plugin_type(&self) -> PluginType
fn plugin_type(&self) -> PluginType
获取插件类型
Source§fn pause<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn pause<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
插件暂停
Source§fn resume<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn resume<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
插件恢复
Source§impl PromptTemplatePlugin for RhaiScriptPromptPlugin
impl PromptTemplatePlugin for RhaiScriptPromptPlugin
Source§fn get_prompt_template<'life0, 'life1, 'async_trait>(
&'life0 self,
scenario: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<Arc<PromptTemplate>>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
RhaiScriptPromptPlugin: 'async_trait,
fn get_prompt_template<'life0, 'life1, 'async_trait>(
&'life0 self,
scenario: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<Arc<PromptTemplate>>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
RhaiScriptPromptPlugin: 'async_trait,
获取当前场景的 Prompt 模板
Source§fn get_active_scenario<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = String> + Send + 'async_trait>>where
'life0: 'async_trait,
RhaiScriptPromptPlugin: 'async_trait,
fn get_active_scenario<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = String> + Send + 'async_trait>>where
'life0: 'async_trait,
RhaiScriptPromptPlugin: 'async_trait,
获取当前活动场景
Source§fn set_active_scenario<'life0, 'life1, 'async_trait>(
&'life0 self,
scenario: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
RhaiScriptPromptPlugin: 'async_trait,
fn set_active_scenario<'life0, 'life1, 'async_trait>(
&'life0 self,
scenario: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
RhaiScriptPromptPlugin: 'async_trait,
设置当前活动的场景
Source§fn get_available_scenarios<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<String>> + Send + 'async_trait>>where
'life0: 'async_trait,
RhaiScriptPromptPlugin: 'async_trait,
fn get_available_scenarios<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<String>> + Send + 'async_trait>>where
'life0: 'async_trait,
RhaiScriptPromptPlugin: 'async_trait,
获取所有可用的场景
Source§fn refresh_templates<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
RhaiScriptPromptPlugin: 'async_trait,
fn refresh_templates<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
RhaiScriptPromptPlugin: 'async_trait,
刷新模板
Source§fn get_current_template<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Option<Arc<PromptTemplate>>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn get_current_template<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Option<Arc<PromptTemplate>>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
获取当前活动场景的模板
Auto Trait Implementations§
impl !Freeze for RhaiScriptPromptPlugin
impl !RefUnwindSafe for RhaiScriptPromptPlugin
impl Send for RhaiScriptPromptPlugin
impl Sync for RhaiScriptPromptPlugin
impl Unpin for RhaiScriptPromptPlugin
impl UnsafeUnpin for RhaiScriptPromptPlugin
impl !UnwindSafe for RhaiScriptPromptPlugin
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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>
Converts
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>
Converts
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 moreSource§impl<T> Message for T
impl<T> Message for T
Source§fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
Convert a BoxedMessage to this concrete type
Source§fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
Convert this message to a BoxedMessage