File size: 2,374 Bytes
2ea8556
8157183
 
2ea8556
8157183
637daef
8157183
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
637daef
8157183
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2ea8556
8157183
 
 
 
 
637daef
8157183
 
 
2ea8556
 
 
 
 
8157183
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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

# Define the web search tool function.
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):
        # Filter out irrelevant search pages
        if "/search?num=" not in result:
            results.append(result)
    return results

if __name__ == "__main__":
    warnings.filterwarnings("ignore")
    # Define the tool metadata for orchestration.
    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'},
                    },
                },
            },
        }
    ]

    # Load the tools using the ToolLoader class.
    tool_loader = ToolLoader()

    model_manager = GeminiManager(toolsLoader=tool_loader)
    
    # Example prompt instructing the CEO model to create a strategy for Ashton Hall.
    # The prompt explicitly mentions that it can use the web_search tool if needed,
    # and that it is allowed to choose the website for the search.
    task_prompt = (
        "Create a strategy for Ashton Hall to improve its online presence."
    )
    
    # Request a CEO response with the prompt.
    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)