Unable to start a human loop using Augmented AI - Error in start_human_loop - amazon-textract

I am trying to trigger a human workflow through a piece of python code. This is to include Human Review for Textract.
The code snippet is as below:
sentiment = "Neutral"
blurb = "The sentiment of this document is neutral"
response = client.start_human_loop(
HumanLoopName='',#Loop name and FlowDefinitionArn are used, have been omitted in the question
FlowDefinitionArn='',
HumanLoopInput={
'InputContent': {
"initialValue": sentiment,
"taskObject": blurb
}
},
DataAttributes={
'ContentClassifiers': [
'FreeOfAdultContent',
]
}
When I run this, an exception occurs :
botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid type for parameter HumanLoopInput
Can anyone help me with an example of HumanLoopInput? Its configuration is already done in the analyze_document() function (HumanLoopConfig).
Is there any other way to avoid this exception?

InputContent should be string try:
'InputContent': json.dumps({
"initialValue": sentiment,
"taskObject": blurb
})

Related

Post Request Returning {"error": "Expecting a string", "result":87}

I am trying to interface with the Chroma SDK released by Razer and have been running into some issues. Following the documentation that razer provides, I have been trying to change the color of my RGB mouse for a while now, and hope that someone has the answer for me. I can successfully check to see if the ChromaSDK is working through:
url = 'http://localhost:54235/razer/chromasdk'
x = requests.get(url)
print(x.text)
Then, I can initialize the connection by sending a post to the URL, following the template given on their website:
data = {
"title": "Razer Chroma SDK RESTful Test Application",
"description": "This is a REST interface test application",
"author": {
"name": "Chroma Developer",
"contact": "www.razerzone.com"
},
"device_supported": [
"keyboard",
"mouse",
"headset",
"mousepad",
"keypad",
"chromalink"],
"category": "application"
}
x = requests.post(url, json=data)
print(x.text)
This post request returns:
{"sessionid":55105,"uri":"http://localhost:55105/chromasdk"}
Then, since the connection is initialized, I SHOULD be able to change the colors of the connected Razer devices using endpoints such as /mouse or /headset. This is where it gets funky, if I were to use the url(s): http://localhost:54235/chromasdk/mouse, http://localhost:54235/razer/mouse, or http://localhost:54235/mouse then I get the error "Not Implemented", whereas if I use the URI provided by the previous post request and tag /mouse onto the end of it, it get this error:
{"error":"Expecting a string","result":87}
Or if I use http://localhost:54235/razer/chromasdk/mouse, I get:
{"author":null,"category":null,"description":null,"device_supported":null,"error":"The parameter is incorrect.","result":87,"title":null}
The endpoints SHOULD follow the URL http://localhost:54235/razer/chromasdk, and I am following the documentation to a T, so what am I doing wrong??

How to get first item from array in Robot Framework

I have the following response from a POST request:
{"facilities":[{"id":"f966a7d9-6a2d-43df-8cbf-ebdcb8c7fdc4","description":"luovbfvwofgdrcwvqtyqohjioocszgplcjh","hasAnyPartnership":false,"hasAnyProcedure":false}
So I used the "Convert String to JSON" function and got the following response:
{'facilities': [{'id': 'f966a7d9-6a2d-43df-8cbf-ebdcb8c7fdc4',
'description': 'luovbfvwofgdrcwvqtyqohjioocszgplcjh',
'hasAnyPartnership': False, 'hasAnyProcedure': False}
How do I get the ID value that is inside FACILITIES?
'facilities': [{'id': 'f966a7d9-6a2d-43df-8cbf-ebdcb8c7fdc4'
The JSON example you have provided is not the valid one. It is missing ] of facilities array and } of opening external brace. After correction it should look like this -
{"facilities":[{"id":"f966a7d9-6a2d-43df-8cbf-ebdcb8c7fdc4","description":"luovbfvwofgdrcwvqtyqohjioocszgplcjh","hasAnyPartnership":false,"hasAnyProcedure":false}]}
You can use following keywords from JSONLibrary
${json}= Convert String to JSON ${JsonVar}
${idValue}= Get Value From Json ${json} $.facilities[0].id
Output -

Load JSON File into Robot Framework

I am trying to load a JSON file and use the values to perform some actions based on my tests. I tried to load the json value which I think I got right, but when trying to log the output, I got error message:
Resolving variable '${qa["REQUEST_ID"]}' failed: TypeError: list indices must be integers or slices, not str
Not exactly sure what this means since I am new to Robot Framework. This is what I did to load and log the values:
${file} Get File ${CURDIR}/RequestIDs.json
${qa} Evaluate json.loads('''${file}''') json
Log To Console ${qa["REQUEST_ID"]}
Json file looks something like:
[
{
"REQUEST_ID" : 10513
},
{
"REQUEST_ID" : 48156
},
{
"REQUEST_ID" : 455131
}
]
So basically I want to get the "REQUEST_ID" value and type that in a text field.
Look at the structure of your json - it's a list of dictionaries; so you have to first specify which list member you want, and then its REQUEST_ID field:
Log To Console ${qa[0]["REQUEST_ID"]
# print the value from all present dictionaries in the list:
FOR ${member} IN #{qa}
Log To Console ${member["REQUEST_ID"]
END

Elastic Easy Search Please provide an index for your component [no-index]?

Despite carefully following the instructions on how to configure the Elastic Search Package to add Search functionality to my Meteor App, I keep getting this frustrating error message in my browser console:
details: undefined
error: "no-index"
errorType: "Meteor.Error"
isClientSafe: true
message: "Please provide an index for your component [no-index]"
reason: "Please provide an index for your component"
stack: "Error: Please provide an index for your component [no-index]
Following is my code:
../imports/api/tasks.js
import { Mongo } from "meteor/mongo";
import { Index, MinimongoEngine } from 'meteor/easy:search';
global.recipientsDetails = new Mongo.Collection("recipients");
global.recipientsDetailsIndex = new Index({
collection: recipientsDetails,
fields: ['recipientNumber', 'recipientAmount'],
engine: new MinimongoEngine(),
})
../client/main.js
import '../imports/api/tasks.js';
Template.navigationMenu.helpers({
enableButtonSearchResults: () => recipientsDetailsIndex,
});
../client/main.html
<template name="navigationMenu">
{{#EasySearch.Each index=recipientsDetailsIndex}}
<ul>
{{#EasySearch.Each index=recipientsDetailsIndex }}
<li>Recipients Number: {{recipientNumber}}</li>
{{/EasySearch.Each}}
</ul>
</template>
What I find strange is that, when I feed in the following code in my browser console:
var cursor = recipientsDetailsIndex.search("705087688");
// search all docs that contain "705087633" in the recipientNumber field.
console.log(cursor.fetch());
The following yeilds in the browser console:
[{…}]
0:
paymentDate: "2019-04-08 23:20:01"
recipientAmount: "110"
recipientNumber: "+254705087688"
_id: "Wo4oZNzs5fLTqadcn"
The above results suggest that the Elastic search package is working and the fault is in the template, though I might be wrong.
Kindly help point out what I have missed or got wrong in the template or elsewhere...
Wild guess here: But the http://matteodem.github.io/meteor-easy-search/docs/engines/ mention that there is a Elastic Search Engine and in your tasks file you use MiniMongoEngine...

Firebase rules not working with code

I am not able to make the security rules in Firebase database working although the simulator shows they are in place.
A simple example:
{
"rules": {
"items":{
"$itemid":{
".read":true,
".write":"newData.child('id').isNumber()"
}
}
}
}
For above rules when I try posting an item from simulator with text value in 'id' it gives proper error as expected.
For Url: /items/-sdsd123
And for data: {"id":"MAC1", "name":"Macbook Pro"}
It gives write denied error in simulator as 'id' is not number.
However after publishing the rules and trying from code or browser data editor it allows the id to be text value. Below works:
var key = db.ref("/items").push().key;
db.ref('/items/' + key).set({"id":"MAC1", "name":"Macbook Pro"});
I am missing something basic but not able to figure it out, kindly help.

Resources