@fencyai/react 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/FencyProvider.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +7 -0
- package/dist/types.d.ts +1 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/useChatCompletion.d.ts +20 -0
- package/dist/useChatCompletion.d.ts.map +1 -0
- package/dist/useChatCompletion.js +76 -0
- package/dist/useEventSource.d.ts +25 -0
- package/dist/useEventSource.d.ts.map +1 -0
- package/dist/useEventSource.js +58 -0
- package/package.json +5 -4
- package/dist/index.js.map +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FencyProvider.d.ts","sourceRoot":"","sources":["../src/FencyProvider.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FencyProvider.d.ts","sourceRoot":"","sources":["../src/FencyProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAGhE,eAAO,MAAM,iBAAiB,mDAAqD,CAAC;AAEpF;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,kBAAkB,kDAiCpE"}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var v=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var K=(e,t)=>{for(var n in t)v(e,n,{get:t[n],enumerable:!0})},$=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of A(t))!T.call(e,o)&&o!==n&&v(e,o,{get:()=>t[o],enumerable:!(r=k(t,o))||r.enumerable});return e};var O=e=>$(v({},"__esModule",{value:!0}),e);var J={};K(J,{FencyProvider:()=>F,useChatCompletion:()=>x,useFency:()=>w});module.exports=O(J);var d=require("react"),I=require("react/jsx-runtime"),b=(0,d.createContext)(void 0);function F({fency:e,children:t}){let[n,r]=(0,d.useState)(null),[o,a]=(0,d.useState)(!0),[u,p]=(0,d.useState)(null);if((0,d.useEffect)(()=>{e.then(l=>{r(l),a(!1)}).catch(l=>{p(l),a(!1)})},[e]),!n)return null;let g={fency:n,loading:o,error:u};return(0,I.jsx)(b.Provider,{value:g,children:t})}var E=require("react");function w(){let e=(0,E.useContext)(b);if(e===void 0)throw new Error("useFency must be used within a FencyProvider");return e}function j(e){return e&&typeof e=="object"&&typeof e.id=="string"&&typeof e.name=="string"}function H(e){return e&&typeof e=="object"&&typeof e.id=="string"&&typeof e.streamId=="string"&&Array.isArray(e.choices)}async function S(e,t,n={}){let r=n.apiUrl||"http://localhost:8080/v1/chat-completions",o={...n.request,streamId:t,openai:{model:"gpt-4o-mini",messages:[{role:"user",content:"Hello, how are you?"}],...n.request?.openai}},a=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify(o)});if(!a.ok)throw new Error(`Failed to create chat completion: ${a.status} ${a.statusText}`);let u=await a.json();if(!H(u))throw new Error("Invalid chat completion response");return u}async function C(e,t={}){let n=t.apiUrl||"http://localhost:8080/v1/streams",r=t.name||e,o=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({name:r})});if(!o.ok)throw new Error(`Failed to create stream: ${o.status} ${o.statusText}`);let a=await o.json();if(!j(a))throw new Error("Invalid stream response");return a}var f=require("react");var c=require("react");function M(e){let t=(0,c.useRef)(null),[n,r]=(0,c.useState)(!1),[o,a]=(0,c.useState)(null),[u,p]=(0,c.useState)([]),g=(0,c.useCallback)(h=>{if(t.current)return;let y=new EventSource(`http://localhost:8080/v1/streams/${h.streamId}?pk=${h.publishableKey}`,e.options);t.current=y,y.onopen=()=>{r(!0)},y.onmessage=i=>{console.log("onmessage",i);let m={data:q(i.data),event:i.type,lastEventId:i.lastEventId};a(m),p(s=>[...s,m]),e.onMessage&&e.onMessage({message:m,streamId:h.streamId})},y.onerror=()=>{r(!1)}},[e.options,e.onMessage]),l=(0,c.useCallback)(()=>{t.current&&(t.current.close(),t.current=null,r(!1))},[]);return(0,c.useEffect)(()=>()=>{l()},[l]),{connect:g,disconnect:l,isConnected:n,latestMessage:o,allMessages:u}}var q=e=>atob(e);function x(){let e=w(),[t,n]=(0,f.useState)({}),[r,o]=(0,f.useState)(!1),[a,u]=(0,f.useState)(null),[p,g]=(0,f.useState)(null),l=M({onMessage:i=>{console.log("Event source message",i);let m=t[i.streamId];if(m)n(s=>({...s,[i.streamId]:{...m,content:m.content+i.message.data}}));else{let s={streamId:i.streamId,role:"assistant",content:i.message.data};n(P=>({...P,[i.streamId]:s}))}}}),h=(0,f.useCallback)(async(i,m)=>{try{o(!0),u(null);let s=p;s||(s=await C(e.fency.publishableKey),console.log("Stream created",s),g(s)),l.connect({streamId:s.id,publishableKey:e.fency.publishableKey}),await S(e.fency.publishableKey,s.id,{request:{openai:{model:m.model,messages:[{role:"user",content:i}]}}})}catch(s){u(s instanceof Error?s:new Error("Unknown error"))}finally{o(!1)}},[e,p,l]),y=(0,f.useCallback)(()=>{n({})},[]);return{sendPrompt:h,clearMessages:y,messages:t,isLoading:r,error:a,stream:p}}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { FencyProvider } from './FencyProvider';
|
|
2
2
|
export { useFency } from './useFency';
|
|
3
|
-
export
|
|
3
|
+
export { useChatCompletion } from './useChatCompletion';
|
|
4
|
+
export type { FencyContext, FencyOptions, FencyProviderProps } from './types';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// Re-export components and hooks
|
|
2
|
+
export { FencyProvider } from './FencyProvider';
|
|
3
|
+
export { useFency } from './useFency';
|
|
4
|
+
export { useChatCompletion } from './useChatCompletion';
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createContext as M,useEffect as x,useState as g}from"react";import{jsx as k}from"react/jsx-runtime";var h=M(void 0);function P({fency:e,children:t}){let[o,i]=g(null),[a,s]=g(!0),[l,m]=g(null);if(x(()=>{e.then(c=>{i(c),s(!1)}).catch(c=>{m(c),s(!1)})},[e]),!o)return null;let f={fency:o,loading:a,error:l};return k(h.Provider,{value:f,children:t})}import{useContext as A}from"react";function w(){let e=A(h);if(e===void 0)throw new Error("useFency must be used within a FencyProvider");return e}function T(e){return e&&typeof e=="object"&&typeof e.id=="string"&&typeof e.name=="string"}function K(e){return e&&typeof e=="object"&&typeof e.id=="string"&&typeof e.streamId=="string"&&Array.isArray(e.choices)}async function b(e,t,o={}){let i=o.apiUrl||"http://localhost:8080/v1/chat-completions",a={...o.request,streamId:t,openai:{model:"gpt-4o-mini",messages:[{role:"user",content:"Hello, how are you?"}],...o.request?.openai}},s=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify(a)});if(!s.ok)throw new Error(`Failed to create chat completion: ${s.status} ${s.statusText}`);let l=await s.json();if(!K(l))throw new Error("Invalid chat completion response");return l}async function F(e,t={}){let o=t.apiUrl||"http://localhost:8080/v1/streams",i=t.name||e,a=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({name:i})});if(!a.ok)throw new Error(`Failed to create stream: ${a.status} ${a.statusText}`);let s=await a.json();if(!T(s))throw new Error("Invalid stream response");return s}import{useCallback as S,useState as y}from"react";import{useCallback as I,useEffect as $,useRef as O,useState as v}from"react";function E(e){let t=O(null),[o,i]=v(!1),[a,s]=v(null),[l,m]=v([]),f=I(p=>{if(t.current)return;let d=new EventSource(`http://localhost:8080/v1/streams/${p.streamId}?pk=${p.publishableKey}`,e.options);t.current=d,d.onopen=()=>{i(!0)},d.onmessage=r=>{console.log("onmessage",r);let u={data:j(r.data),event:r.type,lastEventId:r.lastEventId};s(u),m(n=>[...n,u]),e.onMessage&&e.onMessage({message:u,streamId:p.streamId})},d.onerror=()=>{i(!1)}},[e.options,e.onMessage]),c=I(()=>{t.current&&(t.current.close(),t.current=null,i(!1))},[]);return $(()=>()=>{c()},[c]),{connect:f,disconnect:c,isConnected:o,latestMessage:a,allMessages:l}}var j=e=>atob(e);function H(){let e=w(),[t,o]=y({}),[i,a]=y(!1),[s,l]=y(null),[m,f]=y(null),c=E({onMessage:r=>{console.log("Event source message",r);let u=t[r.streamId];if(u)o(n=>({...n,[r.streamId]:{...u,content:u.content+r.message.data}}));else{let n={streamId:r.streamId,role:"assistant",content:r.message.data};o(C=>({...C,[r.streamId]:n}))}}}),p=S(async(r,u)=>{try{a(!0),l(null);let n=m;n||(n=await F(e.fency.publishableKey),console.log("Stream created",n),f(n)),c.connect({streamId:n.id,publishableKey:e.fency.publishableKey}),await b(e.fency.publishableKey,n.id,{request:{openai:{model:u.model,messages:[{role:"user",content:r}]}}})}catch(n){l(n instanceof Error?n:new Error("Unknown error"))}finally{a(!1)}},[e,m,c]),d=S(()=>{o({})},[]);return{sendPrompt:p,clearMessages:d,messages:t,isLoading:i,error:s,stream:m}}export{P as FencyProvider,H as useChatCompletion,w as useFency};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/FencyProvider.tsx", "../src/useFency.ts", "../../fency-js/dist/index.js", "../src/useChatCompletion.ts", "../src/useEventSource.ts"],
|
|
4
|
+
"sourcesContent": ["import { FencyInstance } from '@fencyai/js';\nimport { createContext, useEffect, useState } from 'react';\nimport type { FencyContext, FencyProviderProps } from './types';\n\n// Create the context\nexport const FencyContextValue = createContext<FencyContext | undefined>(undefined);\n\n/**\n * Provider component that provides Fency instance to child components\n * Expects a promise that resolves to a Fency instance\n */\nexport function FencyProvider({ fency, children }: FencyProviderProps) {\n const [fencyInstance, setFencyInstance] = useState<FencyInstance | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n fency\n .then((instance: FencyInstance) => {\n setFencyInstance(instance);\n setLoading(false);\n })\n .catch((err: Error) => {\n setError(err);\n setLoading(false);\n });\n }, [fency]);\n\n // Only render children and provide context when fency is loaded\n if (!fencyInstance) {\n return null;\n }\n\n const value: FencyContext = {\n fency: fencyInstance,\n loading,\n error,\n };\n\n return (\n <FencyContextValue.Provider value={value}>\n {children}\n </FencyContextValue.Provider>\n );\n} ", "import { useContext } from 'react';\nimport type { FencyContext } from './types';\nimport { FencyContextValue } from './FencyProvider';\n\n/**\n * Hook to access Fency instance and loading state\n */\nexport function useFency(): FencyContext {\n const context = useContext(FencyContextValue);\n if (context === undefined) {\n throw new Error('useFency must be used within a FencyProvider');\n }\n return context;\n} ", "function a(){if(typeof window>\"u\")return!1;let e=[\"fetch\",\"Promise\",\"JSON\"];for(let o of e)if(typeof window[o]>\"u\")return!1;if(typeof window.location<\"u\"){let o=window.location.hostname===\"localhost\"||window.location.hostname===\"127.0.0.1\",t=window.location.protocol===\"https:\";!o&&!t&&console.warn(\"Fency: For security, we recommend using HTTPS in production.\")}return!0}function s(){let e={available:!0,missing:[],warnings:[]};if(typeof window>\"u\")return e.available=!1,e.missing.push(\"Browser environment\"),e;let o=[\"fetch\",\"Promise\",\"JSON\"];for(let t of o)typeof window[t]>\"u\"&&(e.available=!1,e.missing.push(`${t} API`));if(typeof window.location<\"u\"){let t=window.location.hostname===\"localhost\"||window.location.hostname===\"127.0.0.1\",n=window.location.protocol===\"https:\";!t&&!n&&e.warnings.push(\"HTTPS is recommended for production use\")}return e}function f(e){return e&&typeof e==\"object\"&&typeof e.id==\"string\"&&typeof e.name==\"string\"}function y(e){return e&&typeof e==\"object\"&&typeof e.id==\"string\"&&typeof e.streamId==\"string\"&&Array.isArray(e.choices)}async function c(e,o,t={}){let n=t.apiUrl||\"http://localhost:8080/v1/chat-completions\",r={...t.request,streamId:o,openai:{model:\"gpt-4o-mini\",messages:[{role:\"user\",content:\"Hello, how are you?\"}],...t.request?.openai}},i=await fetch(n,{method:\"POST\",headers:{\"Content-Type\":\"application/json\",Authorization:`Bearer ${e}`},body:JSON.stringify(r)});if(!i.ok)throw new Error(`Failed to create chat completion: ${i.status} ${i.statusText}`);let m=await i.json();if(!y(m))throw new Error(\"Invalid chat completion response\");return m}async function p(e,o={}){let t=o.apiUrl||\"http://localhost:8080/v1/streams\",n=o.name||e,r=await fetch(t,{method:\"POST\",headers:{\"Content-Type\":\"application/json\",Authorization:`Bearer ${e}`},body:JSON.stringify({name:n})});if(!r.ok)throw new Error(`Failed to create stream: ${r.status} ${r.statusText}`);let i=await r.json();if(!f(i))throw new Error(\"Invalid stream response\");return i}function l(e,o={}){return new Promise((t,n)=>{if(!e||typeof e!=\"string\"){n(new Error(\"Fency: A valid publishable key is required.\"));return}if(!e.startsWith(\"pk_\")){n(new Error('Fency: Invalid publishable key format. Keys should start with \"pk_\".'));return}let r={publishableKey:e,endpoint:o.endpoint||\"https://api.fency.ai\"};setTimeout(()=>{t(r)},0)})}var P={loadFency:l,isFencyAvailable:a,getFencyAvailabilityInfo:s,createStream:p,createChatCompletion:c};export{c as createChatCompletion,p as createStream,P as default,s as getFencyAvailabilityInfo,a as isFencyAvailable,l as loadFency};\n", "// hooks/useChatCompletion.ts\nimport { createChatCompletion, createStream } from '@fencyai/js'\nimport { useFency } from './useFency'\nimport { useCallback, useState } from 'react'\nimport { Stream } from '../../fency-js/dist/types'\nimport { useEventSource } from './useEventSource'\n\ninterface StreamMessage {\n streamId: string\n role: string\n content: string\n}\n\nexport function useChatCompletion() {\n const fency = useFency()\n const [messages, setMessages] = useState<Record<string, StreamMessage>>({})\n const [isLoading, setIsLoading] = useState(false)\n const [error, setError] = useState<Error | null>(null)\n const [stream, setStream] = useState<Stream | null>(null)\n\n // Create event source URL when stream is available\n const eventSource = useEventSource({\n onMessage: (params) => {\n console.log('Event source message', params)\n const existingMessage = messages[params.streamId]\n if (existingMessage) {\n setMessages(prev => ({ ...prev, [params.streamId]: {\n ...existingMessage,\n content: existingMessage.content + params.message.data\n }}))\n } else {\n const streamMessage: StreamMessage = {\n streamId: params.streamId,\n role: 'assistant',\n content: params.message.data\n }\n setMessages(prev => ({ ...prev, [params.streamId]: streamMessage }))\n }\n }\n })\n\n\n const sendPrompt = useCallback(async (prompt: string, promptOptions: {\n model: \"gpt-4o-mini\"\n temperature: number\n topP: number\n }) => {\n \n try {\n setIsLoading(true)\n setError(null)\n\n // Step 1: Create stream if not exists\n let s = stream\n if (!s) {\n s = await createStream(fency.fency.publishableKey)\n console.log('Stream created', s)\n setStream(s)\n }\n\n eventSource.connect({\n streamId: s.id,\n publishableKey: fency.fency.publishableKey\n })\n\n\n // Step 3: Send chat completion\n await createChatCompletion(fency.fency.publishableKey, s.id, {\n request: {\n openai: { \n model: promptOptions.model,\n messages: [{ role: 'user', content: prompt }],\n }\n }\n })\n\n } catch (error) {\n setError(error instanceof Error ? error : new Error('Unknown error'))\n } finally {\n setIsLoading(false)\n }\n }, [fency, stream, eventSource])\n\n const clearMessages = useCallback(() => {\n setMessages({})\n }, [])\n\n return {\n sendPrompt,\n clearMessages,\n messages,\n isLoading,\n error,\n stream,\n } \n}", "import { useCallback, useEffect, useRef, useState } from 'react'\n\ntype Message = {\n data: string\n event?: string\n lastEventId?: string\n}\n\ntype EventSourceHook = {\n connect: (params:{streamId: string, publishableKey: string }) => void\n disconnect: () => void\n isConnected: boolean\n latestMessage: Message | null\n allMessages: Message[]\n}\n\nexport function useEventSource(\n props: {\n options?: EventSourceInit,\n onMessage?: (params: {\n message: Message\n streamId: string\n }) => void,\n onError?: (error: Event) => void,\n }\n): EventSourceHook {\n const eventSourceRef = useRef<EventSource | null>(null)\n const [isConnected, setIsConnected] = useState(false)\n const [latestMessage, setLatestMessage] = useState<Message | null>(null)\n const [allMessages, setAllMessages] = useState<Message[]>([])\n\n const connect = useCallback((params: {streamId: string, publishableKey: string }) => {\n if (eventSourceRef.current) return\n\n const es = new EventSource(`http://localhost:8080/v1/streams/${params.streamId}?pk=${params.publishableKey}`, props.options)\n eventSourceRef.current = es\n\n es.onopen = () => {\n setIsConnected(true)\n }\n\n es.onmessage = (event: MessageEvent) => {\n console.log('onmessage', event)\n const message: Message = {\n data: base64Decode(event.data),\n event: event.type,\n lastEventId: event.lastEventId,\n }\n setLatestMessage(message)\n setAllMessages((prev) => [...prev, message])\n\n if (props.onMessage) {\n props.onMessage({\n message,\n streamId: params.streamId\n })\n }\n }\n\n es.onerror = () => {\n setIsConnected(false)\n // You could auto-reconnect here if needed\n }\n }, [props.options, props.onMessage])\n\n const disconnect = useCallback(() => {\n if (eventSourceRef.current) {\n eventSourceRef.current.close()\n eventSourceRef.current = null\n setIsConnected(false)\n }\n }, [])\n\n useEffect(() => {\n return () => {\n disconnect()\n }\n }, [disconnect])\n\n return {\n connect,\n disconnect,\n isConnected,\n latestMessage,\n allMessages,\n }\n}\n\nconst base64Decode = (str: string) => {\n return atob(str)\n}"],
|
|
5
|
+
"mappings": "AACA,OAAS,iBAAAA,EAAe,aAAAC,EAAW,YAAAC,MAAgB,QAuC/C,cAAAC,MAAA,oBAnCG,IAAMC,EAAoBJ,EAAwC,MAAS,EAM3E,SAASK,EAAc,CAAE,MAAAC,EAAO,SAAAC,CAAS,EAAuB,CACrE,GAAM,CAACC,EAAeC,CAAgB,EAAIP,EAA+B,IAAI,EACvE,CAACQ,EAASC,CAAU,EAAIT,EAAS,EAAI,EACrC,CAACU,EAAOC,CAAQ,EAAIX,EAAuB,IAAI,EAerD,GAbAD,EAAU,IAAM,CACdK,EACG,KAAMQ,GAA4B,CACjCL,EAAiBK,CAAQ,EACzBH,EAAW,EAAK,CAClB,CAAC,EACA,MAAOI,GAAe,CACrBF,EAASE,CAAG,EACZJ,EAAW,EAAK,CAClB,CAAC,CACL,EAAG,CAACL,CAAK,CAAC,EAGN,CAACE,EACH,OAAO,KAGT,IAAMQ,EAAsB,CAC1B,MAAOR,EACP,QAAAE,EACA,MAAAE,CACF,EAEA,OACET,EAACC,EAAkB,SAAlB,CAA2B,MAAOY,EAChC,SAAAT,EACH,CAEJ,CC5CA,OAAS,cAAAU,MAAkB,QAOpB,SAASC,GAAyB,CACvC,IAAMC,EAAUC,EAAWC,CAAiB,EAC5C,GAAIF,IAAY,OACd,MAAM,IAAI,MAAM,8CAA8C,EAEhE,OAAOA,CACT,CCbw1B,SAASG,EAAE,EAAE,CAAC,OAAO,GAAG,OAAO,GAAG,UAAU,OAAO,EAAE,IAAI,UAAU,OAAO,EAAE,MAAM,QAAQ,CAAC,SAASC,EAAE,EAAE,CAAC,OAAO,GAAG,OAAO,GAAG,UAAU,OAAO,EAAE,IAAI,UAAU,OAAO,EAAE,UAAU,UAAU,MAAM,QAAQ,EAAE,OAAO,CAAC,CAAC,eAAeC,EAAE,EAAEC,EAAEC,EAAE,C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Cf,EAAY,CAAC,CAAC,CAChB,EAAG,CAAC,CAAC,EAEL,MAAO,CACL,WAAAc,EACA,cAAAO,EACA,SAAAtB,EACA,UAAAG,EACA,MAAAE,EACA,OAAAE,CACF,CACF",
|
|
6
|
+
"names": ["createContext", "useEffect", "useState", "jsx", "FencyContextValue", "FencyProvider", "fency", "children", "fencyInstance", "setFencyInstance", "loading", "setLoading", "error", "setError", "instance", "err", "value", "useContext", "useFency", "context", "useContext", "FencyContextValue", "f", "y", "c", "o", "t", "n", "r", "i", "m", "p", "useCallback", "useState", "useCallback", "useEffect", "useRef", "useState", "useEventSource", "props", "eventSourceRef", "isConnected", "setIsConnected", "latestMessage", "setLatestMessage", "allMessages", "setAllMessages", "connect", "params", "es", "event", "message", "base64Decode", "prev", "disconnect", "str", "useChatCompletion", "fency", "useFency", "messages", "setMessages", "useState", "isLoading", "setIsLoading", "error", "setError", "stream", "setStream", "eventSource", "useEventSource", "params", "existingMessage", "prev", "streamMessage", "sendPrompt", "useCallback", "prompt", "promptOptions", "s", "p", "c", "clearMessages"]
|
|
7
|
+
}
|
package/dist/types.d.ts
CHANGED
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,YAAY;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,aAAa,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IAC9B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Stream } from '../../fency-js/dist/types';
|
|
2
|
+
interface StreamMessage {
|
|
3
|
+
streamId: string;
|
|
4
|
+
role: string;
|
|
5
|
+
content: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function useChatCompletion(): {
|
|
8
|
+
sendPrompt: (prompt: string, promptOptions: {
|
|
9
|
+
model: "gpt-4o-mini";
|
|
10
|
+
temperature: number;
|
|
11
|
+
topP: number;
|
|
12
|
+
}) => Promise<void>;
|
|
13
|
+
clearMessages: () => void;
|
|
14
|
+
messages: Record<string, StreamMessage>;
|
|
15
|
+
isLoading: boolean;
|
|
16
|
+
error: Error | null;
|
|
17
|
+
stream: Stream | null;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=useChatCompletion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChatCompletion.d.ts","sourceRoot":"","sources":["../src/useChatCompletion.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAGlD,UAAU,aAAa;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,wBAAgB,iBAAiB;yBA6Be,MAAM,iBAAiB;QACnE,KAAK,EAAE,aAAa,CAAA;QACpB,WAAW,EAAE,MAAM,CAAA;QACnB,IAAI,EAAE,MAAM,CAAA;KACb;;;;;;EAiDF"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// hooks/useChatCompletion.ts
|
|
2
|
+
import { createChatCompletion, createStream } from '@fencyai/js';
|
|
3
|
+
import { useFency } from './useFency';
|
|
4
|
+
import { useCallback, useState } from 'react';
|
|
5
|
+
import { useEventSource } from './useEventSource';
|
|
6
|
+
export function useChatCompletion() {
|
|
7
|
+
const fency = useFency();
|
|
8
|
+
const [messages, setMessages] = useState({});
|
|
9
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
10
|
+
const [error, setError] = useState(null);
|
|
11
|
+
const [stream, setStream] = useState(null);
|
|
12
|
+
// Create event source URL when stream is available
|
|
13
|
+
const eventSource = useEventSource({
|
|
14
|
+
onMessage: (params) => {
|
|
15
|
+
console.log('Event source message', params);
|
|
16
|
+
const existingMessage = messages[params.streamId];
|
|
17
|
+
if (existingMessage) {
|
|
18
|
+
setMessages(prev => ({ ...prev, [params.streamId]: {
|
|
19
|
+
...existingMessage,
|
|
20
|
+
content: existingMessage.content + params.message.data
|
|
21
|
+
} }));
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
const streamMessage = {
|
|
25
|
+
streamId: params.streamId,
|
|
26
|
+
role: 'assistant',
|
|
27
|
+
content: params.message.data
|
|
28
|
+
};
|
|
29
|
+
setMessages(prev => ({ ...prev, [params.streamId]: streamMessage }));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const sendPrompt = useCallback(async (prompt, promptOptions) => {
|
|
34
|
+
try {
|
|
35
|
+
setIsLoading(true);
|
|
36
|
+
setError(null);
|
|
37
|
+
// Step 1: Create stream if not exists
|
|
38
|
+
let s = stream;
|
|
39
|
+
if (!s) {
|
|
40
|
+
s = await createStream(fency.fency.publishableKey);
|
|
41
|
+
console.log('Stream created', s);
|
|
42
|
+
setStream(s);
|
|
43
|
+
}
|
|
44
|
+
eventSource.connect({
|
|
45
|
+
streamId: s.id,
|
|
46
|
+
publishableKey: fency.fency.publishableKey
|
|
47
|
+
});
|
|
48
|
+
// Step 3: Send chat completion
|
|
49
|
+
await createChatCompletion(fency.fency.publishableKey, s.id, {
|
|
50
|
+
request: {
|
|
51
|
+
openai: {
|
|
52
|
+
model: promptOptions.model,
|
|
53
|
+
messages: [{ role: 'user', content: prompt }],
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
setError(error instanceof Error ? error : new Error('Unknown error'));
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
setIsLoading(false);
|
|
63
|
+
}
|
|
64
|
+
}, [fency, stream, eventSource]);
|
|
65
|
+
const clearMessages = useCallback(() => {
|
|
66
|
+
setMessages({});
|
|
67
|
+
}, []);
|
|
68
|
+
return {
|
|
69
|
+
sendPrompt,
|
|
70
|
+
clearMessages,
|
|
71
|
+
messages,
|
|
72
|
+
isLoading,
|
|
73
|
+
error,
|
|
74
|
+
stream,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type Message = {
|
|
2
|
+
data: string;
|
|
3
|
+
event?: string;
|
|
4
|
+
lastEventId?: string;
|
|
5
|
+
};
|
|
6
|
+
type EventSourceHook = {
|
|
7
|
+
connect: (params: {
|
|
8
|
+
streamId: string;
|
|
9
|
+
publishableKey: string;
|
|
10
|
+
}) => void;
|
|
11
|
+
disconnect: () => void;
|
|
12
|
+
isConnected: boolean;
|
|
13
|
+
latestMessage: Message | null;
|
|
14
|
+
allMessages: Message[];
|
|
15
|
+
};
|
|
16
|
+
export declare function useEventSource(props: {
|
|
17
|
+
options?: EventSourceInit;
|
|
18
|
+
onMessage?: (params: {
|
|
19
|
+
message: Message;
|
|
20
|
+
streamId: string;
|
|
21
|
+
}) => void;
|
|
22
|
+
onError?: (error: Event) => void;
|
|
23
|
+
}): EventSourceHook;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=useEventSource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEventSource.d.ts","sourceRoot":"","sources":["../src/useEventSource.ts"],"names":[],"mappings":"AAEA,KAAK,OAAO,GAAG;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,KAAK,eAAe,GAAG;IACnB,OAAO,EAAE,CAAC,MAAM,EAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAA;KAAG,KAAK,IAAI,CAAA;IACtE,UAAU,EAAE,MAAM,IAAI,CAAA;IACtB,WAAW,EAAE,OAAO,CAAA;IACpB,aAAa,EAAE,OAAO,GAAG,IAAI,CAAA;IAC7B,WAAW,EAAE,OAAO,EAAE,CAAA;CACzB,CAAA;AAED,wBAAgB,cAAc,CAC1B,KAAK,EAAG;IACJ,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE;QACjB,OAAO,EAAE,OAAO,CAAA;QAChB,QAAQ,EAAE,MAAM,CAAA;KACnB,KAAK,IAAI,CAAC;IACX,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACpC,GACF,eAAe,CA6DjB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
export function useEventSource(props) {
|
|
3
|
+
const eventSourceRef = useRef(null);
|
|
4
|
+
const [isConnected, setIsConnected] = useState(false);
|
|
5
|
+
const [latestMessage, setLatestMessage] = useState(null);
|
|
6
|
+
const [allMessages, setAllMessages] = useState([]);
|
|
7
|
+
const connect = useCallback((params) => {
|
|
8
|
+
if (eventSourceRef.current)
|
|
9
|
+
return;
|
|
10
|
+
const es = new EventSource(`http://localhost:8080/v1/streams/${params.streamId}?pk=${params.publishableKey}`, props.options);
|
|
11
|
+
eventSourceRef.current = es;
|
|
12
|
+
es.onopen = () => {
|
|
13
|
+
setIsConnected(true);
|
|
14
|
+
};
|
|
15
|
+
es.onmessage = (event) => {
|
|
16
|
+
console.log('onmessage', event);
|
|
17
|
+
const message = {
|
|
18
|
+
data: base64Decode(event.data),
|
|
19
|
+
event: event.type,
|
|
20
|
+
lastEventId: event.lastEventId,
|
|
21
|
+
};
|
|
22
|
+
setLatestMessage(message);
|
|
23
|
+
setAllMessages((prev) => [...prev, message]);
|
|
24
|
+
if (props.onMessage) {
|
|
25
|
+
props.onMessage({
|
|
26
|
+
message,
|
|
27
|
+
streamId: params.streamId
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
es.onerror = () => {
|
|
32
|
+
setIsConnected(false);
|
|
33
|
+
// You could auto-reconnect here if needed
|
|
34
|
+
};
|
|
35
|
+
}, [props.options, props.onMessage]);
|
|
36
|
+
const disconnect = useCallback(() => {
|
|
37
|
+
if (eventSourceRef.current) {
|
|
38
|
+
eventSourceRef.current.close();
|
|
39
|
+
eventSourceRef.current = null;
|
|
40
|
+
setIsConnected(false);
|
|
41
|
+
}
|
|
42
|
+
}, []);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
return () => {
|
|
45
|
+
disconnect();
|
|
46
|
+
};
|
|
47
|
+
}, [disconnect]);
|
|
48
|
+
return {
|
|
49
|
+
connect,
|
|
50
|
+
disconnect,
|
|
51
|
+
isConnected,
|
|
52
|
+
latestMessage,
|
|
53
|
+
allMessages,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const base64Decode = (str) => {
|
|
57
|
+
return atob(str);
|
|
58
|
+
};
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fencyai/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "React components for Fency integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
|
-
"module": "./dist/index.
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"import": "./dist/index.
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
12
|
"require": "./dist/index.cjs",
|
|
13
13
|
"types": "./dist/index.d.ts"
|
|
14
14
|
}
|
|
@@ -45,7 +45,8 @@
|
|
|
45
45
|
"author": "",
|
|
46
46
|
"license": "MIT",
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"react": "^18.0.0"
|
|
48
|
+
"react": "^18.0.0",
|
|
49
|
+
"@fencyai/js": "^0.1.5"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
52
|
"@types/node": "^20.10.0",
|
package/dist/index.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/FencyProvider.tsx", "../src/useFency.ts"],
|
|
4
|
-
"sourcesContent": ["import { createContext, useEffect, useState } from 'react';\nimport type { FencyContext, FencyInstance, FencyProviderProps } from './types';\n\n// Create the context\nexport const FencyContextValue = createContext<FencyContext | undefined>(undefined);\n\n/**\n * Provider component that provides Fency instance to child components\n * Expects a promise that resolves to a Fency instance\n */\nexport function FencyProvider({ fency, children }: FencyProviderProps) {\n const [fencyInstance, setFencyInstance] = useState<FencyInstance | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n fency\n .then((instance: FencyInstance) => {\n setFencyInstance(instance);\n setLoading(false);\n })\n .catch((err: Error) => {\n setError(err);\n setLoading(false);\n });\n }, [fency]);\n\n // Only render children and provide context when fency is loaded\n if (!fencyInstance) {\n return null;\n }\n\n const value: FencyContext = {\n fency: fencyInstance,\n loading,\n error,\n };\n\n return (\n <FencyContextValue.Provider value={value}>\n {children}\n </FencyContextValue.Provider>\n );\n} ", "import { useContext } from 'react';\nimport type { FencyContext } from './types';\nimport { FencyContextValue } from './FencyProvider';\n\n/**\n * Hook to access Fency instance and loading state\n */\nexport function useFency(): FencyContext {\n const context = useContext(FencyContextValue);\n if (context === undefined) {\n throw new Error('useFency must be used within a FencyProvider');\n }\n return context;\n} "],
|
|
5
|
-
"mappings": "AAAA,OAAS,iBAAAA,EAAe,aAAAC,EAAW,YAAAC,MAAgB,QAuC/C,cAAAC,MAAA,oBAnCG,IAAMC,EAAoBJ,EAAwC,MAAS,EAM3E,SAASK,EAAc,CAAE,MAAAC,EAAO,SAAAC,CAAS,EAAuB,CACrE,GAAM,CAACC,EAAeC,CAAgB,EAAIP,EAA+B,IAAI,EACvE,CAACQ,EAASC,CAAU,EAAIT,EAAS,EAAI,EACrC,CAACU,EAAOC,CAAQ,EAAIX,EAAuB,IAAI,EAerD,GAbAD,EAAU,IAAM,CACdK,EACG,KAAMQ,GAA4B,CACjCL,EAAiBK,CAAQ,EACzBH,EAAW,EAAK,CAClB,CAAC,EACA,MAAOI,GAAe,CACrBF,EAASE,CAAG,EACZJ,EAAW,EAAK,CAClB,CAAC,CACL,EAAG,CAACL,CAAK,CAAC,EAGN,CAACE,EACH,OAAO,KAGT,IAAMQ,EAAsB,CAC1B,MAAOR,EACP,QAAAE,EACA,MAAAE,CACF,EAEA,OACET,EAACC,EAAkB,SAAlB,CAA2B,MAAOY,EAChC,SAAAT,EACH,CAEJ,CC3CA,OAAS,cAAAU,MAAkB,QAOpB,SAASC,GAAyB,CACvC,IAAMC,EAAUC,EAAWC,CAAiB,EAC5C,GAAIF,IAAY,OACd,MAAM,IAAI,MAAM,8CAA8C,EAEhE,OAAOA,CACT",
|
|
6
|
-
"names": ["createContext", "useEffect", "useState", "jsx", "FencyContextValue", "FencyProvider", "fency", "children", "fencyInstance", "setFencyInstance", "loading", "setLoading", "error", "setError", "instance", "err", "value", "useContext", "useFency", "context", "useContext", "FencyContextValue"]
|
|
7
|
-
}
|