Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added local llm functionality by incorporating text-generation-webui #289

Merged
merged 37 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
cf7a802
Added local llm functionality by incorporating text-generation-webui
sirajperson Jun 9, 2023
74b0696
Update docker-compose.yaml
sirajperson Jun 9, 2023
275f653
Update docker-compose.yaml
sirajperson Jun 9, 2023
ec94859
Update docker-compose.yaml
sirajperson Jun 9, 2023
dc6eaff
Adds support for searx search
alexkreidler Jun 9, 2023
488758f
Merge pull request #293 from alexkreidler/searx
Jun 10, 2023
669b037
Update json_cleaner.py
sirajperson Jun 10, 2023
35bb8ae
Update config_template.yaml
xutpuu Jun 10, 2023
b90b31b
Merge pull request #297 from xutpuu/patch-1
Jun 10, 2023
812e3cc
This commit makes local the OpenAI api the defualt LLM provider.
sirajperson Jun 10, 2023
e406d07
Merge remote-tracking branch 'origin/main'
sirajperson Jun 10, 2023
ed07ac3
Update docker-compose.yaml
sirajperson Jun 10, 2023
1b707d8
This commit makes local the OpenAI api the defualt LLM provider.
sirajperson Jun 10, 2023
a63a1d7
Add files via upload
sirajperson Jun 10, 2023
cf454b6
Add files via upload
sirajperson Jun 10, 2023
0668187
Resolved requirements.txt conflict
sirajperson Jun 10, 2023
fb9ac23
Resolved AgentCreate.js conflict
sirajperson Jun 10, 2023
37ef5b3
Update requirements.txt
sirajperson Jun 10, 2023
be01a9a
Update agent_executor.py
sirajperson Jun 10, 2023
2edf824
new file: tgwui/config/models/place-your-models-here.txt
sirajperson Jun 10, 2023
7aaeb97
docker-compose fix for podman (#302)
jpenalbae Jun 10, 2023
217a0b1
modified: config_template.yaml
sirajperson Jun 10, 2023
ffead61
Merge branch 'TransformerOptimus:main' into main
sirajperson Jun 10, 2023
15fcbba
partially fix typo, email attachment tool logic
pallasite99 Jun 11, 2023
8cb9e97
Merge pull request #310 from pallasite99/fix-typo-email-attachment-tool
Jun 11, 2023
9c8eab6
Added video
Akki-jain Jun 11, 2023
9a70a7d
Added video
Akki-jain Jun 11, 2023
c818926
Added Installation Video
Akki-jain Jun 11, 2023
8de9a18
Merge pull request #313 from TransformerOptimus/demo-video
Jun 11, 2023
1c134ab
Added new video
Akki-jain Jun 11, 2023
c29a7ae
Merge pull request #314 from TransformerOptimus/demo_video
Jun 11, 2023
50f6de7
Update agent_executor.py
iskandarreza Jun 11, 2023
ebec063
Merge pull request #315 from iskandarreza/typo-fix
Jun 11, 2023
567bba8
Update README.MD
FeelingAGIle Jun 11, 2023
e6cf271
Merge pull request #318 from TransformerOptimus/readme_removed_vid
eqxwow Jun 11, 2023
f133780
modified: docker-compose.yaml
sirajperson Jun 11, 2023
2c7ac53
Merge branch 'TransformerOptimus:main' into main
sirajperson Jun 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adds support for searx search
Searx is a free internet metasearch engine which aggregates
results from more than 70 search services. I added a simple
beautifulsoup scraper that allows many of the instances on
https://searx.space/ to be used without an API key. Uses the
bs4, httpx, and pydantic packages which are already in the
`requirements.txt`.
  • Loading branch information
alexkreidler committed Jun 9, 2023
commit dc6eaff5832c70ce07a89edde5a8a8350cc5b1af
16 changes: 16 additions & 0 deletions superagi/tools/searx/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<p align=center>
<a href="https://superagi.co"><img src=https://superagi.co/wp-content/uploads/2023/05/SuperAGI_icon.png></a>
</p>

# SuperAGI Searx Search Tool

The SuperAGI Searx Search Tool helps users perform a Searx search and extract snippets and webpages. We parse the HTML response pages because most Searx instances do not support the JSON response format without an API key.

## ⚙️ Installation

### 🛠 **Setting Up of SuperAGI**
Set up the SuperAGI by following the instructions given (https://github.com/TransformerOptimus/SuperAGI/blob/main/README.MD)

## Running SuperAGI Searx Search Serp Tool

You can simply ask your agent about latest information regarding anything in the world and your agent will be able to browse the internet to get that information for you.
Empty file.
73 changes: 73 additions & 0 deletions superagi/tools/searx/search_scraper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import random
from typing import List
import httpx
from bs4 import BeautifulSoup
from pydantic import BaseModel


searx_hosts = ["https://search.ononoki.org", "https://searx.be", "https://search.us.projectsegfau.lt"]

class SearchResult(BaseModel):
id: int
title: str
link: str
description: str
sources: List[str]

def __str__(self):
return f"""{self.id}. {self.title} - {self.link}
{self.description}"""

def search(query):
'''Gets the raw HTML of a searx search result page'''
# TODO: use a better strategy for choosing hosts. Could use this list: https://searx.space/data/instances.json
searx_url = random.choice(searx_hosts)
res = httpx.get(
searx_url + "/search", params={"q": query}, headers={"User-Agent": "Mozilla/5.0 (X11; Linux i686; rv:109.0) Gecko/20100101 Firefox/114.0"}
)
if res.status_code != 200:
print(res.status_code, searx_url)
raise Exception(f"Searx returned {res.status_code} status code")

return res.text

def clean_whitespace(s: str):
return " ".join(s.split())


def scrape_results(html):
'''Converts raw HTML into a list of SearchResult objects'''
soup = BeautifulSoup(html, "html.parser")
result_divs = soup.find_all(attrs={"class": "result"})

result_list = []
n = 1
for result_div in result_divs:
# Needed to work on multiple versions of Searx
header = result_div.find(["h4", "h3"])
link = header.find("a")["href"]
title = header.text.strip()

description = clean_whitespace(result_div.find("p").text)

# Needed to work on multiple versions of Searx
sources_container = result_div.find(
attrs={"class": "pull-right"}
) or result_div.find(attrs={"class": "engines"})
source_spans = sources_container.find_all("span")
sources = []
for s in source_spans:
sources.append(s.text.strip())

result = SearchResult(
id=n, title=title, link=link, description=description, sources=sources
)
result_list.append(result)
n += 1

return result_list


def search_results(query):
'''Returns a text summary of the search results via the SearchResult.__str__ method'''
return "\n\n".join(list(map(lambda x: str(x), scrape_results(search(query)))))
43 changes: 43 additions & 0 deletions superagi/tools/searx/searx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from typing import Type, Optional
from pydantic import BaseModel, Field
from superagi.llms.base_llm import BaseLlm
from superagi.tools.base_tool import BaseTool
from superagi.tools.searx.search_scraper import search_results


class SearxSearchSchema(BaseModel):
query: str = Field(
...,
description="The search query for the Searx search engine.",
)

class SearxSearchTool(BaseTool):
llm: Optional[BaseLlm] = None
name = "SearxSearch"
description = (
"A tool for performing a Searx search and extracting snippets and webpages."
"Input should be a search query."
)
args_schema: Type[SearxSearchSchema] = SearxSearchSchema

class Config:
arbitrary_types_allowed = True

def _execute(self, query: str) -> tuple:
snippets = search_results(query)
summary = self.summarise_result(query, snippets)

return summary

def summarise_result(self, query, snippets):
summarize_prompt = """Summarize the following text `{snippets}`
Write a concise or as descriptive as necessary and attempt to
answer the query: `{query}` as best as possible. Use markdown formatting for
longer responses."""

summarize_prompt = summarize_prompt.replace("{snippets}", str(snippets))
summarize_prompt = summarize_prompt.replace("{query}", query)

messages = [{"role": "system", "content": summarize_prompt}]
result = self.llm.chat_completion(messages, max_tokens=self.max_token_limit)
return result["content"]