ChatGPT
ChatGPT copied to clipboard
[Feature Request]: Implementation for WebChatGPT
Is there an existing issue for this?
- [x] I have searched the existing issues and checked the recent builds/commits
What would your feature do ?
I have just come across the GitHub page: https://github.com/qunash/chatgpt-advanced ChatGPT-Advanced or WebChatGPT. The title is self-explanatory and gives ChatGPT access to the web similar to what BingGPT does through a Chrome Extension. I would like to know if you can implement something like it. This is what it does:
- Searches google and looks for relevant info.
- Changes the user's prompt to something like this: With the prompt being What is the ChatGPT Github page by acheong all about?
You can ask directly to @qunash if you can implement or share code. Or you can copy the idea and make a similar feature to the API.
Proposed workflow
When you initialize the ChatBot in python you would simply add a "web" parameter. Which could be equal to True or False.
Additional information
No response
It'll take some time. I'll try to implement this next week when my mock exams are over
@f1nniboy has something similar to this as well. I'll ask him to share source code.
Alright thank you for considering!
good idea!
Thanks! I didn't really come up with the idea for WebChatGPT at first. I just thought it would be cool to see it here.
pynecone has something similar to the request, with local users and questions/answers management. You can take it as a reference. https://github.com/pynecone-io/pynecone-examples/tree/main/gpt
I just reverse engineered the plugin and switched to python below. you can put it in code with a simple function. https://github.com/noseon/WebChatGPT-/blob/main/WebChatGPT%20.py
@noseon that is very impressing!
Haha, i also reverse-engineered it for my project. Should've looked into issues earlier, could've been first :)
@NymdaFromSalad is it on a GitHub repo?
I just reverse engineered the plugin and switched to python below. you can put it in code with a simple function. noseon/WebChatGPT-@
main
/WebChatGPT%20.py
I would rather not use a third party API. I wrote my own DuckDuckGo scraper API today in Go: https://github.com/acheong08/DuckDuckGo-API
As a side note, this will probably be a separate repository rather than part of this one.
I feel that an API would be most suitable for this rather than a Python library
pass your code to python and use it as a secondary api to your ChatGPT.
Sounds great!
@LuckyHead11 No. It's here :) :
import requests, time
def apiSearch(query: str, numResults: int, timePeriod: str='', region: str=''):
searchParams = ''
searchParams += f'q={query}'
searchParams += f'&max_results={numResults}'
if timePeriod:
searchParams += f'&time={timePeriod}'
if region:
searchParams += f'®ion={region}'
url = f'https://ddg-webapp-aagd.vercel.app/search?{searchParams}'
response = requests.get(url)
results = response.json()
return results
def prepare_results(results):
i=1
res = ""
for result in results:
res+=f'[{i}] "{result["body"]}"\nURL: {result["href"]}\n\n'
i+=1
return res
def headers(results):
res = []
for result in results:
#res.append({'text':f'[{i}] {result["title"]}', 'link':result["href"]})
res.append(result["href"])
return res
def compile_prompt(prompt, results, reply_in = 'language of the query'):
return f'''Web search results:
{prepare_results(results)}
Current date: {time.strftime("%d.%m.%Y")}
Instructions: Using the provided web search results, write a comprehensive reply to the given query. Make sure to cite results using [number] notation after the reference. If the provided search results refer to multiple subjects with the same name, write separate answers for each subject.
Query: {prompt}
Reply in {reply_in}'''
def Webify(text:str, query: str, numResults: int, timePeriod: str='', region: str='', reply_in: str='undefined'):
searchResults = apiSearch(query, numResults, timePeriod, region)
return compile_prompt(text, searchResults, reply_in), headers(searchResults)
if __name__ == '__main__':
print(Webify('Testing', 3))
text and query are separate, 'cause i also wanted to do other filters, which can add instructions
Also if you wandering, why the function is called headers, that's because in my native language, headlines, titles and headers means the same
Awesome! @NymdaFromSalad @acheong08 with the code provided by Nymda implementing the Web/ChatGPT mix should be easy. Unless you would like to create your own way of using the web with ChatGPT ;) As you said though, you wouldn't use a 3rd party API.
@LuckyHead11Não. Está aqui :) :
import requests, time def apiSearch(query: str, numResults: int, timePeriod: str='', region: str=''): searchParams = '' searchParams += f'q={query}' searchParams += f'&max_results={numResults}' if timePeriod: searchParams += f'&time={timePeriod}' if region: searchParams += f'®ion={region}' url = f'https://ddg-webapp-aagd.vercel.app/search?{searchParams}' response = requests.get(url) results = response.json() return results def prepare_results(results): i=1 res = "" for result in results: res+=f'[{i}] "{result["body"]}"\nURL: {result["href"]}\n\n' i+=1 return res def headers(results): res = [] for result in results: #res.append({'text':f'[{i}] {result["title"]}', 'link':result["href"]}) res.append(result["href"]) return res def compile_prompt(prompt, results, reply_in = 'language of the query'): return f'''Web search results: {prepare_results(results)} Current date: {time.strftime("%d.%m.%Y")} Instructions: Using the provided web search results, write a comprehensive reply to the given query. Make sure to cite results using [number] notation after the reference. If the provided search results refer to multiple subjects with the same name, write separate answers for each subject. Query: {prompt} Reply in {reply_in}''' def Webify(text:str, query: str, numResults: int, timePeriod: str='', region: str='', reply_in: str='undefined'): searchResults = apiSearch(query, numResults, timePeriod, region) return compile_prompt(text, searchResults, reply_in), headers(searchResults) if __name__ == '__main__': print(Webify('Testing', 3))
texto e consulta são separados, porque eu também queria fazer outros filtros, que podem adicionar instruções
Além disso, se você está vagando, por que a função é chamada de cabeçalhos, é porque no meu idioma nativo, manchetes, títulos e cabeçalhos significam o mesmo
and that's how it works
Also need a mechanism for it to detect whether to search or not and convert natural language to a search query
Also need a mechanism for it to detect whether to search or not and convert natural language to a search query
Well, that's natural language processing and it is hard. Simplest solution would be to require user press the button and either using the whole query as the search parameter, or asking user for a search term. Honestly, forgot to check if WebGPT has any other mechanism. If it does - well, i need to reverse engineer it either way.
Also can use keywords, like putting /search at the start, makes it use WebGPT
Also you can ask ChatGPT to do NLP, as it is NLM :)
and that's how it works
Also must mention:
- Search app gets content and cuts it to a certain size. (Maybe article preview feature can be used to extract data?)
- In the OG ChatGPT (website chat), WebGPT makes it use markdown and put references as (url)[number].
- For some reason WebGPT, when you select default profile, asks to 'Reply in Undefined'
- Headers function is used to put links into the final message, as API returns plaintext (and refs turn into just [number]) you can modify it, depending on how you want to put references in
Also need a mechanism for it to detect whether to search or not and convert natural language to a search query
we could use a different package, like for V1: revChatGPT.V1 But for the web access one would be revChatGPT.V1_WEB
or when you do chatbot.ask
it would have a web parameter as I said in the beginning.
Also need a mechanism for it to detect whether to search or not and convert natural language to a search query
we could use a different package, like for V1: revChatGPT.V1 But for the web access one would be revChatGPT.V1_WEB or when you do
chatbot.ask
it would have a web parameter as I said in the beginning.
Oh, in that sense? Then:
- Needs better name, .webaccess .web or .webgpt are my picks
- You can create a web-accessing bot class, and either pass it chatbot object, or create internal chatbot instances, then it'll have additional functions to process web stuff and retain the OG ones
I dunno, i have some time on the weekend (and need to take a break from my personal project's SQL hijinx), if you guys want, i can make it (and do something i never done before - write decent code)
(Also, will try and use duckduckgo, as putting feature, that uses other people's (who do opensource, might i add) private servers without their consent into a library is not very nice. We only do it to evil corporations)
Also need a mechanism for it to detect whether to search or not and convert natural language to a search query
we could use a different package, like for V1: revChatGPT.V1 But for the web access one would be revChatGPT.V1_WEB or when you do
chatbot.ask
it would have a web parameter as I said in the beginning.Oh, in that sense? Then:
- Needs better name, .webaccess .web or .webgpt are my picks
- You can create a web-accessing bot class, and either pass it chatbot object, or create internal chatbot instances, then it'll have additional functions to process web stuff and retain the OG ones
I dunno, i have some time on the weekend (and need to take a break from my personal project's SQL hijinx), if you guys want, i can make it (and do something i never done before - write decent code)
(Also, will try and use duckduckgo, as putting feature, that uses other people's (who do opensource, might i add) private servers without their consent into a library is not very nice. We only do it to evil corporations)
Good Ideas! It's up to @acheong08 if you should make it. EDIT: Acheong did mention making another repository in that case WebGPT would be a good name for that.
Well, if you guys wanna use it, either way, it'll be time well spent
EDIT: Acheong did mention making another repository in that case WebGPT would be a good name for that.
WebGPT is my slang for WebChatGPT, and it is also a name of another OpenAI product https://openai.com/research/webgpt Also, he was talking about an API to implement this feature, which is not my idea (as i see no benefit to putting it on a server. It is not a passive scraper, it only scrapes one query, on demand. The delay would be mostly due to page loading time anyway, and very minor too. Why not just do the scraping locally?)
(Also, will try and use duckduckgo, as putting feature, that uses other people's (who do opensource, might i add) private servers without their consent into a library is not very nice. We only do it to evil corporations)
There is no need for that. I already wrote my own API for it and currently hosting on Heroku for testing https://github.com/acheong08/DuckDuckGo-API
I dunno, i have some time on the weekend
Let me know if you do. There's no point in duplicating efforts.
(Also, will try and use duckduckgo, as putting feature, that uses other people's (who do opensource, might i add) private servers without their consent into a library is not very nice. We only do it to evil corporations)
There is no need for that. I already wrote my own API for it and currently hosting on Heroku for testing https://github.com/acheong08/DuckDuckGo-API
Well, using your api is one of two options i consider. As i said, there is no need to put the code on a server, if it can perfectly run locally imo. But also, there is no point to inventing bicycle again, so it is a question of 'is it worth it to translate a scraper, if it will use less servers'
Also i was referring to WebChatGPT's server in that fragment
But hey, if you're against me scraping locally in this situation, then ok, will use your api
I prefer scraping locally
I just wrote the API because I couldn't figure out how to scrape reliably locally in Python.