Giter Site home page Giter Site logo

Comments (3)

yuameshi avatar yuameshi commented on June 5, 2024 2

i've wrote a wrapper for it, it judge wether the content ends by detecting the update rate of partitial content.

i think it is a bad solution.

Anyway, I hope this bug will be fixed soon.

Here's the code, but i cant test it because it throwed a Request is throttled. , but it should work(?).

/**
 * @param { import("bing-chat").BingChat } client
 * @param { string } message
 * @param { import("bing-chat").ChatMessage } [session]
 * @returns { Promise<import("bing-chat").ChatMessage> }
 */
function bingAiMessageSendWrapper(client, message, session) {
	const TIMEOUT_THRESHOLD = 20 * 1000;
	return new Promise((resolve, reject) => {
		let response = {};
		let responseText = '';
		let temp = {
			time: new Date().valueOf(),
			response: response,
		};
		const verifyIfResponseChangedInterval = setInterval(() => {
			if (new Date().valueOf() - temp.time > TIMEOUT_THRESHOLD) {
				clearInterval(verifyIfResponseChangedInterval);
				temp.response.text = responseText;
				resolve(temp.response);
			}
		}, 500);
		client
			.sendMessage(message, {
				...session,
				onProgress: (partialResponse) => {
					temp.response = partialResponse;
					responseText += partialResponse.text;
					temp.time = new Date().valueOf();
				},
			})
			.then((response) => {
				resolve(response);
			})
			.catch((error) => {
				reject(error);
			});
	});
}

from bing-chat.

yuameshi avatar yuameshi commented on June 5, 2024

i've got same problem too , but there does appears answer when i add

onProgress: (partialResponse) => {
	console.log(partialResponse.text);
},

though there was an answer(?), but the promise call never ends (i use await api.sendMessage too).

from bing-chat.

yuameshi avatar yuameshi commented on June 5, 2024

so i think the best way to solve the problem without waiting for update is to use the onProgress call.

I m trying to write some code on it , ASAP.

from bing-chat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.