Brevilabs CORS issue (#918)

* Add logging for time range query
* Fix dupe system prompt for vault search
* Use safefetch for brevilabs
* Rename ribbon icon to Open Copilot Chat
This commit is contained in:
Logan Yang 2024-12-10 08:28:18 -08:00 committed by GitHub
parent a5e75b1947
commit e49aafa393
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 25 additions and 5 deletions

View file

@ -1,7 +1,9 @@
import { BREVILABS_API_BASE_URL } from "@/constants";
import { Notice } from "obsidian";
import { getSettings } from "@/settings/model";
import { getDecryptedKey } from "@/encryptionService";
import { getSettings } from "@/settings/model";
import { safeFetch } from "@/utils";
import { Notice } from "obsidian";
export interface BrocaResponse {
response: {
tool_calls: Array<{
@ -88,7 +90,7 @@ export class BrevilabsClient {
});
}
const response = await fetch(url.toString(), {
const response = await safeFetch(url.toString(), {
method,
headers: {
"Content-Type": "application/json",

View file

@ -302,6 +302,11 @@ class CopilotPlusChainRunner extends BaseChainRunner {
content,
});
// Add debug logging for final request
if (debug) {
console.log("==== Final Request to AI ====\n", messages);
}
let fullAIResponse = "";
const chatStream = await this.chainManager.chatModelManager.getChatModel().stream(messages);
@ -427,7 +432,7 @@ class CopilotPlusChainRunner extends BaseChainRunner {
const qaPrompt = await this.chainManager.promptManager.getQAPrompt({
question: standaloneQuestion,
context: context,
systemMessage: getSystemPrompt(),
systemMessage: "", // System prompt is added separately in streamMultimodalResponse
});
fullAIResponse = await this.streamMultimodalResponse(

View file

@ -30,6 +30,7 @@ export class IntentAnalyzer {
indexTool,
pomodoroTool,
webSearchTool,
simpleYoutubeTranscriptionTool,
];
static async analyzeIntent(

View file

@ -99,7 +99,7 @@ export default class CopilotPlugin extends Plugin {
},
});
this.addRibbonIcon("message-square", "Copilot Chat", (evt: MouseEvent) => {
this.addRibbonIcon("message-square", "Open Copilot Chat", (evt: MouseEvent) => {
this.activateView();
});

View file

@ -246,6 +246,14 @@ export class HybridRetriever extends BaseRetriever {
const dateRange = this.generateDateRange(startDate, endDate);
if (this.debug) {
console.log(
"==== Daily note date range: ====",
dateRange[0],
dateRange[dateRange.length - 1]
);
}
// Perform the first search with title filter
const dailyNoteResults = await this.getExplicitChunks(dateRange);
@ -258,6 +266,10 @@ export class HybridRetriever extends BaseRetriever {
},
}));
if (this.debug) {
console.log("==== Modified and created time range: ====", startTimestamp, endTimestamp);
}
// Perform a second search with time range filters
searchParams.where = {
ctime: { between: [startTimestamp, endTimestamp] },