Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Address HTML viewer bug when doing sycamore_crawler_http_sort_all #24

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions openai-proxy/py_proxy/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ def proxy():
download_name = download_name
)

@app.route('/viewHtml/<path:arg>', methods=['GET', 'OPTIONS'])
def proxy_html(arg):
if request.method == 'OPTIONS':
return optionsResp('GET')
path = "/" + arg
if "/../" in path: # Prevent filesystem snooping
return "invalid path"
return send_file(path, mimetype='text/html')

def make_openai_call(messages, model_id="gpt-4"):
response = openai.ChatCompletion.create(
model=model_id,
Expand Down
2 changes: 1 addition & 1 deletion ui/src/ConversationList.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Dispatch, SetStateAction, useState, useEffect, useRef } from 'react';
import { ActionIcon, createStyles, Loader, Navbar, Text, useMantineTheme, rem, Center, Container, Group, Anchor, TextInput } from '@mantine/core';
import { Settings } from './Types'
import { createConversation, deleteConversation, getConversations, is2dot12plus } from './OpenSearch';
import { createConversation, deleteConversation, getConversations } from './OpenSearch';
import { IconChevronRight, IconMessagePlus, IconTrash } from '@tabler/icons-react';
import { useHover } from '@mantine/hooks';
const useStyles = createStyles((theme) => ({
Expand Down
4 changes: 4 additions & 0 deletions ui/src/Doclist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const DocumentItem = ({ document }: { document: SearchResultDocument }) => {
console.log("You clicked: ", document)
localStorage.setItem('pdfDocumentMetadata', dataString);
window.open('/viewPdf');
} else if (document.hasAbsoluteUrl()) {
window.open(document.url);
} else if (document.url.startsWith("/")) {
window.open("/viewHtml" + document.url);
} else {
window.open(document.url);
}
Expand Down
4 changes: 4 additions & 0 deletions ui/src/Types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export class SearchResultDocument {
}
return false;
}

hasAbsoluteUrl() {
return this.url.search(/^[a-z]+:\/\//i) >= 0;
}
}
export class UserChat {
id: string = "";
Expand Down