Skip to content

Commit

Permalink
assistant is not saving any money
Browse files Browse the repository at this point in the history
  • Loading branch information
terryyin committed Nov 29, 2024
1 parent 1029df2 commit 28320e1
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 20 deletions.
26 changes: 26 additions & 0 deletions whatDoesThisButtonDo/AiAssistant/ai_assistant_thread.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from .openai_client import OpenAIClient
from .get_next_action_command import GetNextActionCommand

class AIAssistantThread:
def __init__(self, test_oracles, api_key: str, model: str):
self.openai_client = OpenAIClient(
test_oracles=test_oracles,
api_key=api_key,
model=model
)

def get_next_action(self, possible_actions, sut_state):
"""
Get the AI's choice for the next action to take
Args:
possible_actions: List of possible actions with their descriptions
sut_state: Current state of the system under test
Returns:
dict: Contains 'action' name and 'parameters' for the chosen action,
or None to indicate testing should stop
"""
command = GetNextActionCommand(self.openai_client, possible_actions)
response = command.execute()
return response
30 changes: 12 additions & 18 deletions whatDoesThisButtonDo/AiAssistant/ai_exploratory_test_assistant.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
from .openai_client import OpenAIClient
from .get_next_action_command import GetNextActionCommand

class AIExploratoryTestAssistant:
def __init__(self, test_oracles, api_key: str, model: str):
self.openai_client = OpenAIClient(
test_oracles=test_oracles,
api_key=api_key,
model=model
)
self.test_oracles = test_oracles
self.api_key = api_key
self.model = model

def get_next_action(self, possible_actions, sut_state):
def create_thread(self):
"""
Get the AI's choice for the next action to take
Creates a new AI assistant thread for handling test interactions
Args:
possible_actions: List of possible actions with their descriptions
sut_state: Current state of the system under test
Returns:
dict: Contains 'action' name and 'parameters' for the chosen action,
or None to indicate testing should stop
AIAssistantThread: A new thread instance for test execution
"""
command = GetNextActionCommand(self.openai_client, possible_actions)
response = command.execute()
return response
from .ai_assistant_thread import AIAssistantThread
return AIAssistantThread(
test_oracles=self.test_oracles,
api_key=self.api_key,
model=self.model
)
7 changes: 5 additions & 2 deletions whatDoesThisButtonDo/exploratory_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ def execute(self) -> None:
Executes the exploratory testing process
"""
try:
# Create an AI assistant thread for this test execution
ai_thread = self.ai_assistant.create_thread()

possible_next_actions = self.testable_sandbox.start()
current_state = {"status": "started"}

while possible_next_actions:
# Get AI's chosen action and parameters
action_choice = self.ai_assistant.get_next_action(
# Get AI's chosen action and parameters using the thread
action_choice = ai_thread.get_next_action(
possible_next_actions,
current_state
)
Expand Down

0 comments on commit 28320e1

Please sign in to comment.