@imgly/plugin-ai-text-generation-web 0.2.7 → 0.2.8
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/CHANGELOG.md +11 -0
- package/README.md +7 -7
- package/dist/.tsbuildinfo +1 -0
- package/dist/anthropic/index.mjs +10 -18
- package/dist/anthropic/index.mjs.map +1 -1
- package/dist/index.mjs +11 -34
- package/dist/index.mjs.map +1 -1
- package/dist/open-ai/index.mjs +10 -18
- package/dist/open-ai/index.mjs.map +1 -1
- package/package.json +8 -18
package/dist/open-ai/index.mjs
CHANGED
|
@@ -80,23 +80,15 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
|
80
80
|
`);super({baseURL:o.baseURL,timeout:o.timeout??6e5,httpAgent:o.httpAgent,maxRetries:o.maxRetries,fetch:o.fetch}),this.completions=new Xe(this),this.chat=new he(this),this.embeddings=new et(this),this.files=new Re(this),this.images=new at(this),this.audio=new ie(this),this.moderations=new ct(this),this.models=new Te(this),this.fineTuning=new J(this),this.graders=new $e(this),this.vectorStores=new Y(this),this.beta=new Z(this),this.batches=new Ie(this),this.uploads=new je(this),this.responses=new Le(this),this.evals=new ce(this),this.containers=new le(this),this._options=o,this.apiKey=t,this.organization=n,this.project=i}defaultQuery(){return this._options.defaultQuery}defaultHeaders(e){return{...super.defaultHeaders(e),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project,...this._options.defaultHeaders}}authHeaders(e){return{Authorization:`Bearer ${this.apiKey}`}}stringifyQuery(e){return An(e,{arrayFormat:"brackets"})}};_s=b;b.OpenAI=_s;b.DEFAULT_TIMEOUT=6e5;b.OpenAIError=m;b.APIError=T;b.APIConnectionError=_e;b.APIConnectionTimeoutError=xe;b.APIUserAbortError=E;b.NotFoundError=cr;b.ConflictError=ur;b.RateLimitError=pr;b.BadRequestError=or;b.AuthenticationError=ar;b.InternalServerError=fr;b.PermissionDeniedError=lr;b.UnprocessableEntityError=dr;b.toFile=Nn;b.fileFromPath=Lr;b.Completions=Xe;b.Chat=he;b.ChatCompletionsPage=ve;b.Embeddings=et;b.Files=Re;b.FileObjectsPage=nt;b.Images=at;b.Audio=ie;b.Moderations=ct;b.Models=Te;b.ModelsPage=lt;b.FineTuning=J;b.Graders=$e;b.VectorStores=Y;b.VectorStoresPage=ut;b.VectorStoreSearchResponsesPage=dt;b.Beta=Z;b.Batches=Ie;b.BatchesPage=We;b.Uploads=je;b.Responses=Le;b.Evals=ce;b.EvalListResponsesPage=rt;b.Containers=le;b.ContainerListResponsesPage=Ze;var xs=b;var Gc={model:"gpt-4o-mini",max_tokens:8192,temperature:.1,stream:!0},As={headers:{}};async function Hc(r,e,t,n){let i={};e.model&&(i.model=e.model),e.maxTokens&&(i.max_tokens=e.maxTokens),e.temperature&&(i.temperature=e.temperature);let s=await r.chat.completions.create({...Gc,...i,messages:[{role:"user",content:t}]},{signal:n,...As,headers:{...As.headers??{},...e.headers}});async function*o(){try{for await(let a of s)a.choices&&a.choices[0]?.delta?.content&&(yield a.choices[0].delta.content)}catch(a){throw console.error("Stream error:",a),a}}return o()}var vs=Hc;function Is(r){return()=>{let e=null,n=Ei({"ly.img.improve":!0,"ly.img.fix":!0,"ly.img.shorter":!0,"ly.img.longer":!0,"ly.img.changeTone":!0,"ly.img.translate":!0,"ly.img.changeTextTo":!0},r.supportedQuickActions),i={kind:"text",id:"openai",name:"OpenAI",initialize:async()=>{e=new xs({dangerouslyAllowBrowser:!0,baseURL:r.proxyUrl,apiKey:"dummy-key"})},input:{quickActions:{supported:n}},output:{middleware:r.middlewares,generate:async(s,{engine:o,abortSignal:a})=>{if(e==null)throw new Error("OpenAI SDK is not initialized");if(s.blockId!=null&&o.block.getType(s.blockId)!=="//ly.img.ubq/text")throw new Error("If a block is provided to this generation, it must be a text block");r.debug&&console.log("Sending prompt to OpenAI:",JSON.stringify(s.prompt,void 0,2));let u=await vs(e,{proxyUrl:r.proxyUrl,headers:r.headers,model:r.model??"gpt-4o-mini"},s.prompt,a);async function*d(){let _="";for await(let c of u){if(a?.aborted)break;_+=c,yield{kind:"text",text:_}}return{kind:"text",text:_}}return d()}}};return Promise.resolve(i)}}var Qc={OpenAIProvider:Is},hh=Qc;export{hh as default};
|
|
81
81
|
/*! Bundled license information:
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
* Build: `lodash modularize exports="es" -o ./`
|
|
94
|
-
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
95
|
-
* Released under MIT license <https://lodash.com/license>
|
|
96
|
-
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
97
|
-
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
98
|
-
*)
|
|
99
|
-
*)
|
|
100
|
-
*)
|
|
83
|
+
lodash-es/lodash.js:
|
|
84
|
+
(**
|
|
85
|
+
* @license
|
|
86
|
+
* Lodash (Custom Build) <https://lodash.com/>
|
|
87
|
+
* Build: `lodash modularize exports="es" -o ./`
|
|
88
|
+
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
89
|
+
* Released under MIT license <https://lodash.com/license>
|
|
90
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
91
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
92
|
+
*)
|
|
101
93
|
*/
|
|
102
94
|
//# sourceMappingURL=index.mjs.map
|