khoj-ai / khoj

Your AI second brain. Self-hostable. Get answers from the web or your docs. Build custom agents, schedule automations, do deep research. Turn any online or local LLM into your personal, autonomous AI (e.g gpt, claude, gemini, llama, qwen, mistral).
https://khoj.dev
GNU Affero General Public License v3.0
15.93k stars 786 forks source link

Make most major changes for an updated chat UI #843

Closed sabaimran closed 4 months ago

sabaimran commented 4 months ago
Screenshot 2024-07-09 at 19 49 06

The speaker icon (to talk back) is still non-functional. Mic is still non-functional.

gitguardian[bot] commented 4 months ago

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | | | -------------- | ------------------ | ------------------------------ | ---------------- | --------------- | -------------------- | | [10005301](https://dashboard.gitguardian.com/workspace/453364/incidents/10005301?occurrence=160224960) | Triggered | Generic Password | bf4c2f219ee36f9a26fc657f60961a2a7fcfce0c | src/khoj/app/settings.py | [View secret](https://github.com/khoj-ai/khoj/commit/bf4c2f219ee36f9a26fc657f60961a2a7fcfce0c#diff-12e11c5157feddb98d0a76795945d4ecbea098e12b35c03ee964fb832f85b6adL123) |
🛠 Guidelines to remediate hardcoded secrets
1. Understand the implications of revoking this secret by investigating where it is used in your code. 2. Replace and store your secret safely. [Learn here](https://blog.gitguardian.com/secrets-api-management?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment) the best practices. 3. Revoke and [rotate this secret](https://docs.gitguardian.com/secrets-detection/secrets-detection-engine/detectors/generics/generic_password#revoke-the-secret?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment). 4. If possible, [rewrite git history](https://blog.gitguardian.com/rewriting-git-history-cheatsheet?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment). Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data. To avoid such incidents in the future consider - following these [best practices](https://blog.gitguardian.com/secrets-api-management/?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment) for managing and storing secrets including API keys and other credentials - install [secret detection on pre-commit](https://docs.gitguardian.com/ggshield-docs/integrations/git-hooks/pre-commit?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment) to catch secret before it leaves your machine and ease remediation.

🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

sabaimran commented 4 months ago

To test locally,

  1. Run yarn export from src/interface/web.
  2. Update file returned in relevant web_client.py APIs.

Sample code for local testing in web_client.py.

src/khoj/routers/web_client.py
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

─────────────────────────────────────────────────────────────────────────────────────┐
41: templates = Jinja2Templates([constants.web_directory, constants.next_js_director │
─────────────────────────────────────────────────────────────────────────────────────┘
@web_client.get("/", response_class=FileResponse)
@requires(["authenticated"], redirect="login_page")
def index(request: Request):
    return templates.TemplateResponse(
        "chat/index.html",
        context={
            "request": request,
        },
    )

    user = request.user.object
    user_picture = request.session.get("user", {}).get("picture")
    has_documents = EntryAdapters.user_has_entries(user=user)

─────────────────────────────────┐
68: def index(request: Request): │
─────────────────────────────────┘
@web_client.post("/", response_class=FileResponse)
@requires(["authenticated"], redirect="login_page")
def index_post(request: Request):
    return templates.TemplateResponse(
        "chat/index.html",
        context={
            "request": request,
        },
    )

    user = request.user.object
    user_picture = request.session.get("user", {}).get("picture")
    has_documents = EntryAdapters.user_has_entries(user=user)

────────────────────────────────────────┐
115: def search_page(request: Request): │
────────────────────────────────────────┘
@web_client.get("/chat", response_class=FileResponse)
@requires(["authenticated"], redirect="login_page")
def chat_page(request: Request):

    return templates.TemplateResponse(
        "chat/index.html",
        context={
            "request": request,
        },
    )

    user = request.user.object
    user_picture = request.session.get("user", {}).get("picture")
    has_documents = EntryAdapters.user_has_entries(user=user)

─────────────────────────────────────────────────┐
415: def computer_config_page(request: Request): │
─────────────────────────────────────────────────┘

@web_client.get("/share/chat/{public_conversation_slug}", response_class=HTMLResponse)
def view_public_conversation(request: Request):
    return templates.TemplateResponse(
        "share/chat/index.html",
        context={
            "request": request,
        },
    )

    public_conversation_slug = request.path_params.get("public_conversation_slug")
    public_conversation = PublicConversationAdapters.get_public_conversation_by_slug(public_conversation_slug)
    if not public_conversation: