Skip to content

Commit 75f487f

Browse files
committed
Conversation first commit
Signed-off-by: Siri Varma Vegiraju <[email protected]> Signed-off-by: sirivarma <[email protected]>
1 parent d6c14de commit 75f487f

File tree

12 files changed

+614
-1
lines changed

12 files changed

+614
-1
lines changed

examples/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@
119119
<artifactId>dapr-sdk</artifactId>
120120
<version>${project.version}</version>
121121
</dependency>
122+
<dependency>
123+
<groupId>io.dapr</groupId>
124+
<artifactId>dapr-sdk-ai</artifactId>
125+
<version>${project.version}</version>
126+
</dependency>
122127
<dependency>
123128
<groupId>com.evanlennick</groupId>
124129
<artifactId>retry4j</artifactId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package io.dapr.examples.conversation;
2+
3+
import io.dapr.ai.client.DaprConversationClient;
4+
import io.dapr.ai.client.DaprConversationInput;
5+
import io.dapr.ai.client.DaprConversationResponse;
6+
import io.dapr.v1.DaprProtos;
7+
import reactor.core.publisher.Mono;
8+
9+
import java.util.ArrayList;
10+
import java.util.Collections;
11+
12+
public class DemoConversationAI {
13+
/**
14+
* The main method to start the client.
15+
*
16+
* @param args Input arguments (unused).
17+
*/
18+
public static void main(String[] args) {
19+
try (DaprConversationClient client = new DaprConversationClient(null)) {
20+
DaprConversationInput daprConversationInput = new DaprConversationInput("11");
21+
22+
// Component name is the name provided in the metadata block of the conversation.yaml file.
23+
Mono<DaprConversationResponse> instanceId = client.converse("openai", new ArrayList<>(Collections.singleton(daprConversationInput)), "1234", false, 0.0d);
24+
System.out.printf("Started a new chaining model workflow with instance ID: %s%n", instanceId);
25+
DaprConversationResponse response = instanceId.block();
26+
27+
System.out.println(response);
28+
} catch (Exception e) {
29+
throw new RuntimeException(e);
30+
}
31+
}
32+
}

pom.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<grpc.version>1.69.0</grpc.version>
1818
<protobuf.version>3.25.5</protobuf.version>
1919
<protocCommand>protoc</protocCommand>
20-
<dapr.proto.baseurl>https://raw.githubusercontent.com/dapr/dapr/v1.14.4/dapr/proto</dapr.proto.baseurl>
20+
<dapr.proto.baseurl>https://raw.githubusercontent.com/dapr/dapr/v1.15.2/dapr/proto</dapr.proto.baseurl>
2121
<dapr.sdk.version>1.15.0-SNAPSHOT</dapr.sdk.version>
2222
<dapr.sdk.alpha.version>0.15.0-SNAPSHOT</dapr.sdk.alpha.version>
2323
<os-maven-plugin.version>1.7.1</os-maven-plugin.version>
@@ -333,6 +333,7 @@
333333
<module>sdk-autogen</module>
334334
<module>sdk</module>
335335
<module>sdk-actors</module>
336+
<module>sdk-ai</module>
336337
<module>sdk-workflows</module>
337338
<module>sdk-springboot</module>
338339
<module>dapr-spring</module>

sdk-ai/pom.xml

