Skip to content

Commit

Permalink
refactor: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alenakhineika committed Sep 14, 2024
1 parent a8a0405 commit a1a538b
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/participant/participant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface ChatResult extends vscode.ChatResult {
databaseName?: string;
collectionName?: string;
};
schema?: string;
sampleDocuments?: Document[];
};
}

Expand Down Expand Up @@ -640,31 +640,25 @@ export default class ParticipantController {
);
}

const schema = sampleDocuments
? new SchemaFormatter().format(await getSimplifiedSchema(sampleDocuments))
: undefined;

const useSampleDocsInCopilot = !!vscode.workspace
.getConfiguration('mdb')
.get('useSampleDocsInCopilot');
sampleDocuments =
sampleDocuments && useSampleDocsInCopilot
? getSimplifiedSampleDocuments(sampleDocuments)
: undefined;

const messages = await QueryPrompt.buildMessages({
request,
context,
databaseName: namespace.databaseName,
collectionName: namespace.collectionName,
schema,
sampleDocuments,
schema: sampleDocuments
? new SchemaFormatter().format(
await getSimplifiedSchema(sampleDocuments)
)
: undefined,
sampleDocuments:
sampleDocuments && useSampleDocsInCopilot
? getSimplifiedSampleDocuments(sampleDocuments)
: undefined,
});
// eslint-disable-next-line @typescript-eslint/no-var-requires
const util = require('util');
console.log('messages----------------------');
console.log(`${util.inspect(messages)}`);
console.log('----------------------');
const responseContent = await this.getChatResponseContent({
messages,
stream,
Expand All @@ -685,7 +679,13 @@ export default class ParticipantController {
});
}

return { metadata: { responseContent: runnableContent, namespace } };
return {
metadata: {
responseContent: runnableContent,
namespace,
sampleDocuments,
},
};
}

async chatHandler(
Expand Down

0 comments on commit a1a538b

Please sign in to comment.