Skip to content

Commit 260fd27

Browse files
authored
Merge branch 'v1.16' into remove-go-sdk-submodule
Signed-off-by: Marc Duiker <marcduiker@users.noreply.github.com>
2 parents f33f14b + 7b2a00b commit 260fd27

File tree

39 files changed

+6055
-18
lines changed

39 files changed

+6055
-18
lines changed

.gitmodules

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
1-
[submodule "sdkdocs/python"]
2-
path = sdkdocs/python
3-
url = https://github.com/dapr/python-sdk.git
41
[submodule "sdkdocs/php"]
52
path = sdkdocs/php
63
url = https://github.com/dapr/php-sdk.git
74
[submodule "translations/docs-zh"]
85
path = translations/docs-zh
96
url = https://github.com/dapr/docs-zh.git
107
branch = v1.0_content
11-
[submodule "sdkdocs/java"]
12-
path = sdkdocs/java
13-
url = https://github.com/dapr/java-sdk.git
14-
[submodule "sdkdocs/js"]
15-
path = sdkdocs/js
16-
url = https://github.com/dapr/js-sdk.git
178
[submodule "sdkdocs/rust"]
189
path = sdkdocs/rust
1910
url = https://github.com/dapr/rust-sdk.git

hugo.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,10 @@ module:
275275
target: assets
276276
- source: daprdocs/archetypes
277277
target: archetypes
278-
- source: sdkdocs/python/daprdocs/content/en/python-sdk-docs
278+
- source: sdkdocs/python/content/en/python-sdk-docs
279279
target: content/developing-applications/sdks/python
280280
lang: en
281-
- source: sdkdocs/python/daprdocs/content/en/python-sdk-contributing
281+
- source: sdkdocs/python/content/en/python-sdk-contributing
282282
target: content/contributing/sdk-contrib/
283283
lang: en
284284
- source: sdkdocs/php/daprdocs/content/en/php-sdk-docs
@@ -296,16 +296,16 @@ module:
296296
- source: sdkdocs/go/content/en/go-sdk-contributing
297297
target: content/contributing/sdk-contrib/
298298
lang: en
299-
- source: sdkdocs/java/daprdocs/content/en/java-sdk-docs
299+
- source: sdkdocs/java/content/en/java-sdk-docs
300300
target: content/developing-applications/sdks/java
301301
lang: en
302-
- source: sdkdocs/java/daprdocs/content/en/java-sdk-contributing
302+
- source: sdkdocs/java/content/en/java-sdk-contributing
303303
target: content/contributing/sdk-contrib/
304304
lang: en
305-
- source: sdkdocs/js/daprdocs/content/en/js-sdk-docs
305+
- source: sdkdocs/js/content/en/js-sdk-docs
306306
target: content/developing-applications/sdks/js
307307
lang: en
308-
- source: sdkdocs/js/daprdocs/content/en/js-sdk-contributing
308+
- source: sdkdocs/js/content/en/js-sdk-contributing
309309
target: content/contributing/sdk-contrib/
310310
lang: en
311311
- source: sdkdocs/rust/daprdocs/content/en/rust-sdk-docs

