Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1793,8 +1793,8 @@ export async function fetchAndUpdateSidebar() {
throw new Error(`Failed to fetch sidebar: ${response.statusText}`);
}
sidebarContent = await response.text();
console.log('Successfully fetched and updated sidebar content');
console.log(sidebarContent);
console.error('Successfully fetched and updated sidebar content');
console.error(sidebarContent);
} catch (error) {
console.error('Error fetching sidebar:', error);
// We'll keep using the fallback content if fetch fails
Expand Down
10 changes: 5 additions & 5 deletions tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ import { z } from "zod";
export const getGuide = async ({
guideLink,
}: z.infer<typeof getGuideParams>) => {
console.log("Received request for guide:", guideLink);
console.error("Received request for guide:", guideLink);
try {
// Remove the base URL prefix and ensure the path starts correctly
const guidePath = guideLink.replace("https://docs.base.org", "");
const githubRawUrl = `https://raw.githubusercontent.com/base/web/refs/heads/master/apps/base-docs/docs/pages${guidePath}.mdx`;
console.log("Fetching from URL:", githubRawUrl);
console.error("Fetching from URL:", githubRawUrl);

const response = await fetch(githubRawUrl);
if (!response.ok) {
throw new Error(`Failed to fetch guide: ${response.statusText}`);
}
const guide = await response.text();
console.log("Successfully fetched guide content");
console.error("Successfully fetched guide content");

let finalResult = guide;

if (process.env.OPENAI_API_KEY) {
const client = new OpenAI();
// Process the guide content with GPT-4
console.log("Processing with ChatGPT...");
console.error("Processing with ChatGPT...");
const result = await client.responses.create({
model: "gpt-4o-mini",
input: [
Expand All @@ -37,7 +37,7 @@ export const getGuide = async ({
],
});
finalResult = result.output_text;
console.log("Successfully processed guide content");
console.error("Successfully processed guide content");
}

return {
Expand Down