-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* update * The vertices of the graph support the map data structure clsoe(#810) * ai support Use local LLM(claude3) close #827 * Official and Stable ORM Framework for MongoDB close(#829)
- Loading branch information
Showing
10 changed files
with
162 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package run.mone; | ||
|
||
import com.google.gson.Gson; | ||
import org.json.JSONObject; | ||
import software.amazon.awssdk.core.SdkBytes; | ||
import software.amazon.awssdk.identity.spi.AwsCredentialsIdentity; | ||
import software.amazon.awssdk.identity.spi.IdentityProvider; | ||
import software.amazon.awssdk.identity.spi.ResolveIdentityRequest; | ||
import software.amazon.awssdk.identity.spi.internal.DefaultAwsCredentialsIdentity; | ||
import software.amazon.awssdk.regions.Region; | ||
import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient; | ||
import software.amazon.awssdk.services.bedrockruntime.model.InvokeModelRequest; | ||
import software.amazon.awssdk.services.bedrockruntime.model.InvokeModelResponse; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* @author goodjava@qq.com | ||
* @date 2024/4/12 13:35 | ||
*/ | ||
public class AwsClient { | ||
|
||
private static final Gson gson = new Gson(); | ||
|
||
|
||
public static ResponsePayload call(JSONObject payload, Region region, String modelId, Key key) { | ||
BedrockRuntimeClient client = BedrockRuntimeClient.builder() | ||
.credentialsProvider(new IdentityProvider<>() { | ||
@Override | ||
public Class<AwsCredentialsIdentity> identityType() { | ||
return AwsCredentialsIdentity.class; | ||
} | ||
|
||
public CompletableFuture<AwsCredentialsIdentity> resolveIdentity(ResolveIdentityRequest request) { | ||
return CompletableFuture.completedFuture(DefaultAwsCredentialsIdentity.builder().accessKeyId(key.getKeyId()).secretAccessKey(key.getKey()).build()); | ||
} | ||
}) | ||
.region(region) | ||
.build(); | ||
|
||
InvokeModelRequest request = InvokeModelRequest.builder() | ||
.contentType("application/json") | ||
.body(SdkBytes.fromUtf8String(payload.toString())) | ||
.modelId(modelId) | ||
.build(); | ||
|
||
InvokeModelResponse resp = client.invokeModel(request); | ||
String str = new String(resp.body().asByteArray()); | ||
return gson.fromJson(str, ResponsePayload.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters