Action examples

    You can use artificial intelligence related services in actions. The example of action in the GIF video below is a chat service.

The following is the sample action model code.

<?xml version='1.0' encoding='utf-8'?>

<Chat name="TestChat" descriptors="xworker.lang.ai.AiActions/@Chat" stream="true" chatService="_local.thinglibs.p2023.p09.p21.BaiduChatService">
     <Prompt>
         <Message name="Message" content="Tell me a story."/>
     </Prompt>
     <actions>
         <GroovyAction name="onResult" descriptors="xworker.groovy.GroovyAction" code="print result.getContent();"/>
         <GroovyAction name="onError" code="println errorId + &quot; : &quot; errorMsg;"/>
         <GroovyAction name="onException" code="e.printStackTrace();"/>
         <GroovyAction name="onStreamRequestFinished" code="println &quot;&quot;;"/>
         <GroovyAction name="onStreamResult" code="print result.getContent();"/>
     </actions>
</Chat>

 

Copyright ©  2007-2019 XWorker.org  版权所有  沪ICP备08000575号