@foundationui/react-hooks
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -1,1 +0,1 @@ | ||
"use strict";var e=require("react");exports.useFoundationModel=function(o){var t=e.useState("undefined"!=typeof crypto?crypto.randomUUID():"".concat((new Date).getTime()))[0],n=o.dev?"http://localhost:7777/smartinput":"https://api.foundation-ui.com/smartinput",r=e.useMemo((function(){return function(e,r){return fetch("".concat(n,"/sessions"),{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify([{model:o.model,user:o.user,session:t,input:e,context:r}])}).then((function(e){return e.json()})).catch((function(e){return console.error(e)}))}}),[o.model,o.user,n]),c=e.useMemo((function(){return function(e,r){return fetch("".concat(n,"/completions"),{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:o.model,user:o.user,safeMode:o.safeMode,session:t,input:e,context:r})}).then((function(e){return 200!==e.status&&console.error("Error getting completion"),e.json()})).catch((function(e){return console.error(e),null}))}}),[o.model,o.user,o.dev,o.safeMode]),s=e.useMemo((function(){return function(e){fetch("".concat(n,"/completions"),{method:"PUT",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({completionSid:e,seen:!0})}).then((function(e){200!==e.status&&console.error("Couldn't update completion to seen")})).catch((function(e){return console.error(e)}))}}),[n]),i=e.useMemo((function(){return function(e){fetch("".concat(n,"/completions"),{method:"PUT",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({completionSid:e,accepted:!0})}).then((function(e){200!==e.status&&console.error("Couldn't update completion to accepted")})).catch((function(e){return console.error(e)}))}}),[n]);return{model:o.model,user:o.user,saveCompletion:r,getCompletion:c,markCompletionSeen:s,markCompletionAccepted:i}}; | ||
"use strict";var e=require("react");exports.useFoundationModel=function(o){var t=e.useState("undefined"!=typeof crypto?crypto.randomUUID():"".concat((new Date).getTime()))[0],n=o.dev?"http://localhost:7777/platform":"https://api.foundation-ui.com/platform",r=e.useMemo((function(){return function(e,r){return fetch("".concat(n,"/sessions"),{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify([{model:o.model,user:o.user,session:t,input:e,context:r}])}).then((function(e){return e.json()})).catch((function(e){return console.error(e)}))}}),[o.model,o.user,n]),c=e.useMemo((function(){return function(e,r){return fetch("".concat(n,"/completions"),{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:o.model,user:o.user,safeMode:o.safeMode,session:t,input:e,context:r})}).then((function(e){return 200!==e.status&&console.error("Error getting completion"),e.json()})).catch((function(e){return console.error(e),null}))}}),[o.model,o.user,o.dev,o.safeMode]),s=e.useMemo((function(){return function(e){fetch("".concat(n,"/completions"),{method:"PUT",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({completionSid:e,seen:!0})}).then((function(e){200!==e.status&&console.error("Couldn't update completion to seen")})).catch((function(e){return console.error(e)}))}}),[n]),i=e.useMemo((function(){return function(e){fetch("".concat(n,"/completions"),{method:"PUT",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({completionSid:e,accepted:!0})}).then((function(e){200!==e.status&&console.error("Couldn't update completion to accepted")})).catch((function(e){return console.error(e)}))}}),[n]);return{model:o.model,user:o.user,saveCompletion:r,getCompletion:c,markCompletionSeen:s,markCompletionAccepted:i}}; |
@@ -1,1 +0,1 @@ | ||
import e from"react";function o(o){var t=e.useState("undefined"!=typeof crypto?crypto.randomUUID():"".concat((new Date).getTime()))[0],n=o.dev?"http://localhost:7777/smartinput":"https://api.foundation-ui.com/smartinput",r=e.useMemo((function(){return function(e,r){return fetch("".concat(n,"/sessions"),{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify([{model:o.model,user:o.user,session:t,input:e,context:r}])}).then((function(e){return e.json()})).catch((function(e){return console.error(e)}))}}),[o.model,o.user,n]),c=e.useMemo((function(){return function(e,r){return fetch("".concat(n,"/completions"),{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:o.model,user:o.user,safeMode:o.safeMode,session:t,input:e,context:r})}).then((function(e){return 200!==e.status&&console.error("Error getting completion"),e.json()})).catch((function(e){return console.error(e),null}))}}),[o.model,o.user,o.dev,o.safeMode]),s=e.useMemo((function(){return function(e){fetch("".concat(n,"/completions"),{method:"PUT",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({completionSid:e,seen:!0})}).then((function(e){200!==e.status&&console.error("Couldn't update completion to seen")})).catch((function(e){return console.error(e)}))}}),[n]),i=e.useMemo((function(){return function(e){fetch("".concat(n,"/completions"),{method:"PUT",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({completionSid:e,accepted:!0})}).then((function(e){200!==e.status&&console.error("Couldn't update completion to accepted")})).catch((function(e){return console.error(e)}))}}),[n]);return{model:o.model,user:o.user,saveCompletion:r,getCompletion:c,markCompletionSeen:s,markCompletionAccepted:i}}export{o as useFoundationModel}; | ||
import e from"react";function o(o){var t=e.useState("undefined"!=typeof crypto?crypto.randomUUID():"".concat((new Date).getTime()))[0],n=o.dev?"http://localhost:7777/platform":"https://api.foundation-ui.com/platform",r=e.useMemo((function(){return function(e,r){return fetch("".concat(n,"/sessions"),{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify([{model:o.model,user:o.user,session:t,input:e,context:r}])}).then((function(e){return e.json()})).catch((function(e){return console.error(e)}))}}),[o.model,o.user,n]),c=e.useMemo((function(){return function(e,r){return fetch("".concat(n,"/completions"),{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:o.model,user:o.user,safeMode:o.safeMode,session:t,input:e,context:r})}).then((function(e){return 200!==e.status&&console.error("Error getting completion"),e.json()})).catch((function(e){return console.error(e),null}))}}),[o.model,o.user,o.dev,o.safeMode]),s=e.useMemo((function(){return function(e){fetch("".concat(n,"/completions"),{method:"PUT",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({completionSid:e,seen:!0})}).then((function(e){200!==e.status&&console.error("Couldn't update completion to seen")})).catch((function(e){return console.error(e)}))}}),[n]),i=e.useMemo((function(){return function(e){fetch("".concat(n,"/completions"),{method:"PUT",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({completionSid:e,accepted:!0})}).then((function(e){200!==e.status&&console.error("Couldn't update completion to accepted")})).catch((function(e){return console.error(e)}))}}),[n]);return{model:o.model,user:o.user,saveCompletion:r,getCompletion:c,markCompletionSeen:s,markCompletionAccepted:i}}export{o as useFoundationModel}; |
{ | ||
"name": "@foundationui/react-hooks", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Use a foundation model in your app. It gets smarter the more your users use it.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
8
27864