aichaos / rivescript-go Goto Github PK
View Code? Open in Web Editor NEWA RiveScript interpreter for Go. RiveScript is a scripting language for chatterbots.
Home Page: https://www.rivescript.com/
License: MIT License
A RiveScript interpreter for Go. RiveScript is a scripting language for chatterbots.
Home Page: https://www.rivescript.com/
License: MIT License
I have a chatbot running, and I have programming that allows a user to start a troubleshooting session, and each step is a topic. The problem is they may go away, and then come back hours later and try to ask the chatbot another question -- but they're stuck inside the topic they left on which may be a few days ago. Is there a way to time out a topic? So that ten minutes later it goes back to topic=random?
In
Line 222 in 7f29a68
The JS and Java implementations support arbitrary numbers of <star>
tags for as many capture groups as the trigger regexp matched.
ALl triggers are lower cased -- is it possible to create a trigger that doesn't? I have a user of my chatbot that he wants to decrypt a string. So that string is in upper / lower case etc.
+ decrypt string *
- LocalCommand /usr/local/bin/decrypt <star1>
I have code in my chatbot that looks at the response. If the response starts with: LocalCommand, RemoteCommand it tries to execute the command, the results of that command is what gets sent to the user. This is configurable and can check if that user is allowed to run that command etc. Anyway is there a way to ignore the case of what is input in <star1>? Something like this:
+ decrypt string <ignorecase>*
- LocalCommand /usr/local/bin/decrypt <star1>
I am asking first. I plan on creating one for my chatbot....
I’m curious if it's possible to capture raw (or at least, unlowercased) input in a macro. I'm encountering a case where I need to capture case-sensitive input with punctuation and, as far as I can tell, the data would currently need to be captured outside of RiveScript.
This is a blanket ticket for going through the codebase and doing general cleanup and API fixes to make the code more idiomatic from a Go point of view.
Examples:
More functions should return error
objects to communicate failure conditions rather than relying on "magic" return values like empty strings.
func ClearUservars(username string) error
could return an error when the user had no vars to clear.func CurrentUser() (string, error)
where it gives an error when called outside of an object macro context, rather than what it currently does by returning an empty string -- this isn't idiomatic Go. User variable getter functions should be refactored to make more sense for "API context" vs. "internal use w/ <get>
"
GetUservar()
should follow Go idioms and return "", error
in case of errors rather than "undefined", error
<get>
types of tags would handle the mapping of ""
to "undefined"
for their own use. Find a way to make the constructor config object easier to get and use. It's stupid to need to import aichaos/rivescript-go/config
to get the config.Config{}
type for initializing RiveScript. The config type should be available directly from the parent package.
This might require refactoring to make the parent package include more logic for config handling rather than just proxying all methods through to the /src
versions, but that's probably a good thing anyway. The /src
package is private use only and I already spelled out in its docs that its API can be changed at any time without notice.
bot := rivescript.New(rivescript.BasicConfig())
OK So I have a rive script that looks like this:
Rivescript:
+ echo domain *
- What is <star1>
Go code (simplified):
var bot *rivescript.RiveScript
chatbot = rivescript.New(rivescript.WithUTF8())
err := chatbot.LoadDirectory("/path/to/rivescript/files")
errhandle(err)
bot.SortReplies()
// chatStr = echo domain www.google.com
reply, err := chatbot.Reply(userID, chatStr)
// reply = "What is wwwgooglecom"
What is happening is that rivescript appears to be stripping off the . in urls. Not sure why...
Hi,
It would be great if we can have a tool which can auto convert existing aiml files to rivescripts
would love to help on this.
thank you.
[^\s\d]
instead of [A-Za-z]
\s*
on both sides of the {weight}
tag to tolerate adjacent spaces.I've been noticing that user input with linebreaks seems to not match anything at all, not even the topmost catch-all rule. I've been solving for this in the meantime by stripping line breaks before passing the input to RiveScript, but wondering if this is a bug or intended behavior?
Hey -- I Love Rivescript -- I've implemented a chatbot that integrates into my companies proprietary chat system. Normally folks would open tickets to our team, and we'd go and pull info off of a server, put it in the ticket. Now those users can request that information using our chat system. Rivescript makes it VERY easy for the non-programmers to teach our chatbot new tricks.
+ show server uptime on *
- LocalComand ssh <star1> uptime
(User gets the output of 'LocalCommand')
What I would like is to eliminate the requirement to install redis for sessions. How hard would it be to write a client for Rivescript so that it could use one of the Go naitive databases like Ledis, or Bolt (I know there are others) that way the user can embed the database into their chatbot code, and not have a requirement.
Hi -- Is it possible using rivescript-go to define a regular expression? I am developing a chatbot where I ask the user for information for example if I need to get a serial number that is formatted like this:
123AB6-12C3-123EF456
> topic getserialnumber
+ lookup serial number in database
- Please enter your serial number
+ [A-Z0-9]{6}-[A-Z0-9]{4}-[A-Z0-9]{8}
- Cool, thank you, looking <star1> up
< topic
Is something like this possible?
the "@" is working fine but it still remove the "." .
I tried the example provided
// JavaScript Object Macro Examples
! version = 2.0
> object setvar javascript
// Example of how to get the current user's ID and set
// variables for them.
var uid = rs.CurrentUser();
var name = args[0];
var value = args[1];
rs.SetUservar(uid, name, value);
< object
+ javascript set * to *
- Set user variable <star1> to <star2>.<call>setvar <star1> <star2></call>
but it only ends in panic
http: panic serving [::1]:54453: reflect: Call using []interface {} as type string
goroutine 40 [running]:
net/http.(*conn).serve.func1(0xc042270000)
E:/dev/bin/go/src/net/http/server.go:1721 +0xd7
panic(0x8a0400, 0xc042284090)
E:/dev/bin/go/src/runtime/panic.go:489 +0x2dd
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.catchPanic.func1(0xc0422ee750)
E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/error.go:240 +0x3de
panic(0x8a0400, 0xc042284090)
E:/dev/bin/go/src/runtime/panic.go:489 +0x2dd
reflect.Value.call(0x8b7f20, 0xc0421b50e0, 0x13, 0x93fd98, 0x4, 0xc042119a90, 0x3, 0x3, 0x942b91, 0x8a0400, ...)
E:/dev/bin/go/src/reflect/value.go:371 +0x109b
reflect.Value.Call(0x8b7f20, 0xc0421b50e0, 0x13, 0xc042119a90, 0x3, 0x3, 0xc042284080, 0x98, 0x40ed49)
E:/dev/bin/go/src/reflect/value.go:302 +0xab
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.(*_runtime).toValue.func1(0xc042198000, 0x0, 0x0, 0x5, 0x92ff00, 0
xc0422ad6e0, 0xc0422ada40, 0x3, 0x4, 0xc0421132f0, ...)
E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/runtime.go:403 +0x6e7
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.(*_object).call(0xc0422adb00, 0x5, 0x92ff00, 0xc0422ad6e0, 0xc0422
ada40, 0x3, 0x4, 0x0, 0xc04229d5f0, 0x0, ...)
E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/type_function.go:140 +0x1bf
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.(*_runtime).cmpl_evaluate_nodeCallExpression(0xc042198000, 0xc0422
9d8f0, 0x0, 0x0, 0x0, 0xc04200bf50, 0xc0422eda00, 0x40d036)
E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/cmpl_evaluate_expression.go:244 +0x55e
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.(*_runtime).cmpl_evaluate_nodeExpression(0xc042198000, 0xbb2180, 0
xc04229d8f0, 0x8a0400, 0xc04200bf50, 0x6ed7a2)
E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/cmpl_evaluate_expression.go:44 +0x79b
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.(*_runtime).cmpl_evaluate_nodeStatement(0xc042198000, 0xbb2300, 0x
c0422aaa80, 0x0, 0x0, 0x0)
E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/cmpl_evaluate_statement.go:62 +0x11a4
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.(*_runtime).cmpl_evaluate_nodeStatementList(0xc042198000, 0xc0422a
8980, 0x2, 0x2, 0xc0425a9ed0, 0x470604, 0x8f5a60)
E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/cmpl_evaluate_statement.go:121 +0x7c
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.(*_runtime).cmpl_evaluate_nodeStatement(0xc042198000, 0xbb20c0, 0x
c0422a89a0, 0x0, 0x0, 0x0)
E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/cmpl_evaluate_statement.go:30 +0x6ef
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.(*_runtime).cmpl_call_nodeFunction(0xc042198000, 0xc0422ad1a0, 0xc
042135f20, 0xc0421cb400, 0x5, 0x92ff00, 0xc042188120, 0xc042135ef0, 0x2, 0x2, ...)
E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/cmpl_evaluate.go:61 +0x4fb
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.(*_object).call(0xc0422ad1a0, 0x5, 0x92ff00, 0xc042188120, 0xc0421
35ef0, 0x2, 0x2, 0xc04200be00, 0x0, 0x0, ...)
E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/type_function.go:157 +0x74d
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.(*_runtime).cmpl_evaluate_nodeCallExpression(0xc042198000, 0xc0421
35e90, 0xc0425aa9f0, 0x2, 0x2, 0x755e55, 0xc0425aa728, 0xc0425aa720)
E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/cmpl_evaluate_expression.go:244 +0x55e
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.Otto.Call.func2()
E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/otto.go:482 +0x62
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.catchPanic(0xc0425aa830, 0x0, 0x0)
E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/error.go:243 +0x73
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.Otto.Call(0x0, 0xc042198000, 0xc04200bbe0, 0xd, 0x0, 0x0, 0xc0425a
a9f0, 0x2, 0x2, 0x0, ...)
E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/otto.go:483 +0x7df
github.com/aichaos/rivescript-go/lang/javascript.JavaScriptHandler.Call(0xc0421132f0, 0xc042196000, 0xc0421b4ba0, 0xc042122361, 0x6, 0x
c042135db0, 0x2, 0x2, 0x1, 0xc0421c4000)
E:/dev/code/go/src/github.com/aichaos/rivescript-go/lang/javascript/javascript.go:102 +0x466
github.com/aichaos/rivescript-go/lang/javascript.(*JavaScriptHandler).Call(0xc04217c140, 0xc042122361, 0x6, 0xc042135db0, 0x2, 0x2, 0x3
, 0xc042122340)
<autogenerated>:2 +0x9e
github.com/aichaos/rivescript-go.(*RiveScript).processTags(0xc042196000, 0xc0422ba8e3, 0x2, 0xc0421e8f80, 0xf, 0xc042122340, 0x34, 0xc0
422a38a0, 0x2, 0x2, ...)
E:/dev/code/go/src/github.com/aichaos/rivescript-go/tags.go:511 +0x3653
github.com/aichaos/rivescript-go.(*RiveScript).getReply(0xc042196000, 0xc0422ba8e3, 0x2, 0xc0421e8f80, 0xf, 0x0, 0x0, 0xc042118323, 0x4
, 0x0, ...)
E:/dev/code/go/src/github.com/aichaos/rivescript-go/brain.go:411 +0xcc8
github.com/aichaos/rivescript-go.(*RiveScript).Reply(0xc042196000, 0xc0422ba8e3, 0x2, 0xc0421e8f80, 0xf, 0xc0422ba8ef, 0x3, 0xffffffff,
0x15)
E:/dev/code/go/src/github.com/aichaos/rivescript-go/brain.go:43 +0x515
main.RawIntentHandler(0xbb8480, 0xc042196460, 0xc04203ac00)
net/http.HandlerFunc.ServeHTTP(0x95a458, 0xbb8480, 0xc042196460, 0xc04203ac00)
E:/dev/bin/go/src/net/http/server.go:1942 +0x4b
main.Logger.func1(0xbb8480, 0xc042196460, 0xc04203ac00)
net/http.HandlerFunc.ServeHTTP(0xc0422b6040, 0xbb8480, 0xc042196460, 0xc04203ac00)
E:/dev/bin/go/src/net/http/server.go:1942 +0x4b
github.com/gorilla/mux.(*Router).ServeHTTP(0xc04213efa0, 0xbb8480, 0xc042196460, 0xc04203ac00)
E:/dev/code/go/src/github.com/gorilla/mux/mux.go:114 +0x113
net/http.serverHandler.ServeHTTP(0xc04215c0b0, 0xbb8480, 0xc042196460, 0xc042154100)
E:/dev/bin/go/src/net/http/server.go:2568 +0x99
net/http.(*conn).serve(0xc042270000, 0xbb8c80, 0xc042012580)
E:/dev/bin/go/src/net/http/server.go:1825 +0x619
created by net/http.(*Server).Serve
E:/dev/bin/go/src/net/http/server.go:2668 +0x2d5
Is there any functionality in rivescript-go library to plugin a session manager as in rivescript-python library as this example: https://github.com/aichaos/rivescript-python/tree/master/eg/sessions
If not Please suggest me a method to persistently store the session and chat contexts/history.
Hi,
I'm can't figure out how to use a golang object macro. On top of that I have no idea what is available in the object definition or how to inject context, if possible like in the js version.
I've tried both > object foo go
and object foo golang
and both give me the [ERR: Object Not Found]
so I'm going to assume that it isn't supported. And I see that only javascript
and text
are tested.
I would love to not have to touch javascript at all. Thanks. I am getting pretty excited about rivescript.
trigger
[*] beer [*]
works fine
but
[*] пиво [*]
doesn't works
Any idea how to solve such situation?
I have a trigger
+ # + #
- Adding <star1> and <star2>
But it never matches... looks like the + in the middle is confusing the parser... So how do I write this for inputs like
10+22
In case when create custom SessionManager.
Condition in this string doesn't work, because here pass default param.
Must be:
bot.rs.Configure(cfg.Debug, cfg.Strict, cfg.UTF8, cfg.Depth, cfg.SessionManager)
cannot find package "github.com/aichaos/rivescript-go/src" in any of:
github.com/aichaos/rivescript-go/src does not exist in current repo...and it does not work.. Whats the alternative?
I had written a python macro in .rive file. I ran it earlier using python interpreter and it worked fine. But, now when I'm running it using go interpreter it gives me an error.
[ERR: Object Not Found]
Please help me..!!
just wondering how you liked golang for this project? I'm a bit fedup wtih JS but not sure where to jump next. go seems much more C like and strict - for example parsing JSON you have to declare structs in advance... so maybe not as good for moving fast. but with pointers and other features it gives more fine grained control. presumably goroutines obviate the need for callback hell too...
but for something as freeform a dialect as rivescript, how did you find writing the interpreter compared to say the python port?
When a redirection is called for a different reply, the text should be lowercased and probably run through the same filters that an original message is.
The following code demonstrates the issue:
! var master = Kirsle
+ my name is (<bot master>)
- <set name=<formal>>That's my master's name too.
+ call me <bot master>
@ my name is <bot master>
If you say "call me kirsle" it will try to redirect and find a match for my name is Kirsle
(with a capital K), which doesn't satisfy the regular expression /my name is kirsle/
of the first trigger. The result is a "No reply matched" error.
Lowercasing it in the RiveScript code doesn't work around this problem:
+ call me <bot master>
@ my name is {lowercase}<bot master>{/lowercase}
Catching it in a <star>
works though in the mean time:
+ call me (<bot master>)
@ my name is <star>
Also look into the other RiveScript implementations and see if they're affected by this bug.
@kirsle
This library is not thread safe. It panics and raises fatal error in multi threaded environment. This is because you are not handling concurrent read and write of maps which is not thread safe in golang. Please see these posts for reference:
I'm also posting the error message for your reference.
fatal error: concurrent map read and map write
goroutine 51 [running]:
runtime.throw(0x89e4a0, 0x21)
/home/ravi/Work/software/go/src/runtime/panic.go:530 +0x90 fp=0xc8206221f8 sp=0xc8206221e0
runtime.mapaccess1_faststr(0x727aa0, 0xc820011a10, 0xc82000a538, 0x2, 0x1)
/home/ravi/Work/software/go/src/runtime/hashmap_fast.go:202 +0x5b fp=0xc820622258 sp=0xc8206221f8
github.com/aichaos/rivescript-go.(*RiveScript).processTags(0xc8200ce580, 0xc82000a538, 0x2, 0xc82019451a, 0xa, 0xc8200cb7a0, 0x16, 0xc8206228e0, 0x0, 0x0, ...)
/home/ravi/Work/go/src/github.com/aichaos/rivescript-go/tags.go:227 +0xcd1 fp=0xc820622860 sp=0xc820622258
github.com/aichaos/rivescript-go.(*RiveScript).getReply(0xc8200ce580, 0xc82000a538, 0x2, 0xc82019451a, 0xa, 0x0, 0x1, 0x0, 0x0)
/home/ravi/Work/go/src/github.com/aichaos/rivescript-go/brain.go:400 +0x28ce fp=0xc820622f10 sp=0xc820622860
github.com/aichaos/rivescript-go.(*RiveScript).processTags(0xc8200ce580, 0xc82000a538, 0x2, 0xc8204efbd8, 0x2, 0xc820194510, 0x30, 0xc82000a560, 0x1, 0x1, ...)
/home/ravi/Work/go/src/github.com/aichaos/rivescript-go/tags.go:435 +0x22c7 fp=0xc820623518 sp=0xc820622f10
github.com/aichaos/rivescript-go.(*RiveScript).getReply(0xc8200ce580, 0xc82000a538, 0x2, 0xc8204efbd8, 0x2, 0x0, 0x0, 0x0, 0x0)
/home/ravi/Work/go/src/github.com/aichaos/rivescript-go/brain.go:400 +0x28ce fp=0xc820623bc8 sp=0xc820623518
github.com/aichaos/rivescript-go.(*RiveScript).Reply(0xc8200ce580, 0xc82000a538, 0x2, 0xc8204efbd8, 0x2, 0x0, 0x0)
/home/ravi/Work/go/src/github.com/aichaos/rivescript-go/brain.go:42 +0x47b fp=0xc820623d60 sp=0xc820623bc8
Please resolve this bug.
A suggestion from my side is to use concurrent-map instead of golang inbuilt maps.
There doesn't seem to be any way to get at the un-simplified input
e.g., input of
Jenny's place -> Jennys place
in a function
would like to be able to see Jenny's place not Jennys place
Did I miss it somehow?
also fine to get the whole input not just the if that's available
Hi,
I am trying to build a telegram bot and using Echo web framework.
trying to integrate this library but unable to do so.
here is my sample function code which is called during webhook call
func NewMsg(message *models.Message) (string, error) {
botbrain := brain.New(brain.UTF8())
botbrain.SetHandler("javascript", brain.NewJSHandler(botbrain))
err := botbrain.LoadDirectory("../rivescripts/")
if err != nil {
log.Printf("Error loading directory: %s", err)
os.Exit(1)
}
botbrain.SortReplies()
reply := botbrain.Reply(strconv.Itoa(int(message.User.ID)), message.Text)
return reply, nil
}
but it gives ERR: Replies Not Sorted
Can you please help?
Via @marceloverdijk on Slack:
Line 81 in 7f29a68
This regexp is incorrect and should be patched as follows:
- pipes = strings.Replace(pipes, `(\d+?)`, `(?:\w+?)`, -1)
+ pipes = strings.Replace(pipes, `(\w+?)`, `(?:\w+?)`, -1)
And add a unit test that checks for wildcards in optionals like [_]
and [#]
for good measure.
Tried with compiled and self-compiled versions.
Using examples from https://pkg.go.dev/github.com/aichaos/rivescript-go/lang/javascript any time I try to execute any javascript, I just get my reply for unknown question.
I got the pre-compiled from the releases page, just pulled and built the cmd directory here. Am I compiling it the wrong way?
I've noticed in the recent revision of this library RiveScript.SetSubroutine
no longer works due to what appears to be a type mismatch:
For example, with the following code:
package main
import "github.com/aichaos/rivescript-go"
main() {
bot := rivescript.New(nil)
bot.SetSubroutine("test", func(rs *rivescript.RiveScript, args []string) string {
return "Oh, hello."
})
}
…results in the following error:
cannot use func literal (type func(*"github.com/aichaos/rivescript-go".RiveScript, []string) string) string) as type "chat/vendor/github.com/aichaos/rivescript-go/src".Subroutine in argument to bot.SetSubroutine
…which makes me think the issues lies in the fact that "rivescript-go/src".Submodule
expects "rivescript-go/src".RiveScript
as the first argument whereas "rivescript-go".RiveScript.SetSubmodule
expects the local "rivescript-go".RiveScript
as an argument, hence the type error.
It'd be nice if rivescript-go were able to parse and run Python object macros for RiveScript bots, by using the Python C API.
There are two projects I found so far: sbinet/go-python and qur/gopy. They both only support Python 2 so far, but that will work for now.
I did some experimenting and came up with the following Go code that demonstrates the key pieces of functionality needed: dynamically parse a Python function, call the function giving it an array of string arguments, and retrieve the result of the function as a Go string.
package main
import (
"fmt"
"github.com/sbinet/go-python"
)
func init() {
err := python.Initialize()
if err != nil {
panic(err.Error())
}
}
func main() {
// The source code of the python function we wanna be able to call.
pycode := `
def test(rs, args):
print "Test works"
return "Forwards: {}\nBackwards: {}".format(
" ".join(args),
" ".join(args[::-1]),
)
`
// The []string to use as the 'args' param to `def test()`
args := StringList_ToPython("Hello", "world")
defer args.DecRef() // Always do this so Python can count references well.
// To load the function you can simply eval the code in the global scope:
python.PyRun_SimpleString(pycode)
// Get the main module's dictionary so we can get a reference to our
// function back out of it.
main_module := python.PyImport_AddModule("__main__")
main_dict := python.PyModule_GetDict(main_module)
test_function := python.PyDict_GetItemString(main_dict, "test")
// The tuple of (rs, args) arguments to pass to the function.
// This tuple is the *args in Python lingo.
test_args := python.PyTuple_New(2)
defer test_args.DecRef()
python.PyTuple_SetItem(test_args, 0, python.Py_None)
python.PyTuple_SetItem(test_args, 1, args)
// Call the actual Python function now. Functions return a *PyObject, and
// we can cast it back to a string.
returned := test_function.CallObject(test_args)
result := python.PyString_AsString(returned)
// Print the result of the function.
fmt.Println("Result:", result)
}
// StringList_ToPython is a helper function that simply converts a Go []string
// into a Python List of the same length with the same contents.
func StringList_ToPython(items... string) *python.PyObject {
list := python.PyList_New(len(items))
for i, item := range items {
python.PyList_SetItem(list, i, python.PyString_FromString(item))
}
return list
}
This code lets us:
*args
tuple, converting Go strings into Python strings for the args
argument (which is a list(str)
type)The other huge TODO is the rs
parameter to the Python function: the above code sends in a NoneType
, but IRL it would need to provide an object with at least a subset of the RiveScript API (most importantly, functions like rs.current_user()
and rs.set_uservar()
& friends). I imagine to expose the full RiveScript API to Python I'd need to write a whole wrapper class that translates all the arguments to/from Python types, but I'll probably just focus on the aforementioned useful functions to start out with.
Hi, this operator (?) in goo language causes errors .
$ go run .
[WARN] Unknown command '?' at brain\index.rive line 2
[WARN] Response found before trigger at brain\index.rive line 3
[WARN] Response found before trigger at brain\index.rive line 4
Should macros execute and return before a conditional is evaluated? Currently, in a case such as this…
+ my name is *
* <call>isHisNameFrank <star></call> == true => Welcome, Frank.
- You’re not Frank. Go find Frank.
…it appears that the macro not being called at all.
An issue in the JavaScript RiveScript project makes me think the expected behavior is that macros should indeed execute before the conditional is evaluated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.