File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010 *
1111 */
1212import { ref } from 'vue'
13- import { useCanvas , useResource } from '@opentiny/tiny-engine-meta-register'
13+ import { useCanvas , useResource , getMergeMeta } from '@opentiny/tiny-engine-meta-register'
1414
1515const keyWords = [
1616 'state' ,
@@ -224,14 +224,15 @@ const generateBaseReference = () => {
224224
225225const fetchAiInlineCompletion = ( codeBeforeCursor , codeAfterCursor ) => {
226226 const referenceContext = generateBaseReference ( )
227- return fetch ( 'https://agent.opentiny.design/api/v1/ai/chat/completions' , {
227+ const { modelName, apiKey, url } = getMergeMeta ( 'engine.plugins.pagecontroller' ) ?. options ?. AIModel || { }
228+ return fetch ( `${ url ?? 'https://agent.opentiny.design/api/v1/ai/chat/completions' } ` , {
228229 method : 'POST' ,
229230 headers : {
230231 'Content-Type' : 'application/json' ,
231- Authorization : ' Bearer sk-1234'
232+ Authorization : ` Bearer ${ apiKey ?? ' sk-1234'} `
232233 } ,
233234 body : JSON . stringify ( {
234- model : 'internvl3-14b' ,
235+ model : modelName ?? 'internvl3-14b' ,
235236 messages : [
236237 {
237238 role : 'user' ,
Original file line number Diff line number Diff line change @@ -5,5 +5,12 @@ export default {
55 icon : 'plugin-icon-js' ,
66 width : 600 ,
77 widthResizable : true ,
8+ options : {
9+ AIModel : {
10+ modelName : '' ,
11+ apiKey : '' ,
12+ url : ''
13+ }
14+ } ,
815 confirm : 'close' // 当点击插件栏切换或关闭前是否需要确认, 会调用插件中confirm值指定的方法,e.g. 此处指向 close方法,会调用插件的close方法执行确认逻辑
916}
You can’t perform that action at this time.
0 commit comments