sdkdocs/java

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
type: docs
3+
title: "Contributing to the Java SDK"
4+
linkTitle: "Java SDK"
5+
weight: 3000
6+
description: Guidelines for contributing to the Dapr Java SDK
7+
---
8+
9+
When contributing to the [Java SDK](https://github.com/dapr/java-sdk) the following rules and best-practices should be followed.
10+
11+
## Examples
12+
13+
The `examples` directory contains code samples for users to run to try out specific functionality of the various Java SDK packages and extensions. When writing new and updated samples keep in mind:
14+
15+
- All examples should be runnable on Windows, Linux, and MacOS. While Java code is consistent among operating systems, any pre/post example commands should provide options through [tabpane]({{% ref "contributing-docs.md#tabbed-content" %}})
16+
- Contain steps to download/install any required pre-requisites. Someone coming in with a fresh OS install should be able to start on the example and complete it without an error. Links to external download pages are fine.
17+
18+
## Docs
19+
20+
The `daprdocs` directory contains the markdown files that are rendered into the [Dapr Docs](https://docs.dapr.io) website. When the documentation website is built, this repo is cloned and configured so that its contents are rendered with the docs content. When writing docs, keep in mind:
21+
22+
- All rules in the [docs guide]({{% ref contributing-docs.md %}}) should be followed in addition to these.
23+
- All files and directories should be prefixed with `java-` to ensure all file/directory names are globally unique across all Dapr documentation.
24+
25+
## Github Dapr Bot Commands
26+
27+
Checkout the [daprbot documentation](https://docs.dapr.io/contributing/daprbot/) for Github commands you can run in this repo for common tasks. For example, you can run the `/assign` (as a comment on an issue) to assign the issue to yourself.
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
---
2+
type: docs
3+
title: "Dapr Java SDK"
4+
linkTitle: "Java"
5+
weight: 1000
6+
description: Java SDK packages for developing Dapr applications
7+
cascade:
8+
github_repo: https://github.com/dapr/java-sdk
9+
github_subdir: daprdocs/content/en/java-sdk-docs
10+
path_base_for_github_subdir: content/en/developing-applications/sdks/java/
11+
github_branch: master
12+
---
13+
14+
Dapr offers a variety of packages to help with the development of Java applications. Using them you can create Java clients, servers, and virtual actors with Dapr.
15+
16+
## Prerequisites
17+
18+
- [Dapr CLI]({{% ref install-dapr-cli.md %}}) installed
19+
- Initialized [Dapr environment]({{% ref install-dapr-selfhost.md %}})
20+
- JDK 11 or above - the published jars are compatible with Java 8:
21+
- [AdoptOpenJDK 11 - LTS](https://adoptopenjdk.net/)
22+
- [Oracle's JDK 15](https://www.oracle.com/java/technologies/javase-downloads.html)
23+
- [Oracle's JDK 11 - LTS](https://www.oracle.com/java/technologies/javase-jdk11-downloads.html)
24+
- [OpenJDK](https://openjdk.java.net/)
25+
- Install one of the following build tools for Java:
26+
- [Maven 3.x](https://maven.apache.org/install.html)
27+
- [Gradle 6.x](https://gradle.org/install/)
28+
29+
## Import Dapr's Java SDK
30+
31+
Next, import the Java SDK packages to get started. Select your preferred build tool to learn how to import.
32+
33+
{{< tabpane text=true >}}
34+
35+
{{% tab header="Maven" %}}
36+
<!--Maven-->
37+
38+
For a Maven project, add the following to your `pom.xml` file:
39+
40+
```xml
41+
<project>
42+
...
43+
<dependencies>
44+
...
45+
<!-- Dapr's core SDK with all features, except Actors. -->
46+
<dependency>
47+
<groupId>io.dapr</groupId>
48+
<artifactId>dapr-sdk</artifactId>
49+
<version>1.16.0</version>
50+
</dependency>
51+
<!-- Dapr's SDK for Actors (optional). -->
52+
<dependency>
53+
<groupId>io.dapr</groupId>
54+
<artifactId>dapr-sdk-actors</artifactId>
55+
<version>1.16.0</version>
56+
</dependency>
57+
<!-- Dapr's SDK integration with SpringBoot (optional). -->
58+
<dependency>
59+
<groupId>io.dapr</groupId>
60+
<artifactId>dapr-sdk-springboot</artifactId>
61+
<version>1.16.0</version>
62+
</dependency>
63+
...
64+
</dependencies>
65+
...
66+
</project>
67+
```
68+
{{% /tab %}}
69+
70+
{{% tab header="Gradle" %}}
71+
<!--Gradle-->
72+
73+
For a Gradle project, add the following to your `build.gradle` file:
74+
75+
```java
76+
dependencies {
77+
...
78+
// Dapr's core SDK with all features, except Actors.
79+
compile('io.dapr:dapr-sdk:1.16.0')
80+
// Dapr's SDK for Actors (optional).
81+
compile('io.dapr:dapr-sdk-actors:1.16.0')
82+
// Dapr's SDK integration with SpringBoot (optional).
83+
compile('io.dapr:dapr-sdk-springboot:1.16.0')
84+
}
85+
```
86+
87+
{{% /tab %}}
88+
89+
{{< /tabpane >}}
90+
91+
If you are also using Spring Boot, you may run into a common issue where the `OkHttp` version that the Dapr SDK uses conflicts with the one specified in the Spring Boot _Bill of Materials_.
92+
93+
You can fix this by specifying a compatible `OkHttp` version in your project to match the version that the Dapr SDK uses:
94+
95+
```xml
96+
<dependency>
97+
<groupId>com.squareup.okhttp3</groupId>
98+
<artifactId>okhttp</artifactId>
99+
<version>1.16.0</version>
100+
</dependency>
101+
```
102+
103+
## Try it out
104+
105+
Put the Dapr Java SDK to the test. Walk through the Java quickstarts and tutorials to see Dapr in action:
106+
107+
| SDK samples | Description |
108+
| ----------- | ----------- |
109+
| [Quickstarts]({{% ref quickstarts %}}) | Experience Dapr's API building blocks in just a few minutes using the Java SDK. |
110+
| [SDK samples](https://github.com/dapr/java-sdk/tree/master/examples) | Clone the SDK repo to try out some examples and get started. |
111+
112+
```java
113+
import io.dapr.client.DaprClient;
114+
import io.dapr.client.DaprClientBuilder;
115+
116+
try (DaprClient client = (new DaprClientBuilder()).build()) {
117+
// sending a class with message; BINDING_OPERATION="create"
118+
client.invokeBinding(BINDING_NAME, BINDING_OPERATION, myClass).block();
119+
120+
// sending a plain string
121+
client.invokeBinding(BINDING_NAME, BINDING_OPERATION, message).block();
122+
}
123+
```
124+
125+
- For a full guide on output bindings visit [How-To: Output bindings]({{% ref howto-bindings.md %}}).
126+
- Visit [Java SDK examples](https://github.com/dapr/java-sdk/tree/master/examples/src/main/java/io/dapr/examples/bindings/http) for code samples and instructions to try out output bindings.
127+
128+
## Available packages
129+
130+
<div class="card-deck">
131+
<div class="card">
132+
<div class="card-body">
133+
<h5 class="card-title"><b>Client</b></h5>
134+
<p class="card-text">Create Java clients that interact with a Dapr sidecar and other Dapr applications.</p>
135+
<a href="{{% ref java-client %}}" class="stretched-link"></a>
136+
</div>
137+
</div>
138+
<div class="card">
139+
<div class="card-body">
140+
<h5 class="card-title"><b>Workflow</b></h5>
141+
<p class="card-text">Create and manage workflows that work with other Dapr APIs in Java.</p>
142+
<a href="{{% ref workflow %}}" class="stretched-link"></a>
143+
</div>
144+
</div>
145+
</div>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
type: docs
3+
title: "AI"
4+
linkTitle: "AI"
5+
weight: 3000
6+
description: With the Dapr Conversation AI package, you can interact with the Dapr AI workloads from a Java application. To get started, walk through the [Dapr AI]({{% ref java-ai-howto.md %}}) how-to guide.
7+
---
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
type: docs
3+
title: "How to: Author and manage Dapr Conversation AI in the Java SDK"
4+
linkTitle: "How to: Author and manage Conversation AI"
5+
weight: 20000
6+
description: How to get up and running with Conversation AI using the Dapr Java SDK
7+
---
8+
9+
As part of this demonstration, we will look at how to use the Conversation API to converse with a Large Language Model (LLM). The API
10+
will return the response from the LLM for the given prompt. With the [provided conversation ai example](https://github.com/dapr/java-sdk/tree/master/examples/src/main/java/io/dapr/examples/conversation), you will:
11+
12+
- You will provide a prompt using the [Conversation AI example](https://github.com/dapr/java-sdk/blob/master/examples/src/main/java/io/dapr/examples/conversation/DemoConversationAI.java)
13+
- Filter out Personally identifiable information (PII).
14+
15+
This example uses the default configuration from `dapr init` in [self-hosted mode](https://github.com/dapr/cli#install-dapr-on-your-local-machine-self-hosted).
16+
17+
## Prerequisites
18+
19+
- [Dapr CLI and initialized environment](https://docs.dapr.io/getting-started).
20+
- Java JDK 11 (or greater):
21+
- [Oracle JDK](https://www.oracle.com/java/technologies/downloads), or
22+
- OpenJDK
23+
- [Apache Maven](https://maven.apache.org/install.html), version 3.x.
24+
- [Docker Desktop](https://www.docker.com/products/docker-desktop)
25+
26+
## Set up the environment
27+
28+
Clone the [Java SDK repo](https://github.com/dapr/java-sdk) and navigate into it.
29+
30+
```bash
31+
git clone https://github.com/dapr/java-sdk.git
32+
cd java-sdk
33+
```
34+
35+
Run the following command to install the requirements for running the Conversation AI example with the Dapr Java SDK.
36+
37+
```bash
38+
mvn clean install -DskipTests
39+
```
40+
41+
From the Java SDK root directory, navigate to the examples' directory.
42+
43+
```bash
44+
cd examples
45+
```
46+
47+
Run the Dapr sidecar.
48+
49+
```sh
50+
dapr run --app-id conversationapp --dapr-grpc-port 51439 --dapr-http-port 3500 --app-port 8080
51+
```
52+
53+
> Now, Dapr is listening for HTTP requests at `http://localhost:3500` and gRPC requests at `http://localhost:51439`.
54+
55+
## Send a prompt with Personally identifiable information (PII) to the Conversation AI API
56+
57+
In the `DemoConversationAI` there are steps to send a prompt using the `converse` method under the `DaprPreviewClient`.
58+
59+
```java
60+
public class DemoConversationAI {
61+
/**
62+
* The main method to start the client.
63+
*
64+
* @param args Input arguments (unused).
65+
*/
66+
public static void main(String[] args) {
67+
try (DaprPreviewClient client = new DaprClientBuilder().buildPreviewClient()) {
68+
System.out.println("Sending the following input to LLM: Hello How are you? This is the my number 672-123-4567");
69+
70+
ConversationInput daprConversationInput = new ConversationInput("Hello How are you? "
71+
+ "This is the my number 672-123-4567");
72+
73+
// Component name is the name provided in the metadata block of the conversation.yaml file.
74+
Mono<ConversationResponse> responseMono = client.converse(new ConversationRequest("echo",
75+
List.of(daprConversationInput))
76+
.setContextId("contextId")
77+
.setScrubPii(true).setTemperature(1.1d));
78+
ConversationResponse response = responseMono.block();
79+
System.out.printf("Conversation output: %s", response.getConversationOutputs().get(0).getResult());
80+
} catch (Exception e) {
81+
throw new RuntimeException(e);
82+
}
83+
}
84+
}
85+
```
86+
87+
Run the `DemoConversationAI` with the following command.
88+
89+
```sh
90+
java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.conversation.DemoConversationAI
91+
```
92+
93+
### Sample output
94+
```
95+
== APP == Conversation output: Hello How are you? This is the my number <ISBN>
96+
```
97+
98+
As shown in the output, the number sent to the API is obfuscated and returned in the form of <ISBN>.
99+
The example above uses an ["echo"](https://docs.dapr.io/developing-applications/building-blocks/conversation/howto-conversation-layer/#set-up-the-conversation-component)
100+
component for testing, which simply returns the input message.
101+
When integrated with LLMs like OpenAI or Claude, you’ll receive meaningful responses instead of echoed input.
102+
103+
## Next steps
104+
- [Learn more about Conversation AI]({{% ref conversation-overview.md %}})
105+
- [Conversation AI API reference]({{% ref conversation_api.md %}})

0 commit comments

Comments
 (0)