[Feature Request]: Implementation for WebChatGPT #1048
Replies: 82 comments 10 replies
-
It'll take some time. I'll try to implement this next week when my mock exams are over |
Beta Was this translation helpful? Give feedback.
-
@f1nniboy has something similar to this as well. I'll ask him to share source code. |
Beta Was this translation helpful? Give feedback.
-
Alright thank you for considering! |
Beta Was this translation helpful? Give feedback.
-
good idea! |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
pynecone has something similar to the request, with local users and questions/answers management. You can take it as a reference. |
Beta Was this translation helpful? Give feedback.
-
I just reverse engineered the plugin and switched to python below. you can put it in code with a simple function. |
Beta Was this translation helpful? Give feedback.
-
@noseon that is very impressing! |
Beta Was this translation helpful? Give feedback.
-
Haha, i also reverse-engineered it for my project. Should've looked into issues earlier, could've been first :) |
Beta Was this translation helpful? Give feedback.
-
@NymdaFromSalad is it on a GitHub repo? |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
pass your code to python and use it as a secondary api to your ChatGPT. |
Beta Was this translation helpful? Give feedback.
-
Sounds great! |
Beta Was this translation helpful? Give feedback.
-
@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 |
Beta Was this translation helpful? Give feedback.
-
K, thanks |
Beta Was this translation helpful? Give feedback.
-
@NymdaFromSalad I've spent some time testing and this prompt works 99% of the time: Instructions: You are a chatbot that has access to the web. Use the given web results above to write an easy-to-read and straightforward response. Make sure to cite results using [[number(URL)]. Make sure each website has its own section. All I want you to do is summarize the given web results. Don't say "sure" or anything like that. Just get to the point. Don't forget to cite the results with [[number(URL)] Query: Teletubbies Make sure that you replace the query with whatever the user asks, and add the current date and time to the end of the chat. Also for this to work make sure to give ChatGPT the URL of the website for each section. |
Beta Was this translation helpful? Give feedback.
-
Ok, thank you very much, will use! |
Beta Was this translation helpful? Give feedback.
-
@NymdaFromSalad @acheong08 Should I be concerned?: |
Beta Was this translation helpful? Give feedback.
-
That's what we call in the industry "good enough" |
Beta Was this translation helpful? Give feedback.
-
@NymdaFromSalad any progress? |
Beta Was this translation helpful? Give feedback.
-
On v3? Haven't looked yet, i have some personal matters to attend to. Will look, when done, hopefully won't take me too long |
Beta Was this translation helpful? Give feedback.
-
Hey everyone. Glad you liked the idea of WebChatGPT extension. @noseon I'd very much appreciate if you didn't put additional load on my backend server. I plan to sunset it anyway, so relying on it is not the best option. I've made the backend repo public: https://github.com/qunash/ddg-webapp. It's just a thin wrapper around the duckduckgo-search Python package. You can use it directly instead. |
Beta Was this translation helpful? Give feedback.
-
Hi, yea, i figured that out myself. Not sure, why you haven't made it public earlier. Will also make V3 use ddg instead soon (For context, i made WebGPT submodule, acheong - the V3 implementation) |
Beta Was this translation helpful? Give feedback.
-
Traceback (most recent call last):
File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/acheong/.local/lib/python3.10/site-packages/revChatGPT/WebGPT.py", line 347, in <module>
main(V1.configure())
File "/home/acheong/.local/lib/python3.10/site-packages/revChatGPT/V1.py", line 55, in wrapper
out = func(*args, **kwargs)
File "/home/acheong/.local/lib/python3.10/site-packages/revChatGPT/WebGPT.py", line 325, in main
for data in chatbot.webAsk(prompt):
File "/home/acheong/.local/lib/python3.10/site-packages/revChatGPT/WebGPT.py", line 90, in webAsk
webPrompt, headers = webify(
File "/home/acheong/.local/lib/python3.10/site-packages/revChatGPT/WebGPT.py", line 48, in webify
searchResults = ddg(query, numResults, timePeriod, region)
File "/home/acheong/.local/lib/python3.10/site-packages/duckduckgo_search/ddg.py", line 80, in ddg
"p": safesearch_base[safesearch.capitalize()],
KeyError: '' |
Beta Was this translation helpful? Give feedback.
-
V3 already has web searching implemented |
Beta Was this translation helpful? Give feedback.
-
I made the V3 implementation, not noseon |
Beta Was this translation helpful? Give feedback.
-
@qunash I already stated previously that I would not use third party APIs. I made my own in Go and am using my own server. Don't worry about us abusing your service |
Beta Was this translation helpful? Give feedback.
-
It already uses DDG |
Beta Was this translation helpful? Give feedback.
-
Still doesn't work, as shown below: User:
search Google Scholar with the keywords: vasp first principles.
ChatGPT:
Searching for: site:scholar.google.com "vasp first principles"
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/V3.py", line 482, in <module>
main()
File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/V3.py", line 461, in main
print(json.dumps(json.loads(search_results), indent=4))
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/werner/.pyenv/versions/3.11.1/lib/python3.11/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/werner/.pyenv/versions/3.11.1/lib/python3.11/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/werner/.pyenv/versions/3.11.1/lib/python3.11/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) |
Beta Was this translation helpful? Give feedback.
-
Is there an existing issue for this?
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:
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
Beta Was this translation helpful? Give feedback.
All reactions