Skip to content

Commit

Permalink
Make linters happy.
Browse files Browse the repository at this point in the history
  • Loading branch information
jtorreggiani committed Oct 26, 2024
1 parent 13b1927 commit e481ff3
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 18 deletions.
24 changes: 18 additions & 6 deletions src/goose_plugins/toolkits/critical_systems_thinking.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def message_content(self, content: Content) -> Text:
return content
else:
return Text(str(content))

@tool
def check_status(self) -> str:
"""
Expand Down Expand Up @@ -49,7 +49,7 @@ def search(self, query: str) -> str:
@tool
def analyze_request(self, statement: str) -> str:
"""
When a request is unclear, high-level or ambiguous use this tool to
When a request is unclear, high-level or ambiguous use this tool to
analyze the response and provide a well thought out response. You should
return a well thought out response to the statement or question.
Expand All @@ -69,10 +69,16 @@ def analyze_request(self, statement: str) -> str:
for msg in self.exchange_view.processor.messages
]

exchange = Exchange(provider=provider, model="claude-3-5-sonnet-20240620", messages=existing_messages_copy, system=None)
exchange = Exchange(
provider=provider,
model="claude-3-5-sonnet-20240620",
messages=existing_messages_copy, system=None
)

request_input = f"""
Analyze the user statement: {statement}
If you need to immediately clarify something and it's something short and simple, respond with your question(s).
If you need to immediately clarify something and it's something
short and simple, respond with your question(s).
If you need multiple questions, you can ask multiple questions.
Please bullet point your questions.
Limit your response to 5 questions.
Expand Down Expand Up @@ -115,7 +121,7 @@ def review_web_page(self, url: str) -> str:
@tool
def consider_solutions(self, statement: str) -> str:
"""
Provide a well thought out response to the statement summarize the
Provide a well thought out response to the statement summarize the
problem and provide a solution or a set of solutions.
Args:
Expand All @@ -134,7 +140,13 @@ def consider_solutions(self, statement: str) -> str:
for msg in self.exchange_view.processor.messages
]

exchange = Exchange(provider=provider, model="claude-3-5-sonnet-20240620", messages=existing_messages_copy, system=None)
exchange = Exchange(
provider=provider,
model="claude-3-5-sonnet-20240620",
messages=existing_messages_copy,
system=None
)

request_input = f"""
Analyze the user statement: {statement}
Consider the existing message history and provide a well thought out response.
Expand Down
12 changes: 6 additions & 6 deletions src/goose_plugins/utils/selenium_web_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
import time

def chrome_driver_path():
def chrome_driver_path() -> str:
return "/opt/homebrew/bin/chromedriver"
def get_web_page_content(url, wait_time=10):

def get_web_page_content(url: str, wait_time: int=10) -> str:
# Set up Chrome options
chrome_options = Options()
chrome_options.add_argument("--headless") # Run in headless mode (no GUI)
Expand All @@ -28,7 +28,7 @@ def get_web_page_content(url, wait_time=10):

# Wait for the page to load
WebDriverWait(driver, wait_time).until(
EC.presence_of_element_located((By.TAG_NAME, "body"))
expected_conditions.presence_of_element_located((By.TAG_NAME, "body"))
)

# Allow some time for JavaScript to execute
Expand All @@ -50,4 +50,4 @@ def get_web_page_content(url, wait_time=10):
url = "https://www.google.com"
content = get_web_page_content(url)
print(content)
print("...")
print("...")
4 changes: 2 additions & 2 deletions src/goose_plugins/utils/serper_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import json
import requests

def serper_search(query):
def serper_search(query: str) -> str:
payload = json.dumps({ 'q': query })
headers = {
'X-API-KEY': os.getenv('SERPER_API_KEY'),
Expand All @@ -13,4 +13,4 @@ def serper_search(query):
'https://google.serper.dev/search',
headers=headers, data=payload
)
return response.text
return response.text
8 changes: 4 additions & 4 deletions tests/toolkits/test_critical_systems_thinking.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import pytest
from goose_plugins.toolkits.critical_systems_thinking import CriticalSystemsThinking
from unittest.mock import patch, MagicMock, Mock
from unittest.mock import MagicMock, Mock


@pytest.fixture
def critical_systems_thinking():
def critical_systems_thinking() -> CriticalSystemsThinking:
notifier = MagicMock()
toolkit = CriticalSystemsThinking(notifier=notifier)
toolkit.exchange_view = Mock()
toolkit.exchange_view.processor = Mock()
toolkit.exchange_view.processor.messages = []
return toolkit

def test_check_status(critical_systems_thinking) -> None:
def test_check_status(critical_systems_thinking: CriticalSystemsThinking) -> None:
result = critical_systems_thinking.check_status()

assert "OK" == result

if __name__ == "__main__":
pytest.main()
pytest.main()

0 comments on commit e481ff3

Please sign in to comment.