Compare commits

...

6 Commits

Author SHA1 Message Date
sweep-ai[bot] 8e9f08d00e Merge main into sweep/add-condense-question-chat-engine-example 2023-10-30 20:59:22 +00:00
sweep-ai[bot] c64622ce45 Merge main into sweep/add-condense-question-chat-engine-example 2023-10-30 17:56:40 +00:00
sweep-ai[bot] 0c9ff4054f feat: Updated apps/simple/condenseQuestionChatEngi 2023-10-30 13:03:42 +00:00
sweep-ai[bot] c5c6c8fe43 feat: Updated apps/simple/condenseQuestionChatEngi 2023-10-30 13:02:31 +00:00
sweep-ai[bot] a8ba11bcf7 feat: Updated apps/simple/condenseQuestionChatEngi 2023-10-30 13:01:07 +00:00
sweep-ai[bot] 92a470a1cb feat: Add example for using CondenseQuestionChatEn 2023-10-30 13:00:12 +00:00
@@ -0,0 +1,31 @@
import { CondenseQuestionChatEngine, ChatMessage } from '../../packages/core/src/ChatEngine';
import { BaseQueryEngine } from '../../packages/core/src/QueryEngine';
import { ServiceContext } from '../../packages/core/src/ServiceContext';
import { defaultCondenseQuestionPrompt } from '../../packages/core/src/Prompt';
// Mock implementation of BaseQueryEngine
class MockQueryEngine implements BaseQueryEngine {
async query(query: string) {
return { response: 'Mock response', getFormattedSources: () => [] };
}
}
const queryEngine = new MockQueryEngine();
import { serviceContextFromDefaults } from '../../packages/core/src/ServiceContext';
const serviceContext = serviceContextFromDefaults();
const condenseQuestionChatEngine = new CondenseQuestionChatEngine({
queryEngine: queryEngine,
chatHistory: [],
serviceContext: serviceContext,
condenseMessagePrompt: defaultCondenseQuestionPrompt,
});
// Using the chat method
const message = 'Sample message';
const response = condenseQuestionChatEngine.chat(message);
console.log(response);
// Using the reset method
condenseQuestionChatEngine.reset();