Skip to content

Commit d5f2a0c

Browse files
apaparazzi0329watson-github-bot
authored andcommitted
feat(assistant_v2,disco_v1): add answers property to response model, fix typo
1 parent 2c4b1ca commit d5f2a0c

4 files changed

Lines changed: 64 additions & 7 deletions

File tree

Sources/AssistantV2/Models/SearchResult.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ public struct SearchResult: Codable, Equatable {
5656
*/
5757
public var highlight: SearchResultHighlight?
5858

59+
/**
60+
An array specifying segments of text within the result that were identified as direct answers to the search query.
61+
Currently, only the single answer with the highest confidence (if any) is returned.
62+
**Note:** This property uses the answer finding beta feature, and is available only if the search skill is
63+
connected to a Discovery v2 service instance.
64+
*/
65+
public var answers: [SearchResultAnswer]?
66+
5967
// Map each property name to the key that shall be used for encoding/decoding.
6068
private enum CodingKeys: String, CodingKey {
6169
case id = "id"
@@ -64,6 +72,7 @@ public struct SearchResult: Codable, Equatable {
6472
case title = "title"
6573
case url = "url"
6674
case highlight = "highlight"
75+
case answers = "answers"
6776
}
6877

6978
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* (C) Copyright IBM Corp. 2021.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
**/
16+
17+
import Foundation
18+
19+
/**
20+
An object specifing a segment of text that was identified as a direct answer to the search query.
21+
*/
22+
public struct SearchResultAnswer: Codable, Equatable {
23+
24+
/**
25+
The text of the answer.
26+
*/
27+
public var text: String
28+
29+
/**
30+
The confidence score for the answer, as returned by the Discovery service.
31+
*/
32+
public var confidence: Double
33+
34+
// Map each property name to the key that shall be used for encoding/decoding.
35+
private enum CodingKeys: String, CodingKey {
36+
case text = "text"
37+
case confidence = "confidence"
38+
}
39+
40+
}

Sources/DiscoveryV1/Models/StatusDetails.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,34 @@ public struct StatusDetails: Codable, Equatable {
2424
/**
2525
Indicates whether the credential is accepted by the target data source.
2626
*/
27-
public var authentication: Bool?
27+
public var authenticated: Bool?
2828

2929
/**
30-
If `authentication` is `false`, a message describes why the authentication was unsuccessful.
30+
If `authenticated` is `false`, a message describes why the authentication was unsuccessful.
3131
*/
3232
public var errorMessage: String?
3333

3434
// Map each property name to the key that shall be used for encoding/decoding.
3535
private enum CodingKeys: String, CodingKey {
36-
case authentication = "authentication"
36+
case authenticated = "authenticated"
3737
case errorMessage = "error_message"
3838
}
3939

4040
/**
4141
Initialize a `StatusDetails` with member variables.
4242

43-
- parameter authentication: Indicates whether the credential is accepted by the target data source.
44-
- parameter errorMessage: If `authentication` is `false`, a message describes why the authentication was
43+
- parameter authenticated: Indicates whether the credential is accepted by the target data source.
44+
- parameter errorMessage: If `authenticated` is `false`, a message describes why the authentication was
4545
unsuccessful.
4646

4747
- returns: An initialized `StatusDetails`.
4848
*/
4949
public init(
50-
authentication: Bool? = nil,
50+
authenticated: Bool? = nil,
5151
errorMessage: String? = nil
5252
)
5353
{
54-
self.authentication = authentication
54+
self.authenticated = authenticated
5555
self.errorMessage = errorMessage
5656
}
5757

WatsonDeveloperCloud.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@
110110
3E606DD72550C4D600ABAC72 /* WorkspaceSystemSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E606DD22550C4D600ABAC72 /* WorkspaceSystemSettings.swift */; };
111111
3E606E212550D10800ABAC72 /* AnalyzedResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E606E182550D10700ABAC72 /* AnalyzedResult.swift */; };
112112
3E606E262550D10800ABAC72 /* AnalyzedDocument.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E606E1D2550D10800ABAC72 /* AnalyzedDocument.swift */; };
113+
3E6FB33A26F0E4F200DD3C5F /* SearchResultAnswer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E6FB33926F0E4F200DD3C5F /* SearchResultAnswer.swift */; };
114+
3E6FB33E26F0E5EF00DD3C5F /* StatusDetails.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E6FB33D26F0E5EF00DD3C5F /* StatusDetails.swift */; };
113115
3E89BB85253F71070009E53D /* WordTimestamp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E89BB83253F71070009E53D /* WordTimestamp.swift */; };
114116
3E89BB86253F71070009E53D /* WordConfidence.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E89BB84253F71070009E53D /* WordConfidence.swift */; };
115117
3EDCC07524F02F6200672463 /* Language.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EDCC07324F02F6200672463 /* Language.swift */; };
@@ -1126,6 +1128,8 @@
11261128
3E606DD22550C4D600ABAC72 /* WorkspaceSystemSettings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WorkspaceSystemSettings.swift; sourceTree = "<group>"; };
11271129
3E606E182550D10700ABAC72 /* AnalyzedResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnalyzedResult.swift; sourceTree = "<group>"; };
11281130
3E606E1D2550D10800ABAC72 /* AnalyzedDocument.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnalyzedDocument.swift; sourceTree = "<group>"; };
1131+
3E6FB33926F0E4F200DD3C5F /* SearchResultAnswer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SearchResultAnswer.swift; path = Models/SearchResultAnswer.swift; sourceTree = "<group>"; };
1132+
3E6FB33D26F0E5EF00DD3C5F /* StatusDetails.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusDetails.swift; sourceTree = "<group>"; };
11291133
3E89BB83253F71070009E53D /* WordTimestamp.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WordTimestamp.swift; sourceTree = "<group>"; };
11301134
3E89BB84253F71070009E53D /* WordConfidence.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WordConfidence.swift; sourceTree = "<group>"; };
11311135
3EDCC07324F02F6200672463 /* Language.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Language.swift; path = Models/Language.swift; sourceTree = "<group>"; };
@@ -2470,6 +2474,7 @@
24702474
92261EA721F1007500A1A620 /* SourceOptionsWebCrawl.swift */,
24712475
CADA958D20FCD66400B5BD84 /* SourceSchedule.swift */,
24722476
CADA959220FCD66500B5BD84 /* SourceStatus.swift */,
2477+
3E6FB33D26F0E5EF00DD3C5F /* StatusDetails.swift */,
24732478
68AF8EE7206968CC00D552E3 /* Term.swift */,
24742479
683955042077E613009E1C8A /* Timeslice.swift */,
24752480
92ED234E218A598D00C049A2 /* TokenDictRule.swift */,
@@ -3089,6 +3094,7 @@
30893094
922077802152FC5900C8C7E4 /* AssistantV2 */ = {
30903095
isa = PBXGroup;
30913096
children = (
3097+
3E6FB33926F0E4F200DD3C5F /* SearchResultAnswer.swift */,
30923098
922077992152FC5900C8C7E4 /* Assistant.swift */,
30933099
922077822152FC5900C8C7E4 /* Models */,
30943100
922077B22152FC8A00C8C7E4 /* Tests */,
@@ -4831,6 +4837,7 @@
48314837
68AF8F5E2069690300D552E3 /* Collection.swift in Sources */,
48324838
68AF8F562069690300D552E3 /* EnrichmentOptions.swift in Sources */,
48334839
CADA95A020FCD66600B5BD84 /* Credentials.swift in Sources */,
4840+
3E6FB33E26F0E5EF00DD3C5F /* StatusDetails.swift in Sources */,
48344841
7E34336F2346A385004427C4 /* Completions.swift in Sources */,
48354842
68AF8F722069690300D552E3 /* QueryResponse.swift in Sources */,
48364843
CADA959A20FCD66600B5BD84 /* Source.swift in Sources */,
@@ -5423,6 +5430,7 @@
54235430
922078422152FCE400C8C7E4 /* DialogNodeAction.swift in Sources */,
54245431
922078452152FCE400C8C7E4 /* SessionResponse.swift in Sources */,
54255432
3EEE06BC253A200C005217E0 /* BulkClassifyUtterance.swift in Sources */,
5433+
3E6FB33A26F0E4F200DD3C5F /* SearchResultAnswer.swift in Sources */,
54265434
7E2B504A24E1DEF1007AAFC4 /* LogCollection.swift in Sources */,
54275435
922078502152FCE400C8C7E4 /* MessageInput.swift in Sources */,
54285436
3E50193E264B14D9006A0F2E /* LogMessageSourceDialogNode.swift in Sources */,

0 commit comments

Comments
 (0)