-
Notifications
You must be signed in to change notification settings - Fork 0
Including the integration in your JaCaMo project
If you don't already have one, create a lib
folder at the root of your project.
Download this file Models.jar and save it in the folder lib
.
Right-click on the file and select Build Path/Add to Build Path
.
Create a new file at the root of the project called build.gradle
and add the following code to this file:
plugins {
id 'java'
id 'eclipse'
}
repositories {
mavenCentral()
maven {
url "http://jacamo.sourceforge.net/maven2"
allowInsecureProtocol = true }
maven { url "https://repo.gradle.org/gradle/libs-releases-local" }
maven { url "https://jitpack.io" }
maven { url "https://jade.tilab.com/maven/"}
flatDir {
dirs 'lib'
}
}
dependencies {
implementation group: 'org.jacamo' , name: 'jacamo' , version: '0.9-SNAPSHOT' , changing: true , transitive: true
implementation 'org.jason-lang:jason:2.5-SNAPSHOT'
implementation 'javax.xml.bind:jaxb-api:+'
implementation 'org.glassfish.jersey.containers:jersey-container-servlet:2.29.1'
implementation 'org.glassfish.jersey.containers:jersey-container-servlet-core:2.29.1'
implementation 'org.glassfish.jersey.inject:jersey-hk2:2.29.1'
implementation group: 'org.glassfish.jersey', name: 'jersey-bom', version: '2.29.1', ext: 'pom'
implementation 'org.glassfish.jersey.core:jersey-server:2.29.1'
implementation 'org.glassfish.jersey.core:jersey-client:2.29.1'
implementation 'org.glassfish.jersey.media:jersey-media-multipart:2.29.1'
implementation 'org.glassfish.jersey.media:jersey-media-json-jackson:2.29.1'
// containers:
implementation 'org.glassfish.jersey.containers:jersey-container-grizzly2-http:2.29.1'
implementation 'org.glassfish.grizzly:grizzly-http-server:2.4.4'
implementation 'org.apache.zookeeper:zookeeper:3.5.4-beta'
implementation 'org.apache.curator:curator-framework:4.0.1'
implementation 'org.apache.curator:curator-x-async:4.0.1'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.github.eishub:eis:v0.6.2'
implementation files('lib/Models.jar')
}
task run (type: JavaExec, dependsOn: 'classes') {
description 'runs the application'
group ' JaCaMo'
main = 'jacamo.infra.JaCaMoLauncher'
args '<yourJcmFile>.jcm'
classpath sourceSets.main.runtimeClasspath
}
sourceSets {
main {
java {
srcDir 'env'
srcDir 'agt'
}
}
}
Replace <yourJcmFile>.jcm
by the name of your file .jcm
.
Now, right-click on the project and select Configure / Add Gradle Nature
so that the eclipse understands that it needs to import the Gradle classes.
It may take some time to synchronize.
In env
create a new package with the name br.pucrs.smart.Dial4JaCa
Download the following classes and place them in the newly created package:
Instead of downloading one class at a time, you can download all the classes mentioned below compressed in this file classes.zip and unzip it to get the classes by transferring them to the folder br/pucrs/smart/Dial4JaCa
Create in env
a new package with the name br.pucrs.smart.Dial4JaCa.interfaces
, download the following class, and place it inside it.
Create a Jason agent to communicate with Dialogflow and put the following code in it:
!start.
/*
*
* Plans to communicate with Dialogflow
*
*/
+request(RequestedBy, ResponseId, IntentName, Params, Contexts)
:true
<-
.print("Request received ",IntentName," of Dialogflow");
!responder(RequestedBy, ResponseId, IntentName, Params, Contexts);
.
+!responder(RequestedBy, ResponseId, IntentName, Params, Contexts)
: (IntentName == "Call Jason Agent")
<-
reply("Hello, I am your Jason agent, how can I help you?");
.
+!responder(RequestedBy, ResponseId, IntentName, Params, Contexts)
: (IntentName == "Call Intent By Event")
<-
replyWithEvent("Answering with an event", "testEvent");
.
+!responder(RequestedBy, ResponseId, IntentName, Params, Contexts)
: (IntentName == "Intent Called By Event")
<-
reply("Answering to an intention called by an event");
.
+!responder(RequestedBy, ResponseId, IntentName, Params, Contexts)
: (IntentName == "Call With Contexts and Parameters")
<-
.print("The contexts and parameters will be listed below.");
!printContexts(Contexts);
!printParameters(Params);
reply("Hello, I'm your Jason agent, I received your contexts and parameters");
.
+!responder(RequestedBy, ResponseId, IntentName, Params, Contexts)
: (IntentName == "Call With Contexts")
<-
.print("The contexts will be listed below.");
!printContexts(Contexts);
reply("Hello, I am your Jason agent, I received your contexts");
.
+!responder(RequestedBy, ResponseId, IntentName, Params, Contexts)
: (IntentName == "Reply With Context")
<-
.print("The context will be created next.");
contextBuilder(ResponseId, "test context", "1", Context);
.print("Context created: ", Context);
replyWithContext("Hello, I am your Jason agent, and I am responding with context", Context);
.
+!responder(RequestedBy, ResponseId, IntentName, Params, Contexts)
: true
<-
reply("Sorry, I do not recognize this intention");
.
+!printContexts([]).
+!printContexts([Context|List])
<-
.print(Context);
!printContexts(List);
.
+!printParameters([]).
+!printParameters([Param|List])
<-
.print(Param)
!printParameters(List)
.
+!hello
: True
<-
.print("hello world");
.
+!start
: true
<-
.print("Sample agent enabled.")
.
{ include("$jacamoJar/templates/common-cartago.asl") }
{ include("$jacamoJar/templates/common-moise.asl") }
Include your new agent, communication artifact, and server in your file .jcm
ex.
agent sample_agent:sample_agent.asl{
focus: dial4JaCa
goals: hello
}
workspace wp{
artifact dial4JaCa:br.pucrs.smart.Dial4JaCa.Dial4JaCaArtifact
}
platform: br.pucrs.smart.Dial4JaCa.RestArtifact("--main 2181 --restPort 8080")
To run the project, open the project folder in the terminal and type the command gradle build
(this may take some time) then run the command gradle run
.
If you want to create Docker images from that application, create a new file at the root of the project called Dockerfile
and put the following code in it.
The process for creating the image is the same as in Creating Docker image
FROM alpine
ENV JAVA_HOME /usr/lib/jvm/java-1.8-openjdk
ENV JACAMO_HOME=/jacamo/build
ENV PATH $PATH:$JAVA_HOME/bin #:$JACAMO_HOME/scripts
RUN apk add --update --no-cache git gradle openjdk8-jre bash fontconfig ttf-dejavu graphviz
RUN git clone https://github.com/jacamo-lang/jacamo.git && \
cd jacamo && \
gradle config
COPY . /app
RUN cd app && gradle build
EXPOSE 3271
EXPOSE 3272
EXPOSE 3273
EXPOSE 8080
WORKDIR /app
ENTRYPOINT [ "gradle", "run" ]
CMD []
-
First steps
-
Dialogflow
-
Localhost test
-
Deploy
-
Existing Projects