Closed RaumwerkVogler closed 1 month ago
Hi. Thanks for reaching out about this.
This seems like an issue regarding the version of beautifulsoup4. Could you please let me know what version of beautifulsoup4 and Python you are using? Thanks!
Hey, thanks for your fast reaction.
bf4 seams to be 4.4.0 python is the 3.11.4
sorry for my unnecessary question. It was simply because I didn't pay attention to the reqirements.txt and didn't adjust the system. After I installed the requirements.txt everything works fine.
Great job. It will make my life much more easy. Thanks for this repo :-)
Each time I try to get a answer out of the www I get the following traceback;
Traceback (most recent call last): File "c:\Users\info\OneDrive\Desktop\projektmanagement\ollama web.py", line 85, in
main()
File "c:\Users\info\OneDrive\Desktop\projektmanagement\ollama web.py", line 76, in main
resp = online_agent.search(user_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\info\AppData\Local\Programs\Python\Python311\Lib\site-packages\llm_axe\agents.py", line 535, in search
search_results = self.search_function(query)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\info\AppData\Local\Programs\Python\Python311\Lib\site-packages\llm_axe\core.py", line 157, in internet_search
urls = list(search(query, tld="co.in", num=5, stop=10, pause=2))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\info\AppData\Local\Programs\Python\Python311\Lib\site-packages\googlesearch__init.py", line 309, in search
soup = BeautifulSoup(html, 'html.parser')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\info\AppData\Local\Programs\Python\Python311\Lib\site-packages\bs4__init.py", line 215, in init__
self._feed()
File "C:\Users\info\AppData\Local\Programs\Python\Python311\Lib\site-packages\bs4__init__.py", line 239, in _feed
self.builder.feed(self.markup)
File "C:\Users\info\AppData\Local\Programs\Python\Python311\Lib\site-packages\bs4\builder_htmlparser.py", line 164, in feed
parser.feed(markup)
File "C:\Users\info\AppData\Local\Programs\Python\Python311\Lib\html\parser.py", line 110, in feed
self.goahead(0)
File "C:\Users\info\AppData\Local\Programs\Python\Python311\Lib\html\parser.py", line 178, in goahead
k = self.parse_html_declaration(i)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\info\AppData\Local\Programs\Python\Python311\Lib\html\parser.py", line 269, in parse_html_declaration
self.handle_decl(rawdata[i+2:gtpos])
File "C:\Users\info\AppData\Local\Programs\Python\Python311\Lib\site-packages\bs4\builder_htmlparser.py", line 109, in handle_decl
self.soup.endData(Doctype)
File "C:\Users\info\AppData\Local\Programs\Python\Python311\Lib\site-packages\bs4\init.py", line 315, in endData
self.object_was_parsed(o)
File "C:\Users\info\AppData\Local\Programs\Python\Python311\Lib\site-packages\bs4\init.py", line 320, in object_was_parsed
previous_element = most_recent_element or self._most_recent_element
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\info\AppData\Local\Programs\Python\Python311\Lib\site-packages\bs4\element.py", line 997, in getattr
return self.find(tag)
^^^^^^^^^^^^^^
File "C:\Users\info\AppData\Local\Programs\Python\Python311\Lib\site-packages\bs4\element.py", line 1234, in find
l = self.find_all(name, attrs, recursive, text, 1, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\info\AppData\Local\Programs\Python\Python311\Lib\site-packages\bs4\element.py", line 1255, in find_all
return self._find_all(name, attrs, text, limit, generator, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\info\AppData\Local\Programs\Python\Python311\Lib\site-packages\bs4\element.py", line 512, in _find_all
strainer = SoupStrainer(name, attrs, text, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\info\AppData\Local\Programs\Python\Python311\Lib\site-packages\bs4\element.py", line 1548, in init__
self.text = self._normalize_search_value(text)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\info\AppData\Local\Programs\Python\Python311\Lib\site-packages\bs4\element.py", line 1553, in _normalize_search_value
if (isinstance(value, str) or isinstance(value, collections.Callable) or hasattr(value, 'match')
^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'collections' has no attribute 'Callable'
Used your democode after getting errors with the code from your video on youtube:
Example Conversation Output:
User: Who are you?
AI: I am a helpful chat assistant.
User: Great. Can you find me a website that I can use to practice web scraping?
AI: Based on information from the internet, one such website is https://www.scrapethissite.com/pages/.
This website provides various examples of pages for practicing web scraping, including country lists, hockey team stats, Oscar-winning films, and more. These examples cover different types of interfaces, such as forms, searching, pagination, AJAX, JavaScript, frames, and iFrames, making it a great resource to practice your web scraping skills.
User: Thanks!
AI: You're welcome!
This is an example chat session through the terminal
The AI will use the internet if it is required, otherwise, it will use its own knowledge base
from llm_axe import make_prompt, AgentType, OllamaChat, OnlineAgent, FunctionCaller, Agent
def internet(): """Choose if the internet is required or if we don't have information about the topic""" return ""
def no_internet(): """Choose if the internet is not required""" return ""
prompt = ''' You are an AI assistant. Determine whether or not the internet is required to answer the user's prompt. If the internet is not required, answer "no internet required". If the internet is required, answer "internet required".
'''
def main(): print('''
if name == 'main': main()