From 4aff7f991a97063ead98cf79ab67cb1f7d94b85c Mon Sep 17 00:00:00 2001 From: n4ze3m Date: Sat, 16 Mar 2024 14:28:32 +0530 Subject: [PATCH] Update package version and add hideEditAndRegenerate prop --- package.json | 2 +- src/components/Common/Playground/Message.tsx | 36 +++++++++++--------- src/components/Sidepanel/Chat/body.tsx | 1 + src/web/web.ts | 11 +++++- 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index 8cf6e16..e7e777c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pageassist", "displayName": "Page Assist - A Web UI for Local AI Models", - "version": "1.0.8", + "version": "1.0.9", "description": "Use your locally running AI models to assist you in your web browsing.", "author": "n4ze3m", "scripts": { diff --git a/src/components/Common/Playground/Message.tsx b/src/components/Common/Playground/Message.tsx index 7063049..abebce2 100644 --- a/src/components/Common/Playground/Message.tsx +++ b/src/components/Common/Playground/Message.tsx @@ -21,6 +21,7 @@ type Props = { webSearch?: {} isSearchingInternet?: boolean sources?: any[] + hideEditAndRegenerate?: boolean } export const PlaygroundMessage = (props: Props) => { @@ -130,24 +131,27 @@ export const PlaygroundMessage = (props: Props) => { )} - {props.currentMessageIndex === props.totalMessages - 1 && ( - - - - )} + {!props.hideEditAndRegenerate && + props.currentMessageIndex === props.totalMessages - 1 && ( + + + + )} )} - - - + {!props.hideEditAndRegenerate && ( + + + + )} )} diff --git a/src/components/Sidepanel/Chat/body.tsx b/src/components/Sidepanel/Chat/body.tsx index d3f117c..a96fae9 100644 --- a/src/components/Sidepanel/Chat/body.tsx +++ b/src/components/Sidepanel/Chat/body.tsx @@ -26,6 +26,7 @@ export const SidePanelBody = () => { totalMessages={messages.length} onRengerate={() => {}} isProcessing={streaming} + hideEditAndRegenerate /> ))}
diff --git a/src/web/web.ts b/src/web/web.ts index be1eef1..f062ecd 100644 --- a/src/web/web.ts +++ b/src/web/web.ts @@ -1,6 +1,15 @@ import { getWebSearchPrompt } from "~services/ollama" import { webSearch } from "./local-google" +const getHostName = (url: string) => { + try { + const hostname = new URL(url).hostname + return hostname + } catch (e) { + return "" + } +} + export const getSystemPromptForWeb = async (query: string) => { try { const search = await webSearch(query) @@ -18,7 +27,7 @@ export const getSystemPromptForWeb = async (query: string) => { source: search.map((result) => { return { url: result.url, - name: new URL(result.url).hostname, + name: getHostName(result.url), type: "url", } })