Skip to content

Commit d6e162f

Browse files
committed
updated the versions and fixed the swagger now you can access the endpoints with http://localhost:7860/swagger-ui/index.html
1 parent bbc52d6 commit d6e162f

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@
4141
<dependency>
4242
<groupId>io.github.vishalmysore</groupId>
4343
<artifactId>a2ajava</artifactId>
44-
<version>0.1.8.1</version>
44+
<version>0.1.8.2</version>
4545
</dependency>
4646
<dependency>
4747
<groupId>io.github.vishalmysore</groupId>
4848
<artifactId>tools4ai-annotations</artifactId>
49-
<version>0.0.1</version>
49+
<version>0.0.2</version>
5050
</dependency>
5151

5252

5353
<dependency>
5454
<groupId>io.github.vishalmysore</groupId>
5555
<artifactId>tools4ai</artifactId>
56-
<version>1.1.4</version>
56+
<version>1.1.5</version>
5757
<exclusions>
5858
<!-- Common Swagger/OpenAPI dependencies to exclude -->
5959
<exclusion>

src/main/java/io/github/vishalmysore/service/RaiseCustomerTicket.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.t4a.api.JavaMethodAction;
77

88
import com.t4a.detect.ActionCallback;
9+
import com.t4a.detect.ActionState;
910
import com.t4a.processor.AIProcessor;
1011
import lombok.extern.java.Log;
1112
import org.springframework.stereotype.Service;
@@ -16,16 +17,28 @@
1617
public class RaiseCustomerTicket {
1718
/**
1819
* Each action has access to AIProcessor and ActionCallback which are autowired by tools4ai
20+
* Use ThreadLocal to store the ActionCallback for the current thread if you are concerned
21+
* about concurrency issues.
1922
*/
20-
private ActionCallback callback;
23+
private static final ThreadLocal<ActionCallback> callbackThreadLocal = new ThreadLocal<>();
2124

2225
/**
2326
* Each action has access to AIProcessor and ActionCallback which are autowired by tools4ai
2427
*/
2528
private AIProcessor processor;
2629
@Action(description = "Raise a ticket for customer")
27-
public String raiseTicket(String customerName) {
28-
30+
public String raiseTicket(String customerName, String reason) {
31+
if(callbackThreadLocal.get() != null) {
32+
ActionCallback callback = callbackThreadLocal.get();
33+
log.info("callback is set "+callback);
34+
// you can call the callback to get the AIProcessor
35+
if(callback!=null) {
36+
//the spelling mistake in the message is intentional to test the callback and the ai
37+
callback.sendtStatus("raiseed ticket for will be resoved soon , t"+customerName+ " reason "+reason, ActionState.COMPLETED);
38+
}
39+
} else {
40+
log.warning("callback is not set");
41+
}
2942
return "ticket 111 raised for "+customerName;
3043
}
3144
}

0 commit comments

Comments
 (0)