h2oai / h2ogpt

Private chat with local GPT with document, images, video, etc. 100% private, Apache 2.0. Supports oLLaMa, Mixtral, llama.cpp, and more. Demo: https://gpt.h2o.ai/ https://gpt-docs.h2o.ai/
http://h2o.ai
Apache License 2.0
11.28k stars 1.24k forks source link

Source Link opened in the same tab #1678

Open llmwesee opened 3 months ago

llmwesee commented 3 months ago

After got the answer and go to the source and hit the source link then it opened in the same tab instead of new tab. By looking the code, The link should open in the new tab always instead of same tab because we are targeting the blank. Then is it a Bug or something else?

def get_url(x, from_str=False, short_name=False, font_size=2):
    if not from_str:
        source = x.metadata['source']
    else:
        source = x
    if short_name:
        source_name = get_short_name(source)
    else:
        source_name = source
    if source.startswith('http://') or source.startswith('https://'):
        return """<font size="%s"><a href="%s" target="_blank"  rel="noopener noreferrer">%s</a></font>""" % (
            font_size, source, source_name)
    elif '<a href=' not in source:
        return """<font size="%s"><a href="file/%s" target="_blank"  rel="noopener noreferrer">%s</a></font>""" % (
            font_size, source, source_name)
    else:
        # already filled
        return source
pseudotensor commented 3 months ago

Sorry for delay.

I've never seen it open in same tab. For me a PDF link leads to downloading of the PDF.

For images, it opens in new tab always for me.

Just tried it again, seems all ok.

Can you give a specific document and question where there is an issue?

llmwesee commented 3 months ago

I'm attaching the both PDF and also the screenshot for the reference.

Screencast from 28-06-24 09:45:42 AM IST.webm

2210.14699v2.pdf

pseudotensor commented 2 months ago

I see. It must be because for me it downloads the PDF in Ubuntu, but for you it is instead opening the PDF up. And you are using some modified code to get the correct page number, which is great.

llmwesee commented 2 months ago

Yep, I want to open the PDF up. And for get the correct page number it doesn't work on cases where PDFs are the scanned copies.