Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compatibility with GPT-4-Turbo models + a new instruction #8

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion browserpilot/agents/compilers/instruction_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import logging
import traceback
import os
import re

from typing import Dict, List, Union

Expand Down Expand Up @@ -297,7 +298,6 @@ def get_completion(
frequency_penalty=0,
presence_penalty=0,
temperature=temperature,
stop=stop,
)
text = response.choices[0].message.content
else:
Expand Down Expand Up @@ -326,6 +326,9 @@ def get_completion(
except Exception:
traceback.print_exc()

# Extract python code
text = self._extract_python_code(text)

# Add to cache.
self.api_cache[prompt] = text

Expand Down Expand Up @@ -406,6 +409,15 @@ def save_compiled_instructions(self, filename):
elif filename.endswith(".yaml"):
yaml.dump(to_dump, f)

def _extract_python_code(self, input_string: str) -> str:
pattern = r'```python\n(.*?)```'
match = re.search(pattern, input_string, re.DOTALL)

if match:
return match.group(1)
else:
return input_string


if __name__ == "__main__":
import pprint
Expand Down
2 changes: 1 addition & 1 deletion examples.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import click

from browserpilot.agents.gpt_selenium_agent import GPTSeleniumAgent
# from browserpilot.agents.goal_agent import GoalAgent


# Set up multiple command CLI.
Expand All @@ -24,6 +23,7 @@ def selenium(instructions, chromedriver_path, model, memory_folder, debug, outpu
chromedriver_path,
instruction_output_file=output,
model_for_instructions=model,
model_for_responses=model,
memory_folder=memory_folder,
debug=debug,
retry=True,
Expand Down
18 changes: 18 additions & 0 deletions prompts/examples/github_issue.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
instructions:
- BEGIN_FUNCTION open_github_issue
- Go to Google.com
- Find all textareas.
- Find the first visible textarea.
- Click on the first visible textarea.
- Type in "netbox github" and press enter.
- Wait 2 seconds.
- Find all anchor elements that link to GitHub.com.
- Click on the first one.
- Wait 2 seconds.
- Click on the anchor element with id 'issues-tab'.
- Wait 2 seconds.
- Click on the closed issues to filter them.
- Wait 2 seconds.
- END_FUNCTION
- RUN_FUNCTION open_github_issue
- Wait for 10 seconds.