Skip to content

Commit

Permalink
code clean - some adoc adds
Browse files Browse the repository at this point in the history
  • Loading branch information
vga91 committed Oct 19, 2023
1 parent 72162e3 commit 0ebc486
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 54 deletions.
36 changes: 24 additions & 12 deletions docs/asciidoc/modules/ROOT/pages/ml/bedrock.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
= AWS Bedrock procedures



These procedures leverage the https://aws.amazon.com/bedrock/[Amazon Bedrock API].


Expand All @@ -12,33 +11,46 @@ Here is a list of all available Aws Bedrock procedures:
[opts=header, cols="1, 4", separator="|"]
|===
|name|description
|name|description
|name|description
|name|description
|name|description
|name|description
|name|description
|name|description
|name|description
|apoc.ml.bedrock.list($config)|To get the list of foundation or custom models
|apoc.ml.bedrock.jurassic(body, $config)|To create an API call to `Jurassic-2` model
|apoc.ml.bedrock.anthropic.claude(body, $config)|To create an API call to ``Titan Embedding``s model
|apoc.ml.bedrock.titan.embedding(body, $config)|To create an API call to `Claude` model
|apoc.ml.bedrock.stability(body, $config)|To create an API call to `Stable Diffusion` model
|apoc.ml.bedrock.custom(body, $config)|To create a customizable Bedrock API call
|===

All the procedures, leverage the `apoc.ml.bedrock.custom` procedures,
and support the same config parameter, but unlike the `custom` one,
they have some different default parameters and return a data type consistent with the called API,
they have some different default parameters and model id.
Moreover the return data is consistent with the called API,
instead of returning a generic `Object` as a result


== Config
// TODO

.Config parameters
[opts=header, cols="1,1,1,5"]
|===
| name | type | default | description
| secretKey | String | null | The AWS key ID. We can also evaluate it via `apoc.conf`, with the key `apoc.aws.key.id`. As an alternative to the pair keyId-secretKey, we can directly pass the https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html[aws V4 signature] via the `headers` config
| keyId | String | null | The AWS secret access key. We can also evaluate it via `apoc.conf`, with the key `apoc.aws.secret.id`. As an alternative to the pair keyId-secretKey, we can directly pass the https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html[aws V4 signature] via the `headers` config
| region | String | the one calculated from `endpoint` config | The AWS region
| endpoint | String | see below | The AWS endpoint.
| method | String | `"POST"` (or `"GET"` with the `apoc.ml.bedrock.list` procedure) | TODO
| headers | Map<String, Object> | `{}` | The additional headers
| modelId | String | see below | The modelId. If created,
|===

modelId and endpoint - TODO

== Usage examples

TODO

=== Custom AWS API Call



: You need to acquire an https://platform.openai.com/account/api-keys[OpenAI API key^] to use these procedures. Using them will incur costs on your OpenAI account. You can set the api key globally by defining the `apoc.openai.key` configuration in `apoc.conf`

- endpoint customizable
- keyId e secretKey, oppure passare direttamente nell'header
Expand Down
40 changes: 0 additions & 40 deletions extended/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,46 +72,6 @@ dependencies {
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-annotations'
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'
}

/*
<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.20.157</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bedrockruntime</artifactId>
<version>2.20.157</version>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>sts</artifactId>
<version>2.20.157</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20230618</version>
</dependency>
</dependencies>
*/

// TODO - move in extra-deps
implementation group: 'software.amazon.awssdk', name: 'bom', version: '2.20.157'
implementation group: 'software.amazon.awssdk', name: 'bedrockruntime', version: '2.20.157'
implementation group: 'software.amazon.awssdk', name: 'bedrock', version: '2.20.157'
implementation group: 'software.amazon.awssdk', name: 'sts', version: '2.20.157'

implementation group: 'org.json', name: 'json', version: '20230618'


// These will be dependencies packaged with the .jar
implementation project(':common')
Expand Down
5 changes: 3 additions & 2 deletions extended/src/main/java/apoc/ml/bedrock/Bedrock.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

public class Bedrock {

@Procedure("apoc.ml.bedrock.list")
@Procedure
public Stream<ModelItemResult> list(@Name(value = "config", defaultValue = "{}") Map<String, Object> config) {

BedrockConfig conf = new BedrockGetModelsConfig(config);
Expand All @@ -47,7 +47,7 @@ public Stream<ObjectResult> custom(@Name(value = "body") Object body,
.map(ObjectResult::new);
}

@Procedure("apoc.ml.bedrock.jurassic")
@Procedure
public Stream<Jurassic> jurassic(@Name(value = "body") Object body,
@Name(value = "config", defaultValue = "{}") Map<String, Object> config) {

Expand Down Expand Up @@ -83,6 +83,7 @@ public Stream<StabilityAi> stability(@Name(value = "body") Object body,
return executeRequestReturningMap(body, config, "$.artifacts[0]")
.map(StabilityAi::from);
}


private Stream<Map<String, Object>> executeRequestReturningMap(Object body, Map<String, Object> config, String path) {
return executeCustomRequest(body, config, path)
Expand Down

0 comments on commit 0ebc486

Please sign in to comment.