I am trying to run duckling locally. So with the help of this article I installed stack, and then
cloned duckling code
git clone https://github.com/facebook/duckling.git
download the zoneinfo and updated the reference in exe/ExampleMain.hs
let defaultPath = "duckling/exe/zoneinfo/"
let fallbackPath = "exe/zoneinfo/"
build using
stack build
then run using
stack exec duckling-example-exe
now if i hit http://localhost:8000/parse in the postman with request type POST and with following content
{
"text": "tommorow",
"locale": "de_DE",
"tz": "Europe/Berlin",
"dims": [
"time"
],
"reftime": 1616571265000
}
it shows 422 bad input
Need a 'text' parameter to parse
and if i hit the same request again it shows 200 OK
quack!
any help?
I see that you are trying to send the request as a JSON, however, the "http://localhost:8000/parse" endpoint expects the input to be sent as "form-encoded" data.
Refer to this image for a sample snapshot - https://i.stack.imgur.com/Cqdz4.png
You can check the source code of RASA open source. They are using requests python library to use duckling inside RASA for data parsing.
Here is the source code, here
It will be so useful to know the correct format of text data.
Also, I will show you how to use duckling through a simple example:
Be sure that you compile and run the binary:
$ stack build
$ stack exec duckling-example-exe
Insdie pythod code environment or any IDE that support python run the following:
import requests
t = requests.post('http://0.0.0.0:8000/parse', data={'text':'tomorrow at eight', 'locale':'en_GB'})
print(t.text)
The output is
[{"body":"tomorrow at eight","start":0,"value":{"values":[{"value":"2021-09-27T08:00:00.000-07:00","grain":"hour","type":"value"},{"value":"2021-09-27T20:00:00.000-07:00","grain":"hour","type":"value"}],"value":"2021-09-27T08:00:00.000-07:00","grain":"hour","type":"value"},"end":17,"dim":"time","latent":false}]
Related
I am a newbie in go and go-swagger. I am following steps in Simple Server tutorial in goswagger.io.
I am using Ubuntu 18.04, swagger v0.25.0 and go 1.15.6.
Following the same steps, there are a few differences of the files generated. For instance, goswagger.io's has find_todos_okbody.go and get_okbody.go in models but mine does not. Why is that so?
Link to screenshot of my generated files vs
Link to screenshot of generated files by swagger.io
Starting the server as written in the tutorial go install ./cmd/todo-list-server/ gives me the following error. Can anyone please help with this?
# my_folder/swagger-todo-list/restapi
restapi/configure_todo_list.go:41:8: api.TodosGetHandler undefined (type *operations.TodoListAPI has no field or method TodosGetHandler)
restapi/configure_todo_list.go:42:6: api.TodosGetHandler undefined (type *operations.TodoListAPI has no field or method TodosGetHandler)
The first step in goswagger.io todo-list is swagger init spec .... Which directory should I run this command in? I ran it in a newly created folder in my home directory. However, from the page, it shows the path to be ~/go/src/github.com/go-swagger/go-swagger/examples/tutorials/todo-list. I am not sure whether I should use go get ..., git clone ... or create those folders. Can someone advise me?
Thanks.
This is likely the documentation lagging behind the version of the code that you are running. As long as it compiles, the specific files the tool generates isn't so crucial.
This is a compilation error. When you do go install foo it will try to build the foo package as an executable and then move that to your GOPATH/bin directory. It seems that the generated code in restapi/configure_todo_list.go isn't correct for the operations code generated.
All you need to run this tutorial yourself is an empty directory and the swagger tool (not its source code). You run the commands from the root of this empty project. In order not to run into GOPATH problems I would initialise a module with go mod init todo-list-example before doing anything else.
Note that while the todo-list example code exists inside the go-swagger source, it's there just for documenting example usage and output.
What I would advice for #2 is to make sure you're using a properly released version of go-swagger, rather than installing from the latest commit (which happens when you just do a go get), as I have found that to be occasionally unstable.
Next, re-generate the entire server, but make sure you also regenerate restapi/configure_todo_list.go by passing --regenerate-configureapi to your swagger generate call. This file isn't always refreshed because you're meant to modify it to configure your app, and if you changed versions of the tool it may be different and incompatible.
If after that you still get the compilation error, it may be worth submitting a bug report at https://github.com/go-swagger/go-swagger/issues.
Thanks #EzequielMuns. The errors in #2 went away after I ran go get - u -f ./... as stated in
...
For this generation to compile you need to have some packages in your GOPATH:
* github.com/go-openapi/runtime
* github.com/jessevdk/go-flags
You can get these now with: go get -u -f ./...
I think it's an error of swagger code generation. You can do as folloing to fix this:
delete file configure_todo_list.go;
regenerate code.
# swagger generate server -A todo-list -f ./swagger.yml
Then, you can run command go install ./cmd/todo-list-server/, it will succeed.
I get the following error when I run jscodeshift -t ./react-codemod/transforms/React-PropTypes-to-prop-types.js ./src
Transformation error (This experimental syntax requires enabling one of the following parser plugin(s): 'decorators-legacy, decorators' (13:0))
I googled a bit and found out I have to set the --parser-config of jscodeshift. I need help with a sample json file that can resolve the above error.
The instructions mentioned in the comment by The Third are correct.
I was need to manually update babel5Compat.js file with this 'decorators-legacy' plugin.
// in ./node_modules/jscodeshift/parser/babel5Compat.js
plugins: [
// a list of plugins,
'decorators-legacy',
]
I have used Ruby gem avro_turf to convert data to binary and publish it to Kafka. But I got an error unknown keyword: version when try to encode data.
I have started Confluent Schema Registry on localhost:8081. I can create and read subject on terminal.
I scan its source code, there is a "version" param in encode function.
I curl curl -X GET http://127.0.0.1:8081/subjects/avro-test/versions/1 to Schema Registry and get this data
{"subject":"avro-test","version":1,"id":1,"schema":"{\"type\":\"record\",\"name\":\"evolution\",\"namespace\":\"com.landoop\",\"doc\":\"This is a sample Avro schema to get you started. Please edit\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"phone\",\"type\":\"string\"},{\"name\":\"email\",\"type\":\"string\"}]}"}
This is my current code
require "avro_turf/messaging"
avro = AvroTurf::Messaging.new(registry_url: "http://localhost:8081/")
data = avro.encode('{ "name" => "hello, world", "phone": "01232323", "email": "hello#gmail.com" }', subject: 'avro-test', version: 1)
Please help me for solution.
I scan its source code, there is a "version" param in encode function.
Yes, the problem is, you're looking at the current state of master branch. As of now, it contains unreleased changes, this keyword included.
So either wait for next version to be released, or use master directly
gem "avro_turf", github: "dasch/avro_turf"
I'm working on a ASP.NET Core WebAPI project and I'm trying to find a way to generate swagger json at build time ?
As i'm working with 4 environments, i'd like to have 4 swagger.json with a different name of my choice, like:
swagger_{appName}dev{buildNumber}.json
swagger_{appName}demo{buildNumber}.json
swagger_{appName}int{buildNumber}.json
swagger_{appName}staging{buildNumber}.json
Is it also possible to edit the fields in the json ? I'd like to edit (depending of the environment) the following fields : host, schemes and basePath.
I'm using Swashbuckle.AspNetCore but it appears it doesn't have an option to do such task or am I wrong ?
Thanks in advance
You have the option of generating OpenApi json file(s) from the command line without deploying using the Swashbuckle.AspNetCore.Cli nuget package.
The command will look something like this and can be added as a "post build" script
dotnet <nugetpackages>\Swashbuckle.AspNetCore.Cli\bin\$(Configuration)\netcoreapp<ver>\dotnet-swagger.dll tofile --host http://localhost --output swagger.json <bin>\<AssemblyName>.dll v1
more details can be found here https://github.com/domaindrivendev/Swashbuckle.AspNetCore#swashbuckleaspnetcorecli
I'm not sure about generating separate files for each environment offhand
The simple way is using PowerShell task to update json file and save with another name.
Simple workflow:
Read the file through Get-Content script
Using ConvertFrom-Json to converts content to object
Set the property value to update object
Using ConvertTo-Json to convert an object to a JSON-formatted string
Using Set-Content to write content to a file
For detail code, you can refer to this thread: how do I update json file using powershell.
The build number value is stored in the predefined variable: Build.BuildNumber (PowerShell: $env:BUILD_BUILDNUMBER)
I am following this tutorial
https://hyperledger.github.io/composer/integrating/deploying-the-rest-server.html
I have done all the steps. But when I run rest-server through github, it prints following stack trace.
Error
404 Cannot GET /auth/github
status: 404
Error: Cannot GET /auth/github
at raiseUrlNotFoundError (/home/praval/.nvm/versions/node/v6.11.1/lib/node_modules/composer-rest-server/node_modules/loopback/server/middleware/url-not-found.js:21:17)
I presume you installed the Github strategy via npm install -g passport-github?
If so did it create a folder /auth/github?
You are required to go to this Folder per documentation: "Authenticate to the REST server by navigating to the value of the authPath property specified in the environment variable COMPOSER_PROVIDERS. In the example above, this is http://localhost:3000/auth/github"
In my case that folder was not created. I read on Github website: https://github.com/cfsghost/passport-github
"The author of Passport-Github has not maintained the original module for a long time. Features in his module don't work since Github upgraded their API to version 3.0. We forked it and re-published it to NPM with a new name passport-github2"
I'm looking for guidance on this.
Before create private api just execute this command in your terminal.
export COMPOSER_PROVIDERS='{
"github": {
"provider": "github",
"module": "passport-github",
"clientID": "<your id>",
"clientSecret": "<your secret>",
"authPath": "/auth/github",
"callbackURL": "/auth/github/callback",
"successRedirect": "http://localhost(domain of angular app):4200(port)/home(page to redirect)",
"failureRedirect": "http://localhost(domain of angular app):4200(port)/login-github(page to redirect)""
}
}'
To check if all is fine - run command
echo $COMPOSER_PROVIDERS
After this you will see your COMPOSER_PROVIDERS value.
And after in github profile app (https://github.com/settings/applications/) you must configure "Homepage URL" (ex. http://APIdomain:3000/) and "Authorization callback URL" (ex. http://APIdomain:3000/auth/github/callback)