diff --git a/.github/workflows/github_pages_deploy.yml b/.github/workflows/github_pages_deploy.yml index 13d15269..9e02c97f 100644 --- a/.github/workflows/github_pages_deploy.yml +++ b/.github/workflows/github_pages_deploy.yml @@ -1,4 +1,4 @@ -name: build and deploy github pages for documentation +name: deploy documentation on: push: branches: diff --git a/documentation/docs/advanced/lmstudio.md b/documentation/docs/advanced/lmstudio.md index 1ecd7f06..59eb0592 100644 --- a/documentation/docs/advanced/lmstudio.md +++ b/documentation/docs/advanced/lmstudio.md @@ -14,14 +14,14 @@ LM Studio can expose an [OpenAI API compatible server](https://lmstudio.ai/docs/ ## Setup 1. Install [LM Studio](https://lmstudio.ai/) and download your preferred Chat Model 2. Go to the Server Tab on LM Studio, Select your preferred Chat Model and Click the green Start Server button -3. Create a new [OpenAI Processor Conversation Config](http://localhost:42110/server/admin/database/openaiprocessorconversationconfig/add) on your Khoj admin panel +3. Create a new [Add ai model api](http://localhost:42110/server/admin/database/aimodelapi/add/) on your Khoj admin panel - Name: `proxy-name` - Api Key: `any string` - Api Base Url: `http://localhost:1234/v1/` (default for LMStudio) 4. Create a new [Chat Model](http://localhost:42110/server/admin/database/chatmodel/add) on your Khoj admin panel. - Name: `llama3.1` (replace with the name of your local model) - Model Type: `Openai` - - Openai Config: `` + - Ai model api: `` - Max prompt size: `20000` (replace with the max prompt size of your model) - Tokenizer: *Do not set for OpenAI, mistral, llama3 based models* 5. Go to [your config](http://localhost:42110/settings) and select the model you just created in the chat model dropdown. diff --git a/src/interface/web/app/settings/page.tsx b/src/interface/web/app/settings/page.tsx index 7452e4f9..bebc979f 100644 --- a/src/interface/web/app/settings/page.tsx +++ b/src/interface/web/app/settings/page.tsx @@ -52,6 +52,8 @@ import { Waveform, MagnifyingGlass, Brain, + EyeSlash, + Eye, } from "@phosphor-icons/react"; import Loading from "../components/loading/loading"; @@ -182,6 +184,101 @@ const useApiKeys = () => { }; }; +function ApiKeyCard() { + const { apiKeys, generateAPIKey, copyAPIKey, deleteAPIKey } = useApiKeys(); + const [visibleApiKeys, setVisibleApiKeys] = useState>(new Set()); + const { toast } = useToast(); + + return ( + + + + + API Keys + + + + +

+ Access Khoj from the{" "} + + Desktop + + , Obsidian,{" "} + Emacs apps and more. +

+ + + {apiKeys.map((key) => ( + + {key.name} + + + {visibleApiKeys.has(key.token) + ? key.token + : `${key.token.slice(0, 6)}...${key.token.slice(-4)}`} + +
+ {visibleApiKeys.has(key.token) ? ( + + setVisibleApiKeys((prev) => { + const next = new Set(prev); + next.delete(key.token); + return next; + }) + } + /> + ) : ( + + setVisibleApiKeys( + new Set([...visibleApiKeys, key.token]), + ) + } + /> + )} + { + toast({ + title: `🔑 Copied API Key: ${key.name}`, + description: `Set this API key in the Khoj apps you want to connect to this Khoj account`, + }); + copyAPIKey(key.token); + }} + /> + { + toast({ + title: `🔑 Deleted API Key: ${key.name}`, + description: `Apps using this API key will no longer connect to this Khoj account`, + }); + deleteAPIKey(key.token); + }} + /> +
+
+
+ ))} +
+
+
+ +
+ ); +} + enum PhoneNumberValidationState { Setup = "setup", SendOTP = "otp", @@ -190,7 +287,6 @@ enum PhoneNumberValidationState { } export default function SettingsView() { - const { apiKeys, generateAPIKey, copyAPIKey, deleteAPIKey } = useApiKeys(); const { userConfig: initialUserConfig } = useUserConfig(true); const [userConfig, setUserConfig] = useState(null); const [name, setName] = useState(undefined); @@ -206,7 +302,7 @@ export default function SettingsView() { const title = "Settings"; const cardClassName = - "w-full lg:w-5/12 grid grid-flow-column border border-gray-300 shadow-md rounded-lg border dark:border-none dark:bg-muted border-opacity-50"; + "w-full lg:w-5/12 grid grid-flow-column border border-gray-300 shadow-md rounded-lg border dark:border-none border-opacity-50 dark:bg-muted"; useEffect(() => { setUserConfig(initialUserConfig); @@ -1018,92 +1114,7 @@ export default function SettingsView() { Clients
- {!userConfig.anonymous_mode && ( - - - - - API Keys - - - - -

- Access Khoj from the{" "} - - Desktop - - ,{" "} - - Obsidian - - ,{" "} - - Emacs - {" "} - apps and more. -

- - - {apiKeys.map((key) => ( - - - {key.name} - - - - {`${key.token.slice(0, 6)}...${key.token.slice(-4)}`} - -
- { - toast({ - title: `🔑 Copied API Key: ${key.name}`, - description: `Set this API key in the Khoj apps you want to connect to this Khoj account`, - }); - copyAPIKey( - key.token, - ); - }} - /> - { - toast({ - title: `🔑 Deleted API Key: ${key.name}`, - description: `Apps using this API key will no longer connect to this Khoj account`, - }); - deleteAPIKey( - key.token, - ); - }} - /> -
-
-
- ))} -
-
-
- -
- )} + {!userConfig.anonymous_mode && } diff --git a/src/interface/web/app/settings/settings.module.css b/src/interface/web/app/settings/settings.module.css index 5cb41e51..195b6b4c 100644 --- a/src/interface/web/app/settings/settings.module.css +++ b/src/interface/web/app/settings/settings.module.css @@ -23,6 +23,7 @@ div.phoneInput input { width: 100%; padding: 0.5rem; border: 1px solid hsla(var(--border)); + background-color: hsla(var(--background)); border-radius: 0.25rem; } diff --git a/src/khoj/utils/initialization.py b/src/khoj/utils/initialization.py index a4864dcc..83062a21 100644 --- a/src/khoj/utils/initialization.py +++ b/src/khoj/utils/initialization.py @@ -267,7 +267,7 @@ def initialization(interactive: bool = True): ) # Remove models that are no longer available - existing_models.exclude(chat_model__in=available_models).delete() + existing_models.exclude(name__in=available_models).delete() except Exception as e: logger.warning(f"Failed to update models for {config.name}: {str(e)}")