-
Notifications
You must be signed in to change notification settings - Fork 3
chore: Explicit no-convenience; Add code usage examples #340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
13780df
c29e333
c576534
b515e4d
0e95f7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -17,9 +17,10 @@ This guide provides examples on how to manage data in [SAP Document Grounding](h | |||||
| It's divided into two main sections: Data Ingestion and Data Retrieval. | ||||||
|
|
||||||
| :::warning | ||||||
| All classes under any of the `...model` packages are generated from an OpenAPI specification. | ||||||
| This means that these model classes are not guaranteed to be stable and may change with future releases. | ||||||
| They are safe to use, but may require updates even in minor releases. | ||||||
| All classes in the `...model` and `...client` packages are generated from an OpenAPI specification. | ||||||
| These classes can be used, but no API stability guarantees are provided, even for minor releases. | ||||||
| Maintenance and support are limited to ensuring consistency with the service specification. | ||||||
| No additional convenience API layer is provided. | ||||||
| ::: | ||||||
|
|
||||||
| ## Prerequisites | ||||||
|
|
@@ -78,6 +79,23 @@ PipelineStatus status = api.getPipelineStatus(resourceGroupId, pipeline.getPipel | |||||
|
|
||||||
| ### Vector API | ||||||
|
|
||||||
| Collection creation: | ||||||
|
|
||||||
| ``` | ||||||
| String resourceGroupId; | ||||||
| CollectionRequest collectionRequest; | ||||||
|
|
||||||
| var api = new GroundingClient().vector(); | ||||||
|
|
||||||
| OpenApiResponse documents = api.createCollection(resourceGroupId, collectionRequest); | ||||||
| Map<String, List<String>> headers = documents.getHeaders(); | ||||||
|
|
||||||
| String locationHeader = headers.get("Location").get(0); | ||||||
| String collectionId = locationHeader.replaceAll("^.*?/([a-f0-9-]+)/.*?$", "$1"); | ||||||
| ``` | ||||||
|
|
||||||
| Document creation: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| ```java | ||||||
| var api = new GroundingClient().vector(); | ||||||
| var resourceGroupId = "default"; | ||||||
|
|
@@ -96,6 +114,23 @@ var request = DocumentCreateRequest.create() | |||||
| DocumentsListResponse response = api.createDocuments(resourceGroupId, collectionId, request); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Document creation is not compiling
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. var request =
DocumentCreateRequest.create()
.documents(
BaseDocument.create()
.chunks(
TextOnlyBaseChunk.create()
.content("The dog makes _woof_")
.metadata(VectorKeyValueListPair.create().key("animal").value("dog")))
.metadata(VectorDocumentKeyValueListPair.create().key("topic").value("sound"))); |
||||||
| ``` | ||||||
|
|
||||||
| Document search: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| ```java | ||||||
| String resourceGroup; | ||||||
| TextSearchRequest textSearch; | ||||||
|
|
||||||
| var api = new GroundingClient().vector(); | ||||||
| var result = api.search(resourceGroup, textSearch); | ||||||
|
|
||||||
| String joinedContent = result.getResults().stream() | ||||||
| .flatMap(r -> r.getResults().stream()) | ||||||
| .flatMap(r -> r.getDocuments().stream()) | ||||||
| .flatMap(d -> d.getChunks().stream()) | ||||||
| .map(VectorChunk::getContent) | ||||||
| .collect(Collectors.joining()); | ||||||
| ``` | ||||||
|
|
||||||
| Refer to the [GroundingController](https://github.com/SAP/ai-sdk-java/tree/main/sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/GroundingController.java) in our Spring Boot application for a complete example. | ||||||
|
|
||||||
| ## Data Retrieval | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.