Skip to main content

Python package for semantic relevant web search results.

Project description

AgentWebSearch Package

CI CD

Description

...

Quickstart

Create a AgentWebSearch Object

from agentwebsearch import AgentWebSearch
from agentwebsearch.websearch.request import WebSearchRequest
from agentwebsearch.search.client import DefaultSearchClient
from agentwebsearch.webscraper import DefaultWebScraper
from agentwebsearch.indexsearch import HNSWInMemoryIndexDB
from agentwebsearch.llm import OpenAIChatModel
from agentwebsearch.embedding import OpenAIEmbeddingModel


embedding_model = OpenAIEmbeddingModel(
    model="text-embedding-3-large",
    api_key="YOUR_OPENAI_API_KEY"
)

llm = OpenAIChatModel(
    model="gpt-4o",
    api_key="YOUR_OPENAI_API_KEY",
    temperature=0.7
)

index_db = HNSWInMemoryIndexDB(embedding_model=embedding_model)
search_client = DefaultSearchClient()
scraper = DefaultWebScraper()

websearch = AgentWebSearch(
    search_client=search_client,
    index_db=index_db,
    scraper=scraper,
    llm=llm,
    embedding_model=embedding_model
)

Execute AgentWebSearch

from agentwebsearch.websearch.request import RequestQuery, RequestQueryMessage

req = WebSearchRequest(
    query=RequestQuery(
        messages=[
            RequestQueryMessage(
                role="user",
                content="Wann wurde der Bundeskanzler 2025 gewählt?"
            )
        ]
    )
)

result = websearch.execute(req)
# or
for result in websearch.execute(req, stream=True):
    print(result)
    yield result

Deploy as MCP-Server

# server.py
from agentwebsearch.mcp import WebSearchFastMCP

mcp = WebSearchFastMCP("Demo 🚀")


@mcp.tool
def other_tool():
    return "Other tool"


if __name__ == "__main__":
    # available tools:
    #   - websearch
    #   - other_tool

    mcp.run(
        transport="streamable-http",
        host="127.0.0.1",
        port=8000,
        path="/mcp"
    )

# python run server.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agentwebsearch_py-0.1.1.tar.gz (104.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentwebsearch_py-0.1.1-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file agentwebsearch_py-0.1.1.tar.gz.

File metadata

  • Download URL: agentwebsearch_py-0.1.1.tar.gz
  • Upload date:
  • Size: 104.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for agentwebsearch_py-0.1.1.tar.gz
Algorithm Hash digest
SHA256 79852640a681ebc1120e507bb0b050461e6b86b6b690d68c664f76978ac01e47
MD5 62ffd55c7ee8fbebc27d2718ad88a547
BLAKE2b-256 e830ff7b17cd0fa6e3a733726bfe978eb7155db7101071e891747399267aafef

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentwebsearch_py-0.1.1.tar.gz:

Publisher: release.yml on enricogoerlitz/agentwebsearch-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agentwebsearch_py-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for agentwebsearch_py-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c4ab1495fc86e37047eb79e182c5bc93b5c35f7b3f0cdcb1462a73c6887745ba
MD5 bfa57e64e49d969f0fbd92289bc5b3f4
BLAKE2b-256 6d15d804a913eb94c0ce3e23c58681eb2b143c885e621b69d393f54c63fe389c

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentwebsearch_py-0.1.1-py3-none-any.whl:

Publisher: release.yml on enricogoerlitz/agentwebsearch-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page