File tree Expand file tree Collapse file tree 3 files changed +23
-2
lines changed
packages/monaco-plugin-ob
example/src/components/App Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,27 @@ export default function () {
7272 delimiter : ';' ,
7373 llm : {
7474 async completions ( input : string , pos : number ) {
75- return 'aaa1\naaaa\n'
75+ // input 的 pos 位置增加一个光标
76+ const cursor = input . slice ( 0 , pos ) + '|' + input . slice ( pos ) ;
77+ const res = await fetch ( 'http://localhost/v1/workflows/run' , {
78+ method : 'POST' ,
79+ headers : {
80+ "Authorization" : `Bearer app-XyQfvJ9VFtm58VLquEMNHUmO` ,
81+ "Content-Type" : 'application/json'
82+ } ,
83+ body : JSON . stringify ( {
84+ user : 'shankar' ,
85+ response_mode : "blocking" ,
86+ inputs : {
87+ sql : cursor ,
88+ currentDatabase : 'dbgpt'
89+ }
90+ } )
91+ } )
92+ const data = await res . json ( ) ;
93+ const sql = data . data ?. outputs ?. sql || '' ;
94+ console . log ( sql ) ;
95+ return sql ;
7696 }
7797 } ,
7898 async getSnippets ( ) {
Original file line number Diff line number Diff line change 11{
22 "name" : " @oceanbase-odc/monaco-plugin-ob" ,
3- "version" : " 1.4.0 " ,
3+ "version" : " 1.4.1 " ,
44 "description" : " " ,
55 "main" : " dist/index.js" ,
66 "scripts" : {
Original file line number Diff line number Diff line change @@ -348,6 +348,7 @@ export default {
348348 if ( ! statement ) {
349349 return null ;
350350 }
351+ offset = offset - statement . start ;
351352 const result = statement . parse ( offset , ( ) => { } ) ;
352353 if ( ! result ) {
353354 return null ;
You can’t perform that action at this time.
0 commit comments