Adding Embeddings endpoint, and reconfiguring env variables. - #130
Adding Embeddings endpoint, and reconfiguring env variables.#130Enielect wants to merge 17 commits into
Conversation
…ghtweight'. There seems to be an inconsistency with the latest version of novel-lightweight, so I just imported from 'novel' instead
|
@Enielect is attempting to deploy a commit to the The Personal AI Company Team on Vercel. A member of the Team first needs to authorize it. |
|
@sansyrox here is a PR, please can you help review this? I should get the merge conflict fixed soon, just realized it was cause by something added after I had forked the repo |
dwi11harsh
left a comment
There was a problem hiding this comment.
Thanks for the substantial improvements and local-model support!
I’m requesting a few changes to improve robustness and deployment safety before merge.
| NEXT_PUBLIC_BASE_URL=http://0.0.0.0:8080 | ||
| NEXT_PUBLIC_APP_URL=http://localhost:3000 | ||
| NEXT_PUBLIC_LOCAL_AI_MODEL_URL=http://localhost:11434/api | ||
| NEXT_PUBLIC_BASE_URL_EMBEDDINGS="https://api.mistral.ai/v1/" | ||
|
|
||
| MODEL_NAME=llama3.1:8b | ||
| CLIENT_MODE=local |
There was a problem hiding this comment.
no need to add the values here
suggesting on README is sufficient
| }; | ||
|
|
||
| let PipelineSingleton; | ||
| if (process.env.NODE_ENV !== "production") { |
There was a problem hiding this comment.
validate env variable before using
| process.env.GOOGLE_CLIENT_ID_NEW, | ||
| process.env.GOOGLE_CLIENT_SECRET_NEW, | ||
| process.env.GOOGLE_REDIRECT_URI_NEW | ||
| process.env.GOOGLE_REDIRECT_URI |
There was a problem hiding this comment.
let's not change this as we would also need to fix this in server
| if (process.env.CLIENT_MODE === 'local') { | ||
| // Use local Ollama model as fallback | ||
| try { | ||
| const response = await fetch('http://localhost:11434/api/generate', { |
There was a problem hiding this comment.
since this url is already present in environment variable, using it here might be a better option
| if (process.env.CLIENT_MODE === 'local' && process.env.MODEL_NAME) { | ||
| try { | ||
| // Use local Ollama API | ||
| const response = await fetch('http://localhost:11434/api/generate', { |
There was a problem hiding this comment.
use environment value instead of hardcoded url
|
|
||
| // Function to check which model to use and make the appropriate API call | ||
| async function generateCompletion(messages, modelName) { | ||
| const clientMode = process.env.CLIENT_MODE; |
There was a problem hiding this comment.
not validating could cause runtime failure
| if (misttralApiKey?.length == 0) { | ||
| embeddingResponse = await fetch("/api/embed", { | ||
| method: "GET", | ||
| body: JSON.stringify({text: truncatedText}), |
There was a problem hiding this comment.
truncatedText is not defined
|
|
||
| // fetching user's sessions | ||
| const fetchUserThreads = async () => { | ||
| console.log(session?.user?.id, 'user Id from session in fetchUserThreads') |
| .select("analytics_enabled") | ||
| .eq("id", userId) | ||
| .single(); | ||
|
|
There was a problem hiding this comment.
consider using
if (!analyticsEnabled) return;
to save additional api calls
| client.client_id, | ||
| client.client_secret, | ||
| process.env.GOOGLE_REDIRECT_URI_NEW | ||
| process.env.GOOGLE_REDIRECT_URI // why is there new in front of it??? |
There was a problem hiding this comment.
lets leave this as is and maybe fix this later (in some other PR)
| client.client_id, | ||
| client.client_secret, | ||
| process.env.GOOGLE_REDIRECT_URI // why is there new in front of it??? | ||
| process.env.GOOGLE_REDIRECT_URI_NEW // why is there new in front of it??? |
…-web into self-hosting-web-app and fix some conflicts
This pull request introduces significant updates to the
.env.exampleconfiguration, environment-specific behavior, and the integration of a local AI model for generating embeddings and tags. It also includes enhancements to API routes, dependency updates, and minor logging improvements. Below is a categorized summary of the most important changes:Environment Configuration Updates
.env.exampleandREADME.mdfor local AI model integration, includingNEXT_PUBLIC_LOCAL_AI_MODEL_URL,MODEL_NAME, andCLIENT_MODEto enable switching between local and cloud-based models. [1] [2]BRAIN_API_KEYfor linking platforms. [1] [2]AI Model Integration
src/app/api/embed/pipeline.jsfor lazy initialization of a feature-extraction pipeline using the@xenova/transformerslibrary.src/app/api/embed/route.jsto generate embeddings using the pipeline.google/import,notion/import,obsidian/upload, andsearch). These routes now conditionally use the local Ollama model whenCLIENT_MODEis set tolocal. [1] [2] [3] [4]Dependency and Configuration Updates
@xenova/transformersas a dependency inpackage.jsonfor handling AI model pipelines.next.config.mjsto include experimental support for external packages (sharpandonnxruntime-node).Code Simplification and Bug Fixes
GOOGLE_REDIRECT_URI_NEW) with the correct variableGOOGLE_REDIRECT_URIin multiple Google OAuth-related API routes. [1] [2] [3]src/app/api/google/callback/route.jsfor clarity.Minor Enhancements
meetingsandsearchpages to respect user preferences for analytics. (src/app/meetings/[id]/page.jsR69-R77, src/app/search/page.jsR689)These changes collectively enhance the application's flexibility, enabling local AI model usage, improving configuration clarity, and refining API behavior.