@@ -2,7 +2,7 @@ import EventEmitter from "events";
22import { WebSocket } from "ws" ;
33import { DELIMITER } from "./constant" ;
44import { createRequest } from "./request" ;
5- import { Conversation , EdgeGPTResponse } from "./types" ;
5+ import { Conversation , EdgeGPTResponse , RequestOptions } from "./types" ;
66import { appendIdentifier , createHeaders } from "./utils" ;
77import TypedEmitter from "typed-emitter" ;
88
@@ -17,28 +17,28 @@ type ChatHubEvents = {
1717
1818export class ChatHub extends ( EventEmitter as new ( ) => TypedEmitter < ChatHubEvents > ) {
1919 protected ws ! : WebSocket ;
20- protected request : ( prompt : string ) => any ;
20+ protected request : ( prompt : string , options ?: RequestOptions ) => any ;
2121
2222 constructor ( protected conversation : Conversation ) {
2323 super ( ) ;
2424 this . request = createRequest ( conversation ) ;
2525 }
2626
27- async ask ( prompt : string ) {
27+ async ask ( prompt : string , options ?: RequestOptions ) {
2828 if ( ! this . ws || this . ws . readyState === WebSocket . CLOSED ) {
2929 await this . createWs ( ) ;
3030 }
31- this . send ( this . request ( prompt ) ) ;
31+ this . send ( this . request ( prompt , options ) ) ;
3232 }
3333
34- askAsync ( prompt : string ) {
34+ askAsync ( prompt : string , options ?: RequestOptions ) {
3535 return new Promise < string > ( ( resolve ) => {
3636 this . once ( "final" , ( response ) => {
3737 resolve (
3838 response [ "item" ] [ "messages" ] [ 1 ] [ "adaptiveCards" ] [ 0 ] [ "body" ] [ 0 ] [ "text" ]
3939 ) ;
4040 } ) ;
41- this . ask ( prompt ) ;
41+ this . ask ( prompt , options ) ;
4242 } ) ;
4343 }
4444
0 commit comments