Skip to content
Snippets Groups Projects
Unverified Commit 8f670a93 authored by Marcus Schiesser's avatar Marcus Schiesser Committed by GitHub
Browse files

fix: allow relative URL in docs (#259)

parent f04f60d5
No related branches found
No related tags found
No related merge requests found
---
"create-llama": patch
---
Allow relative URL in documents
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
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment