Spaces:
Running
Running
File size: 5,991 Bytes
6a37520 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
type Author = "user" | "bot";
type SendMessageOptions = {
conversationId?: string;
clientId?: string;
conversationSignature?: string;
invocationId?: string;
messageType?: string;
variant?: string;
locale?: string;
market?: string;
region?: string;
location?: {
lat: number | string;
lng: number | string;
re?: string;
};
onProgress?: (partialResponse: ChatMessage) => void;
};
interface ChatMessage {
id: string;
text: string;
author: Author;
conversationId: string;
clientId: string;
conversationSignature: string;
conversationExpiryTime?: string;
invocationId?: string;
messageType?: string;
variant?: string;
detail?: ChatMessageFull | ChatMessagePartial;
}
interface ConversationResult {
conversationId: string;
clientId: string;
conversationSignature: string;
result: APIResult;
}
interface APIResult {
value: string;
message: null;
}
interface ChatUpdate {
type: 1;
target: string;
arguments: ChatUpdateArgument[];
}
interface ChatUpdateArgument {
messages: ChatMessagePartial[];
requestId: string;
result: null;
}
interface ChatMessagePartial {
text: string;
author: Author;
createdAt: string;
timestamp: string;
messageId: string;
offense: string;
adaptiveCards: AdaptiveCard[];
sourceAttributions: any[];
feedback: ChatMessageFeedback;
contentOrigin: string;
privacy?: null;
messageType?: string;
}
interface AdaptiveCard {
type: string;
version: string;
body: AdaptiveCardBody[];
}
interface AdaptiveCardBody {
type: string;
text: string;
wrap: boolean;
}
interface ChatMessageFeedback {
tag: null;
updatedOn: null;
type: string;
}
interface ChatUpdateCompleteResponse {
type: 2;
invocationId: string;
item: ChatResponseItem;
}
interface ChatResponseItem {
messages: ChatMessageFull[];
firstNewMessageIndex: number;
suggestedResponses: null;
conversationId: string;
requestId: string;
conversationExpiryTime: string;
telemetry: Telemetry;
result: ChatRequestResult;
}
interface ChatMessageFull {
text: string;
author: Author;
from?: ChatMessageFrom;
createdAt: string;
timestamp: string;
locale?: string;
market?: string;
region?: string;
location?: string;
locationHints?: LocationHint[];
messageId: string;
requestId: string;
offense: string;
feedback: ChatMessageFeedback;
contentOrigin: string;
privacy?: null;
inputMethod?: string;
adaptiveCards?: AdaptiveCard[];
sourceAttributions?: any[];
suggestedResponses?: SuggestedResponse[];
messageType?: string;
}
interface ChatMessageFrom {
id: string;
name: null;
}
interface LocationHint {
country: string;
countryConfidence: number;
state: string;
city: string;
cityConfidence: number;
zipCode: string;
timeZoneOffset: number;
dma: number;
sourceType: number;
center: Coords;
regionType: number;
}
interface Coords {
latitude: number;
longitude: number;
height: null;
}
interface SuggestedResponse {
text: string;
messageId: string;
messageType: string;
contentOrigin: string;
author?: Author;
createdAt?: string;
timestamp?: string;
offense?: string;
feedback?: ChatMessageFeedback;
privacy?: null;
}
interface ChatRequestResult {
value: string;
serviceVersion: string;
}
interface Telemetry {
metrics?: null;
startTime: string;
}
interface ChatRequest {
arguments: ChatRequestArgument[];
invocationId: string;
target: string;
type: number;
}
interface ChatRequestArgument {
source: string;
optionsSets: string[];
allowedMessageTypes: string[];
sliceIds: any[];
traceId: string;
isStartOfSession: boolean;
message: ChatRequestMessage;
conversationSignature: string;
participant: Participant;
conversationId: string;
previousMessages: PreviousMessage[];
}
interface ChatRequestMessage {
locale: string;
market: string;
region?: string;
location?: string;
locationHints?: LocationHintChatRequestMessage[];
timestamp: string;
author: Author;
inputMethod: string;
text: string;
messageType: string;
}
interface LocationHintChatRequestMessage {
country: string;
state: string;
city: string;
zipcode: string;
timezoneoffset: number;
dma: number;
countryConfidence: number;
cityConfidence: number;
Center: Center;
RegionType: number;
SourceType: number;
}
interface Center {
Latitude: number;
Longitude: number;
}
interface Participant {
id: string;
}
interface PreviousMessage {
text: string;
author: Author;
adaptiveCards: any[];
suggestedResponses: SuggestedResponse[];
messageId: string;
messageType: string;
}
declare class BingChat {
protected _cookie: string;
protected _debug: boolean;
constructor(opts: {
cookie: string | undefined;
/** @defaultValue `false` **/
debug?: boolean;
});
/**
* Sends a message to Bing Chat, waits for the response to resolve, and returns
* the response.
*
* If you want to receive a stream of partial responses, use `opts.onProgress`.
*
* @param message - The prompt message to send
* @param opts.conversationId - Optional ID of a conversation to continue (defaults to a random UUID)
* @param opts.onProgress - Optional callback which will be invoked every time the partial response is updated
*
* @returns The response from Bing Chat
*/
sendMessage(text: string, opts?: SendMessageOptions): Promise<ChatMessage>;
createConversation(): Promise<ConversationResult>;
}
export {
APIResult,
AdaptiveCard,
AdaptiveCardBody,
Author,
BingChat,
Center,
ChatMessage,
ChatMessageFeedback,
ChatMessageFrom,
ChatMessageFull,
ChatMessagePartial,
ChatRequest,
ChatRequestArgument,
ChatRequestMessage,
ChatRequestResult,
ChatResponseItem,
ChatUpdate,
ChatUpdateArgument,
ChatUpdateCompleteResponse,
ConversationResult,
Coords,
LocationHint,
LocationHintChatRequestMessage,
Participant,
PreviousMessage,
SendMessageOptions,
SuggestedResponse,
Telemetry,
};
|