• ANN: Dogelog Runtime 1.6.0 (POST Requests)

    From Mostowski Collapse@janburse@fastmail.fm to comp.lang.prolog on Sun May 21 15:19:50 2023
    From Newsgroup: comp.lang.prolog

    (Sorry for multiple posts, looks like my human
    post mechanism isn't working correctly)

    Dear All,

    We are happy to announce a new version of the former
    Jekejeke runtime 1.6.0, now called Dogelog runtime.

    - Script Mode: The Prolog flag argv is now supported.
    The Prolog interpreter can be called in the form
    "prolog text arg1 .. argn". The "text" file is then
    automatically consulted and "arg1 .. argn" ends up
    in argv as a list of prolog atoms. Furthermore,
    there is now the directive initialization/1. Both
    features are also available in Dogelog Player.

    - POST Requests: The open/[3,4] predicates have long
    been able to understand the http: and https: protocol.
    The new options method/1, headers/1 and body/1 are
    self-explanatory. The options are also available in
    Dogelog players, but support is not yet universal
    across platforms. Jekejeke Prolog should use sys_open/4
    temporarily until we adjust path searching.

    - Affine JSON: There is a new library(util/json)
    that delivers read_json/[1,2] and write_json/[1,2].
    The mapping is affine, since we map JSON lists to
    prolog lists and JSON structures to prolog sets.
    We also use the new constants 0rNone, 0rFalse
    and 0rTrue. Library also available as
    library(json) in Dogelog player.

    Have Fun!
    Jan Burse, 21.05.2023, http://www.xlog.ch/
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Mostowski Collapse@bursejan@gmail.com to comp.lang.prolog on Mon May 22 11:42:22 2023
    From Newsgroup: comp.lang.prolog

    Concerning the ChatGPT example. Its good to see that it
    also works in SWI-Prolog. Here are some results:
    I guess one can build a SWI-Prolog server that acts as a
    ChatGPT relay, accepting some request, and in turn
    making a request on the OpenAI API. So the bearer token
    from OpenAI API remains in the SWI-Prolog relay,
    and doesn’t become visible to the end user browser
    client. It seems it is possibly to make the afforementioned
    request via http_open/3, since server side no CORS needs
    to be in effect. CORS is only a browser safety thingy.
    This example code worked for me:
    :- use_module(library(http/http_open)).
    :- use_module(library(http/json)).
    quizzswi :-
    atom_json_term(Request, _{model:'text-davinci-003',
    prompt:'Generate a single random multiple choice quizz about Switzerland',
    max_tokens:100,
    temperature:0.7,
    n:1}, []),
    http_open('https://api.openai.com/v1/completions', Stream, [authorization(
    bearer('###########')),
    post(atom('application/json', Request))]),
    json_read(Stream, Response),
    close(Stream),
    write(Response), nl.
    Mostowski Collapse schrieb am Sonntag, 21. Mai 2023 um 15:19:54 UTC+2:
    (Sorry for multiple posts, looks like my human
    post mechanism isn't working correctly)

    Dear All,

    We are happy to announce a new version of the former
    Jekejeke runtime 1.6.0, now called Dogelog runtime.

    - Script Mode: The Prolog flag argv is now supported.
    The Prolog interpreter can be called in the form
    "prolog text arg1 .. argn". The "text" file is then
    automatically consulted and "arg1 .. argn" ends up
    in argv as a list of prolog atoms. Furthermore,
    there is now the directive initialization/1. Both
    features are also available in Dogelog Player.

    - POST Requests: The open/[3,4] predicates have long
    been able to understand the http: and https: protocol.
    The new options method/1, headers/1 and body/1 are
    self-explanatory. The options are also available in
    Dogelog players, but support is not yet universal
    across platforms. Jekejeke Prolog should use sys_open/4
    temporarily until we adjust path searching.

    - Affine JSON: There is a new library(util/json)
    that delivers read_json/[1,2] and write_json/[1,2].
    The mapping is affine, since we map JSON lists to
    prolog lists and JSON structures to prolog sets.
    We also use the new constants 0rNone, 0rFalse
    and 0rTrue. Library also available as
    library(json) in Dogelog player.

    Have Fun!
    Jan Burse, 21.05.2023, http://www.xlog.ch/
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Mostowski Collapse@janburse@fastmail.fm to comp.lang.prolog on Mon May 22 20:44:25 2023
    From Newsgroup: comp.lang.prolog

    You need to replace ########### by your API token. It gives me:

    /* SWI-Prolog 9.1.9 */
    ?- quizzswi. json([id=cmpl-7J4ek6NK0ICXXKv0P69F7uHWOx3jg,object=text_completion, created=1684780486,model=text-davinci-003,choices=[json([text=

    Q. What is the official language of Switzerland?
    A. A. French
    B. German
    C. Italian
    D. Swiss German,index=0,logprobs= @(null),finish_reason=stop])], usage=json([prompt_tokens=10,completion_tokens=35,total_tokens=45])])
    true.

    Have Fun!

    Mostowski Collapse schrieb:
    Concerning the ChatGPT example. Its good to see that it
    also works in SWI-Prolog. Here are some results:

    I guess one can build a SWI-Prolog server that acts as a
    ChatGPT relay, accepting some request, and in turn
    making a request on the OpenAI API. So the bearer token
    from OpenAI API remains in the SWI-Prolog relay,

    and doesn’t become visible to the end user browser
    client. It seems it is possibly to make the afforementioned
    request via http_open/3, since server side no CORS needs
    to be in effect. CORS is only a browser safety thingy.

    This example code worked for me:

    :- use_module(library(http/http_open)).
    :- use_module(library(http/json)).

    quizzswi :-
    atom_json_term(Request, _{model:'text-davinci-003',
    prompt:'Generate a single random multiple choice quizz about Switzerland',
    max_tokens:100,
    temperature:0.7,
    n:1}, []),
    http_open('https://api.openai.com/v1/completions', Stream, [authorization(
    bearer('###########')),
    post(atom('application/json', Request))]),
    json_read(Stream, Response),
    close(Stream),
    write(Response), nl.

    Mostowski Collapse schrieb am Sonntag, 21. Mai 2023 um 15:19:54 UTC+2:
    (Sorry for multiple posts, looks like my human
    post mechanism isn't working correctly)

    Dear All,

    We are happy to announce a new version of the former
    Jekejeke runtime 1.6.0, now called Dogelog runtime.

    - Script Mode: The Prolog flag argv is now supported.
    The Prolog interpreter can be called in the form
    "prolog text arg1 .. argn". The "text" file is then
    automatically consulted and "arg1 .. argn" ends up
    in argv as a list of prolog atoms. Furthermore,
    there is now the directive initialization/1. Both
    features are also available in Dogelog Player.

    - POST Requests: The open/[3,4] predicates have long
    been able to understand the http: and https: protocol.
    The new options method/1, headers/1 and body/1 are
    self-explanatory. The options are also available in
    Dogelog players, but support is not yet universal
    across platforms. Jekejeke Prolog should use sys_open/4
    temporarily until we adjust path searching.

    - Affine JSON: There is a new library(util/json)
    that delivers read_json/[1,2] and write_json/[1,2].
    The mapping is affine, since we map JSON lists to
    prolog lists and JSON structures to prolog sets.
    We also use the new constants 0rNone, 0rFalse
    and 0rTrue. Library also available as
    library(json) in Dogelog player.

    Have Fun!
    Jan Burse, 21.05.2023, http://www.xlog.ch/

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Mostowski Collapse@bursejan@gmail.com to comp.lang.prolog on Thu May 25 02:20:43 2023
    From Newsgroup: comp.lang.prolog

    Note: In some new examples I am using 'argv' together with
    some config.p file, which is a nice example that shows a
    library(macro) would be useless.
    Basically it can be more versatile to have facts. For example
    the following doesn’t work with (#)/1 expansion. First the
    facts, the “configuration” file:
    foo(a).
    foo(b).
    bar(a, jack).
    bar(b, jill).
    bar(c, baz).
    Now the client code, some failure driven loop:
    :- (foo(X), bar(X,Y), do_something(X,Y), fail; true).
    One cannot do this with compile time expansion.
    Unless one wants to expand it to:
    :- (do_something(a,jack), fail;
    do_something(b,jill), fail;
    true).
    But individually expanded #a and #b at compile time
    into jack and jill would be useless.
    Mostowski Collapse schrieb am Montag, 22. Mai 2023 um 20:46:33 UTC+2:
    You need to replace ########### by your API token. It gives me:

    /* SWI-Prolog 9.1.9 */
    ?- quizzswi. json([id=cmpl-7J4ek6NK0ICXXKv0P69F7uHWOx3jg,object=text_completion, created=1684780486,model=text-davinci-003,choices=[json([text=

    Q. What is the official language of Switzerland?
    A. A. French
    B. German
    C. Italian
    D. Swiss German,index=0,logprobs= @(null),finish_reason=stop])], usage=json([prompt_tokens=10,completion_tokens=35,total_tokens=45])])
    true.

    Have Fun!

    Mostowski Collapse schrieb:
    Concerning the ChatGPT example. Its good to see that it
    also works in SWI-Prolog. Here are some results:

    I guess one can build a SWI-Prolog server that acts as a
    ChatGPT relay, accepting some request, and in turn
    making a request on the OpenAI API. So the bearer token
    from OpenAI API remains in the SWI-Prolog relay,

    and doesn’t become visible to the end user browser
    client. It seems it is possibly to make the afforementioned
    request via http_open/3, since server side no CORS needs
    to be in effect. CORS is only a browser safety thingy.

    This example code worked for me:

    :- use_module(library(http/http_open)).
    :- use_module(library(http/json)).

    quizzswi :-
    atom_json_term(Request, _{model:'text-davinci-003',
    prompt:'Generate a single random multiple choice quizz about Switzerland', max_tokens:100,
    temperature:0.7,
    n:1}, []),
    http_open('https://api.openai.com/v1/completions', Stream, [authorization( bearer('###########')),
    post(atom('application/json', Request))]),
    json_read(Stream, Response),
    close(Stream),
    write(Response), nl.

    Mostowski Collapse schrieb am Sonntag, 21. Mai 2023 um 15:19:54 UTC+2:
    (Sorry for multiple posts, looks like my human
    post mechanism isn't working correctly)

    Dear All,

    We are happy to announce a new version of the former
    Jekejeke runtime 1.6.0, now called Dogelog runtime.

    - Script Mode: The Prolog flag argv is now supported.
    The Prolog interpreter can be called in the form
    "prolog text arg1 .. argn". The "text" file is then
    automatically consulted and "arg1 .. argn" ends up
    in argv as a list of prolog atoms. Furthermore,
    there is now the directive initialization/1. Both
    features are also available in Dogelog Player.

    - POST Requests: The open/[3,4] predicates have long
    been able to understand the http: and https: protocol.
    The new options method/1, headers/1 and body/1 are
    self-explanatory. The options are also available in
    Dogelog players, but support is not yet universal
    across platforms. Jekejeke Prolog should use sys_open/4
    temporarily until we adjust path searching.

    - Affine JSON: There is a new library(util/json)
    that delivers read_json/[1,2] and write_json/[1,2].
    The mapping is affine, since we map JSON lists to
    prolog lists and JSON structures to prolog sets.
    We also use the new constants 0rNone, 0rFalse
    and 0rTrue. Library also available as
    library(json) in Dogelog player.

    Have Fun!
    Jan Burse, 21.05.2023, http://www.xlog.ch/
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Mild Shock@bursejan@gmail.com to comp.lang.prolog on Sat May 27 05:31:24 2023
    From Newsgroup: comp.lang.prolog

    One could use prefix (‘.’)/1 instead of (#)/1. So that it is kind of a special case of the dict dot notation, refering to a kind of a global
    context. At least the Prolog parser seems to be able to read such terms:
    ?- op(10, fx, '.').
    true.
    ?- X = .a .
    X = '.'a.
    So if we have a dict X with some constant max, its already possible
    to write the following code:
    /* SWI-Prolog 9.1.9 */
    ?- X = _{foo:123, bar:'baz', max:100}, write(X.max), nl.
    100
    X = _{bar:baz, foo:123, max:100}.
    The writing of .max alone, without a receiver would indicate that
    we refer to some global definition. A variant of User defined
    functions on dicts:
    /* Hypothetical */
    .max := 100.
    ?- write(.max), nl.
    100
    Or extend function on dicts that they understand a receiver which
    is not a dict, but a name of a dict, somewhere define. Could also
    lead to some modularization of constants.
    Mostowski Collapse schrieb am Donnerstag, 25. Mai 2023 um 11:20:45 UTC+2:
    Note: In some new examples I am using 'argv' together with
    some config.p file, which is a nice example that shows a
    library(macro) would be useless.

    Basically it can be more versatile to have facts. For example
    the following doesn’t work with (#)/1 expansion. First the
    facts, the “configuration” file:

    foo(a).
    foo(b).

    bar(a, jack).
    bar(b, jill).
    bar(c, baz).

    Now the client code, some failure driven loop:

    :- (foo(X), bar(X,Y), do_something(X,Y), fail; true).

    One cannot do this with compile time expansion.
    Unless one wants to expand it to:

    :- (do_something(a,jack), fail;
    do_something(b,jill), fail;
    true).

    But individually expanded #a and #b at compile time
    into jack and jill would be useless.
    Mostowski Collapse schrieb am Montag, 22. Mai 2023 um 20:46:33 UTC+2:
    You need to replace ########### by your API token. It gives me:

    /* SWI-Prolog 9.1.9 */
    ?- quizzswi. json([id=cmpl-7J4ek6NK0ICXXKv0P69F7uHWOx3jg,object=text_completion, created=1684780486,model=text-davinci-003,choices=[json([text=

    Q. What is the official language of Switzerland?
    A. A. French
    B. German
    C. Italian
    D. Swiss German,index=0,logprobs= @(null),finish_reason=stop])], usage=json([prompt_tokens=10,completion_tokens=35,total_tokens=45])]) true.

    Have Fun!

    Mostowski Collapse schrieb:
    Concerning the ChatGPT example. Its good to see that it
    also works in SWI-Prolog. Here are some results:

    I guess one can build a SWI-Prolog server that acts as a
    ChatGPT relay, accepting some request, and in turn
    making a request on the OpenAI API. So the bearer token
    from OpenAI API remains in the SWI-Prolog relay,

    and doesn’t become visible to the end user browser
    client. It seems it is possibly to make the afforementioned
    request via http_open/3, since server side no CORS needs
    to be in effect. CORS is only a browser safety thingy.

    This example code worked for me:

    :- use_module(library(http/http_open)).
    :- use_module(library(http/json)).

    quizzswi :-
    atom_json_term(Request, _{model:'text-davinci-003',
    prompt:'Generate a single random multiple choice quizz about Switzerland',
    max_tokens:100,
    temperature:0.7,
    n:1}, []),
    http_open('https://api.openai.com/v1/completions', Stream, [authorization(
    bearer('###########')),
    post(atom('application/json', Request))]),
    json_read(Stream, Response),
    close(Stream),
    write(Response), nl.

    Mostowski Collapse schrieb am Sonntag, 21. Mai 2023 um 15:19:54 UTC+2:
    (Sorry for multiple posts, looks like my human
    post mechanism isn't working correctly)

    Dear All,

    We are happy to announce a new version of the former
    Jekejeke runtime 1.6.0, now called Dogelog runtime.

    - Script Mode: The Prolog flag argv is now supported.
    The Prolog interpreter can be called in the form
    "prolog text arg1 .. argn". The "text" file is then
    automatically consulted and "arg1 .. argn" ends up
    in argv as a list of prolog atoms. Furthermore,
    there is now the directive initialization/1. Both
    features are also available in Dogelog Player.

    - POST Requests: The open/[3,4] predicates have long
    been able to understand the http: and https: protocol.
    The new options method/1, headers/1 and body/1 are
    self-explanatory. The options are also available in
    Dogelog players, but support is not yet universal
    across platforms. Jekejeke Prolog should use sys_open/4
    temporarily until we adjust path searching.

    - Affine JSON: There is a new library(util/json)
    that delivers read_json/[1,2] and write_json/[1,2].
    The mapping is affine, since we map JSON lists to
    prolog lists and JSON structures to prolog sets.
    We also use the new constants 0rNone, 0rFalse
    and 0rTrue. Library also available as
    library(json) in Dogelog player.

    Have Fun!
    Jan Burse, 21.05.2023, http://www.xlog.ch/
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Mild Shock@janburse@fastmail.fm to comp.lang.prolog on Tue May 30 18:35:20 2023
    From Newsgroup: comp.lang.prolog


    Dogelog Player is a Prolog system 100%
    written in Prolog based on Novacore, a
    very small Prolog kernel and bundled set
    of libraries. We started adopting the
    Novacore libraries by formerly Jekejeke
    Prolog and are now heading into
    allowing them for GNU Prolog.

    GNU Prolog doesn’t support bigint or
    Unicode, which we could workaround in
    that we disabled these test cases. Maybe
    there are forks around that support these
    features? The results are encouraging,
    GNU Prolog currently has some precentage
    failure rate around 25%.

    See also:

    Novacore Libraries on GNU Prolog https://twitter.com/dogelogch/status/1663580904885714958

    Novacore Libraries on GNU Prolog
    https://www.facebook.com/groups/dogelog

    Mostowski Collapse schrieb:
    (Sorry for multiple posts, looks like my human
    post mechanism isn't working correctly)

    Dear All,

    We are happy to announce a new version of the former
    Jekejeke runtime 1.6.0, now called Dogelog runtime.

    - Script Mode: The Prolog flag argv is now supported.
    The Prolog interpreter can be called in the form
    "prolog text arg1 .. argn". The "text" file is then
    automatically consulted and "arg1 .. argn" ends up
    in argv as a list of prolog atoms. Furthermore,
    there is now the directive initialization/1. Both
    features are also available in Dogelog Player.

    - POST Requests: The open/[3,4] predicates have long
    been able to understand the http: and https: protocol.
    The new options method/1, headers/1 and body/1 are
    self-explanatory. The options are also available in
    Dogelog players, but support is not yet universal
    across platforms. Jekejeke Prolog should use sys_open/4
    temporarily until we adjust path searching.

    - Affine JSON: There is a new library(util/json)
    that delivers read_json/[1,2] and write_json/[1,2].
    The mapping is affine, since we map JSON lists to
    prolog lists and JSON structures to prolog sets.
    We also use the new constants 0rNone, 0rFalse
    and 0rTrue. Library also available as
    library(json) in Dogelog player.

    Have Fun!
    Jan Burse, 21.05.2023, http://www.xlog.ch/

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Mild Shock@janburse@fastmail.fm to comp.lang.prolog on Wed Jun 7 20:50:16 2023
    From Newsgroup: comp.lang.prolog


    We recently submerged into accessing OpenAI API
    via HTTP POST requests. They are now supported by
    both Jekejeke Prolog and Dogelog Player. While
    testing the Dogelog Player HTTP POST requests we
    stepped over some limitation of common echo
    servers and built our own.

    We chose the Java based implementation from
    Apache of the Tomcat web server that can even
    serve the HTTP/2 protocol. By means of our Echo
    servlet we could start testing Dogelog Player
    in the browser, concerning the new support for
    open options method/1, body/1 and headers/1.

    See also:

    Roll your Echo Server via Tomcat - Dogelog, 2023 https://twitter.com/dogelogch/status/1666516167152771095

    Roll your Echo Server via Tomcat - Dogelog, 2023 https://www.facebook.com/groups/dogelog
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Mild Shock@bursejan@gmail.com to comp.lang.prolog on Mon Jul 17 03:51:59 2023
    From Newsgroup: comp.lang.prolog

    Althout Python has a Decimal module and decimal
    modules exist for nodeJS. Decimals did not yet make
    it into Dogelog Player, and are also still a moving target in
    Jekejeke Prolog. We did a small refinement for Jekejeke
    Prolog concering basic arithmethic and comparison.

    The money type provided us with mathematical
    functions, but it also enlarged the native footprint. We
    removed the money type and went with an Prolog
    module to overload basic arithmetic. We also fixed
    the syntactic comparison problem for BigDecimals.

    See also:

    Improved Decimals in Jekejeke Prolog https://twitter.com/dogelogch/status/1680891639449939971

    Improved Decimals in Jekejeke Prolog
    https://www.facebook.com/groups/dogelog
    --- Synchronet 3.20a-Linux NewsLink 1.114