|
from google.genai import types |
|
from typing import List |
|
from googlesearch import search |
|
from CEO.CEO import GeminiManager |
|
from CEO.tool_loader import ToolLoader |
|
import warnings |
|
|
|
|
|
def web_search(website: str, query: str) -> List[str]: |
|
""" |
|
Searches the specified website for the given query. |
|
The search query is formed by combining the website domain and the query string. |
|
""" |
|
search_query = f"site:{website} {query}" |
|
results = [] |
|
for result in search(search_query, num_results=10): |
|
|
|
if "/search?num=" not in result: |
|
results.append(result) |
|
return results |
|
|
|
if __name__ == "__main__": |
|
warnings.filterwarnings("ignore") |
|
|
|
tools = [ |
|
{ |
|
'type': 'function', |
|
'function': { |
|
'name': 'web_search', |
|
'description': 'Search for results on a specified website using a query string. ' |
|
'The CEO model should define which website to search from and the query to use.', |
|
'parameters': { |
|
'type': 'object', |
|
'required': ['website', 'query'], |
|
'properties': { |
|
'website': {'type': 'string', 'description': 'The website domain to search from (e.g., huggingface.co)'}, |
|
'query': {'type': 'string', 'description': 'The search query to use on the specified website'}, |
|
}, |
|
}, |
|
}, |
|
} |
|
] |
|
|
|
|
|
tool_loader = ToolLoader() |
|
|
|
model_manager = GeminiManager(toolsLoader=tool_loader) |
|
|
|
|
|
|
|
|
|
task_prompt = ( |
|
"Create a strategy for Ashton Hall to improve its online presence." |
|
) |
|
|
|
|
|
user_prompt_content = types.Content( |
|
role='user', |
|
parts=[types.Part.from_text(text=task_prompt)], |
|
) |
|
response = model_manager.request([user_prompt_content]) |
|
print("\nCEO Response:", response) |
|
|