File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,5 +11,5 @@ const GITHUB_OAUTH_SCOPES = [
1111export const ENV = {
1212 GITHUB_CLIENT_ID ,
1313 GITHUB_OAUTH_SCOPES ,
14- ENABLE_STREAMING : false ,
14+ EMULATE_STREAMING : false ,
1515}
Original file line number Diff line number Diff line change @@ -7,12 +7,10 @@ const args = {
77 default : false ,
88 description : "Show this help message" ,
99 } ,
10- stream : {
11- alias : "s" ,
10+ "emulate-streaming" : {
1211 type : "boolean" ,
13- default : true ,
14- // citty will automatically convert this to --no-stream
15- description : "Disable streaming response for chat completions" ,
12+ default : false ,
13+ description : "Emulate streaming response for chat completions" ,
1614 } ,
1715 port : {
1816 alias : "p" ,
@@ -29,7 +27,14 @@ export interface CliOptions {
2927}
3028
3129export async function parseCli ( ) {
32- const command = defineCommand ( { args } )
30+ const command = defineCommand ( {
31+ args,
32+ meta : {
33+ name : "copilot-api" ,
34+ description :
35+ "A wrapper around GitHub Copilot API to make it OpenAI compatible, making it usable for other tools." ,
36+ } ,
37+ } )
3338 const options = parseArgs < typeof args > ( Bun . argv , args )
3439
3540 if ( options . help ) {
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { initialize } from "./lib/initialization"
66import { server } from "./server"
77
88const options = await parseCli ( )
9- ENV . ENABLE_STREAMING = options . stream
9+ ENV . EMULATE_STREAMING = options [ "emulate-streaming" ]
1010
1111await initialize ( )
1212
Original file line number Diff line number Diff line change @@ -11,15 +11,17 @@ export const completionRoutes = new Hono()
1111
1212completionRoutes . post ( "/chat/completions" , ( c ) => {
1313 try {
14- if ( ENV . ENABLE_STREAMING ) {
15- return handlerStreaming ( c )
16- } else {
14+ if ( ENV . EMULATE_STREAMING ) {
1715 return handler ( c )
16+ } else {
17+ return handlerStreaming ( c )
1818 }
1919 } catch ( error ) {
2020 if ( error instanceof FetchError ) {
2121 consola . error ( `Request failed: ${ error . message } ` , error . response ?. _data )
2222 }
23+ consola . error ( error )
24+
2325 throw error
2426 }
2527} )
You can’t perform that action at this time.
0 commit comments