ztjhz / BetterChatGPT

An amazing UI for OpenAI's ChatGPT (Website + Windows + MacOS + Linux)
http://bettergpt.chat/
Creative Commons Zero v1.0 Universal
8.19k stars 2.77k forks source link

Browsing Support for BetterChatGPT #304

Open MonsalvoGeoffrey opened 1 year ago

MonsalvoGeoffrey commented 1 year ago

We currently have issue #300 working on how to support ChatGPT plug-ins. I think having browing support, even if it may not be identical to the official one, might be in the meantime easier to implement while still providing a lot of value.

acheong08 commented 1 year ago

@ztjhz Perhaps allow text input for a custom model name. This should be implemented on back end and extra features can be determined based on model

acheong08 commented 1 year ago

@MonsalvoGeoffrey It might require 2 or 3 requests for browsing to work well per chat via the official API & browsing implementation from scratch (higher cost). Meanwhile, another option is you providing an OpenAI access token for a ChatGPT account with access to plugins as API key (not everybody has access)

acheong08 commented 1 year ago

Any thoughts on how a user can decide whether or not to use browsing for a particular message? My thoughts on options: Plugins toggle (per message), lightweight classifier model (to be trained), ask chatgpt if search is necessary.

Example implementation for the last option: https://github.com/acheong08/ChatGPT/blob/f952b16ab79a0daf07d7e9b2af52cf46f13e5e5a/src/revChatGPT/V3.py#L663-L697

print("ChatGPT: ", flush=True)
if args.enable_internet:
    query = chatbot.ask(
        f'This is a prompt from a user to a chatbot: "{prompt}". Respond with "none" if it is directed at the chatbot or cannot be answered by an internet search. Otherwise, respond with a possible search query to a search engine. Do not write any additional text. Make it as minimal as possible',
        convo_id="search",
        temperature=0.0,
    ).strip()
    print("Searching for: ", query, "")
    # Get search results
    search_results = '{"results": "No search results"}'
    if query != "none":
        resp = requests.post(
            url="https://ddg-api.herokuapp.com/search",
            json={"query": query, "limit": 3},
            timeout=10,
        )
        resp.encoding = "utf-8" if resp.encoding is None else resp.encoding
        search_results = resp.text
    print(json.dumps(json.loads(search_results), indent=4))
    chatbot.add_to_conversation(
        f"Search results:{search_results}",
        "system",
        convo_id="default",
    )
    if args.no_stream:
        print(chatbot.ask(prompt, "user", convo_id="default"))
    else:
        for query in chatbot.ask_stream(prompt):
            print(query, end="", flush=True)

(Ripped from my ChatGPT repo. Will translate/tweak/optimize for Go if this is desirable)

acheong08 commented 1 year ago

Alternatively, we can use Google Bard as the search engine (Already have that reversed so it's plug and play). Pass through search results from Bard to ChatGPT for better analysis or something like that. For simple browsing tasks, Bard alone might be sufficient. Might make a https://github.com/acheong08/ChatGPT-to-API but for Bard

mariodian commented 1 year ago

Meanwhile, another option is you providing an OpenAI access token for a ChatGPT account with access to plugins as API key (not everybody has access)

There's no plugin support for the API. Plugins are only available within ChatGPT's app.

Any thoughts on how a user can decide whether or not to use browsing for a particular message?

It can trigger browsing for keywords like "latest", "now", "update" etc. I wouldn't leave it up to GPT to decide when the internet search is needed because of the GPT hallucination issues (at least for 3.5)

mariodian commented 1 year ago

According to GPT these would be the best situations to trigger internet search.

Latest or up-to-date If the user asks for the latest or up-to-date news, facts, or figures on a topic, GPT4 should search the internet for the most recent information.

Frequently or often If the user asks for something that occurs frequently or often, GPT4 should go to the internet to find a database of the most recent and comprehensive information.

Historical events or facts If the user asks for historical events or facts about a topic, GPT4 might need to research books, articles, or websites on the internet.

Data, statistics, or numbers If the user asks for any data, statistics, or numbers related to a topic, GPT4 should go online and search for relevant databases and sources.

Complex or advanced concepts If the user asks about complex or advanced topics, GPT4 might have to browse academic articles or research papers online.

Multilingual words or phrases If the user asks for words or phrases in different languages, GPT4 should look for online translation tools or websites for the most accurate translations.

Product or service reviews If the user asks for reviews or ratings of a product or service, GPT4 should search for reviews on relevant websites or databases.

Current events or news If the user asks for news or updates on current events, GPT4 should browse news websites or social media platforms for the latest information.

Comparisons or differences If the user asks for a comparison or differences between multiple things, GPT4 should look for online articles or blogs that make such comparisons.

Expert opinions or advice If the user asks for an expert opinion or advice on a topic, GPT4 should search for professional platforms or websites that provide expert opinions or advice on related matters.

magedhelmy1 commented 1 year ago

Dear @mariodian what is the way forward with regards to this? Could we use something like Langchain Web Browser Tool for example?

mariodian commented 1 year ago

@magedhelmy1 we could, but that would only make sense if you wanted to search within numerous services such as Google, DuckDuckGo, YouTube, Wikipedia, etc. However, I'm not sure if that's what we want? Why not just use Bing/Bard directly in that case? Otherwise, @acheong08's solution is much cleaner imo.

After some testing, however, GPT 3.5 (I don't have access to 4 yet) cannot accurately determine whether it needs to search online or if the knowledge is already within its data. We need to determine the best way to initiate browsing and proceed with the search results. One option would be to ask GPT to summarize the results.

It's not as easy as it seems.

lindebuyer commented 1 year ago

Dear @mariodian what is the way forward with regards to this? Could we use something like [Langchain Web Browser Tool

](https://js.langchain.com/docs/modules/agents/tools/webbrowser) for example?

With new introduced function calling updated released by openAI. No langchain is needed (but also great to implement it)

What I meant no needed because function calling is a official smart way to instruct the model and long-chain inject prompt to launch tool usage.