+164
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
<project
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>io.dapr</groupId>
9+
<artifactId>dapr-sdk-parent</artifactId>
10+
<version>1.15.0-SNAPSHOT</version>
11+
</parent>
12+
13+
<artifactId>dapr-sdk-ai</artifactId>
14+
<packaging>jar</packaging>
15+
<version>1.15.0-SNAPSHOT</version>
16+
<name>dapr-sdk-ai</name>
17+
<description>SDK for AI on Dapr</description>
18+
19+
<properties>
20+
<maven.deploy.skip>false</maven.deploy.skip>
21+
</properties>
22+
23+
<dependencies>
24+
<dependency>
25+
<groupId>io.dapr</groupId>
26+
<artifactId>dapr-sdk</artifactId>
27+
<version>${project.parent.version}</version>
28+
</dependency>
29+
<dependency>
30+
<groupId>io.dapr</groupId>
31+
<artifactId>dapr-sdk-autogen</artifactId>
32+
<version>1.14.0-SNAPSHOT</version>
33+
<scope>compile</scope>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.mockito</groupId>
37+
<artifactId>mockito-core</artifactId>
38+
<scope>test</scope>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.mockito</groupId>
42+
<artifactId>mockito-inline</artifactId>
43+
<version>4.2.0</version>
44+
<scope>test</scope>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.junit.jupiter</groupId>
48+
<artifactId>junit-jupiter</artifactId>
49+
<scope>test</scope>
50+
</dependency>
51+
<dependency>
52+
<groupId>org.junit.vintage</groupId>
53+
<artifactId>junit-vintage-engine</artifactId>
54+
<version>5.7.0</version>
55+
<scope>test</scope>
56+
</dependency>
57+
<dependency>
58+
<groupId>com.microsoft</groupId>
59+
<artifactId>durabletask-client</artifactId>
60+
<version>1.5.0</version>
61+
</dependency>
62+
<!--
63+
manually declare durabletask-client's jackson dependencies
64+
which conflict with dapr-sdk's jackson dependencies
65+
https://github.com/microsoft/durabletask-java/blob/main/client/build.gradle#L16
66+
-->
67+
<dependency>
68+
<groupId>com.fasterxml.jackson.core</groupId>
69+
<artifactId>jackson-core</artifactId>
70+
<version>${jackson.version}</version>
71+
</dependency>
72+
<dependency>
73+
<groupId>com.fasterxml.jackson.core</groupId>
74+
<artifactId>jackson-databind</artifactId>
75+
<version>${jackson.version}</version>
76+
</dependency>
77+
<dependency>
78+
<groupId>com.fasterxml.jackson.core</groupId>
79+
<artifactId>jackson-annotations</artifactId>
80+
<version>${jackson.version}</version>
81+
</dependency>
82+
<dependency>
83+
<groupId>com.fasterxml.jackson.datatype</groupId>
84+
<artifactId>jackson-datatype-jsr310</artifactId>
85+
<version>${jackson.version}</version>
86+
</dependency>
87+
</dependencies>
88+
89+
<build>
90+
<plugins>
91+
<plugin>
92+
<groupId>org.apache.maven.plugins</groupId>
93+
<artifactId>maven-source-plugin</artifactId>
94+
<version>3.2.1</version>
95+
<executions>
96+
<execution>
97+
<id>attach-sources</id>
98+
<goals>
99+
<goal>jar-no-fork</goal>
100+
</goals>
101+
</execution>
102+
</executions>
103+
</plugin>
104+
105+
<plugin>
106+
<groupId>org.apache.maven.plugins</groupId>
107+
<artifactId>maven-javadoc-plugin</artifactId>
108+
<version>3.2.0</version>
109+
<executions>
110+
<execution>
111+
<id>attach-javadocs</id>
112+
<goals>
113+
<goal>jar</goal>
114+
</goals>
115+
</execution>
116+
</executions>
117+
</plugin>
118+
<plugin>
119+
<groupId>org.jacoco</groupId>
120+
<artifactId>jacoco-maven-plugin</artifactId>
121+
<version>0.8.11</version>
122+
<executions>
123+
<execution>
124+
<id>default-prepare-agent</id>
125+
<goals>
126+
<goal>prepare-agent</goal>
127+
</goals>
128+
</execution>
129+
<execution>
130+
<id>report</id>
131+
<phase>test</phase>
132+
<goals>
133+
<goal>report</goal>
134+
</goals>
135+
<configuration>
136+
<outputDirectory>target/jacoco-report/</outputDirectory>
137+
</configuration>
138+
</execution>
139+
<execution>
140+
<id>check</id>
141+
<goals>
142+
<goal>check</goal>
143+
</goals>
144+
<configuration>
145+
<rules>
146+
<rule>
147+
<element>BUNDLE</element>
148+
<limits>
149+
<limit>
150+
<counter>LINE</counter>
151+
<value>COVEREDRATIO</value>
152+
<minimum>80%</minimum>
153+
</limit>
154+
</limits>
155+
</rule>
156+
</rules>
157+
</configuration>
158+
</execution>
159+
160+
</executions>
161+
</plugin>
162+
</plugins>
163+
</build>
164+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package io.dapr.ai.client;
2+
3+
import reactor.core.publisher.Mono;
4+
5+
import javax.annotation.Nullable;
6+
import java.util.List;
7+
8+
/**
9+
* Defines client operations for managing Dapr AI instances.
10+
*/
11+
interface DaprAiClient {
12+
13+
/**
14+
* Method to call the Dapr Converse API.
15+
*
16+
* @param conversationComponentName name for the conversation component.
17+
* @param daprConversationInputs prompts that are part of the conversation.
18+
* @param contextId identifier of an existing chat (like in ChatGPT)
19+
* @param scrubPii data that comes from the LLM.
20+
* @param temperature to optimize from creativity or predictability.
21+
* @return @ConversationResponse.
22+
*/
23+
Mono<DaprConversationResponse> converse(
24+
String conversationComponentName,
25+
List<DaprConversationInput> daprConversationInputs,
26+
@Nullable String contextId,
27+
boolean scrubPii,
28+
double temperature);
29+
}

0 commit comments

Comments
 (0)