Skip to content

Add support for free Azure Search endpoint and GitHub models #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ankitrjk
Copy link

@ankitrjk ankitrjk commented May 2, 2025

This PR leverages GitHub tokens to access free GitHub Models endpoint for GPT models and embeddings, as well as free Azure AI Search endpoints for data indexing and retrieval. These changes allow users to explore and use the application without incurring any costs.

@manekinekko manekinekko requested a review from Copilot June 19, 2025 07:10
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for free access to GitHub Models and Azure AI Search services without cost, allowing users to try the application without incurring charges.

  • Migrates settings initialization to support conditional vector store instantiation.
  • Introduces helper functions for Azure AI Search and GitHub models configuration.
  • Updates documentation and environment setup instructions for free endpoint usage.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
app/api/chat/route.ts Delegates vector store initialization to a new helper function.
app/api/chat/engine/settings.ts Refactors settings initialization using helper functions and updates error messages.
app/api/chat/engine/createIndex.ts Implements retrieval of search endpoint details with basic error logging.
app/api/chat/engine/chat.ts Uses a helper to configure retriever options based on environment tokens.
README.md Updates documentation regarding no-cost application usage.
.env.example Adds GITHUB_TOKEN instructions for local development.

...openAiConfig,
model: process.env.AZURE_OPENAI_CHAT_DEPLOYMENT,
});
Settings.llm = new OpenAI(createOpenAiParams(openAiConfig, githubToken));
console.log({ openAiConfig });
Copy link
Preview

Copilot AI Jun 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider removing or limiting this debug log to avoid exposing sensitive configuration details in production.

Suggested change
console.log({ openAiConfig });
if (process.env.NODE_ENV === 'development') {
console.log("OpenAI configuration initialized.");
}

Copilot uses AI. Check for mistakes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This log statement wasn't introduced in this PR, so I’d prefer to keep this PR focused on the current scope. Happy to include the change here if you'd prefer, just let me know.

console.log(`Your Azure AI Search Endpoint: ${searchServiceEndpoint}; Index Name: ${searchIndexName}`);
return { endpoint: searchServiceEndpoint, indexName: searchIndexName };
} catch (error) {
console.error("Error while retrieving search service details", error);
Copy link
Preview

Copilot AI Jun 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of solely logging errors, consider throwing an exception or returning an error result to better surface failures in retrieving search service details.

Suggested change
console.error("Error while retrieving search service details", error);
console.error("Error while retrieving search service details", error);
throw new Error("Failed to retrieve search service details: " + error.message);

Copilot uses AI. Check for mistakes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of an error, searchService object would be null and an exception is already being thrown here.

Comment on lines +13 to +16
const createRetrieverOptions = () => {
return process.env.GITHUB_TOKEN
? { mode: "hybrid" as any }
: { mode: "semantic_hybrid" as any, similarityTopK: 5 };
Copy link
Preview

Copilot AI Jun 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using 'as any' bypasses type checking; consider defining proper types or using existing enums to enforce valid retriever modes.

Suggested change
const createRetrieverOptions = () => {
return process.env.GITHUB_TOKEN
? { mode: "hybrid" as any }
: { mode: "semantic_hybrid" as any, similarityTopK: 5 };
type RetrieverMode = "hybrid" | "semantic_hybrid";
const createRetrieverOptions = (): { mode: RetrieverMode; similarityTopK?: number } => {
return process.env.GITHUB_TOKEN
? { mode: "hybrid" }
: { mode: "semantic_hybrid", similarityTopK: 5 };

Copilot uses AI. Check for mistakes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding explicit type for VectorStoreQueryMode results in the following import error:
Attempted import error: 'VectorStoreQueryMode' is not exported from 'llamaindex' (imported as 'VectorStoreQueryMode').

Hence kept the type as any. May be in future version when llamaindex version is upgraded then the explicit type can be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant