(Sorry for multiple posts, looks like my human--- Synchronet 3.20a-Linux NewsLink 1.114
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/
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/
You need to replace ########### by your API token. It gives me:--- Synchronet 3.20a-Linux NewsLink 1.114
/* 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/
Note: In some new examples I am using 'argv' together with--- Synchronet 3.20a-Linux NewsLink 1.114
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/
(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/
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 920 |
Nodes: | 10 (1 / 9) |
Uptime: | 77:19:50 |
Calls: | 12,187 |
Calls today: | 2 |
Files: | 186,526 |
Messages: | 2,236,883 |