diff --git a/.changeset/tidy-months-dance.md b/.changeset/tidy-months-dance.md new file mode 100644 index 0000000000000000000000000000000000000000..a459ff8e68ae4216521aa4a407fada7b66605363 --- /dev/null +++ b/.changeset/tidy-months-dance.md @@ -0,0 +1,5 @@ +--- +"create-llama": patch +--- + +Allow relative URL in documents diff --git a/templates/types/streaming/nextjs/app/components/ui/chat/index.ts b/templates/types/streaming/nextjs/app/components/ui/chat/index.ts index 669f404adac58a6e50c6a0a0a18f7cfc6e1e7cb5..cacd5503d2b563326478707595deb5857ee9f99f 100644 --- a/templates/types/streaming/nextjs/app/components/ui/chat/index.ts +++ b/templates/types/streaming/nextjs/app/components/ui/chat/index.ts @@ -1,5 +1,4 @@ import { JSONValue } from "ai"; -import { isValidUrl } from "../lib/utils"; import ChatInput from "./chat-input"; import ChatMessages from "./chat-messages"; @@ -113,7 +112,7 @@ function preprocessSourceNodes(nodes: SourceNode[]): SourceNode[] { // Filter source nodes has lower score nodes = nodes .filter((node) => (node.score ?? 1) > NODE_SCORE_THRESHOLD) - .filter((node) => isValidUrl(node.url)) + .filter((node) => node.url && node.url.trim() !== "") .sort((a, b) => (b.score ?? 1) - (a.score ?? 1)) .map((node) => { // remove trailing slash for node url if exists diff --git a/templates/types/streaming/nextjs/app/components/ui/lib/utils.ts b/templates/types/streaming/nextjs/app/components/ui/lib/utils.ts index 59c84c0c411340b22e4488533e94bea9cc79a337..a5ef193506d07d0459fec4f187af08283094d7c8 100644 --- a/templates/types/streaming/nextjs/app/components/ui/lib/utils.ts +++ b/templates/types/streaming/nextjs/app/components/ui/lib/utils.ts @@ -4,13 +4,3 @@ import { twMerge } from "tailwind-merge"; export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } - -export function isValidUrl(url?: string): boolean { - if (!url) return false; - try { - new URL(url); - return true; - } catch (_) { - return false; - } -} \ No newline at end of file