Skip to content

Commit

Permalink
Merge pull request #132 from tyfiero/Tests-update
Browse files Browse the repository at this point in the history
Update local mode system message. And modify tests
  • Loading branch information
tyfiero authored Mar 23, 2024
2 parents f9cc6bb + 84224fd commit a325efb
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 28 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Run Test

on:
workflow_dispatch:
pull_request:
branches: [main]
# push: # Trigger the workflow on push events
Expand All @@ -16,7 +17,8 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
os: [macos-latest]
# os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.11"]

defaults:
Expand Down Expand Up @@ -58,4 +60,6 @@ jobs:
# Run pytest
- name: Run Pytest
run: poetry run pytest tests
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: poetry run pytest
4 changes: 2 additions & 2 deletions software/source/server/i.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
```python
result_string = computer.browser.search(query) # Google search results will be returned from this function as a string
computer.calendar.create_event(title="Meeting", start_date=datetime.datetime.now(), end=datetime.datetime.now() + datetime.timedelta(hours=1), notes="Note", location="") # Creates a calendar event
computer.calendar.create_event(title="Meeting", start_date=datetime.datetime.now(), end_date=datetime.datetime.now() + datetime.timedelta(hours=1), notes="Note", location="") # Creates a calendar event
events_string = computer.calendar.get_events(start_date=datetime.date.today(), end_date=None) # Get events between dates. If end_date is None, only gets events for start_date
computer.calendar.delete_event(event_title="Meeting", start_date=datetime.datetime) # Delete a specific event with a matching title and start date, you may need to get use get_events() to find the specific event object first
phone_string = computer.contacts.get_phone_number("John Doe")
Expand Down Expand Up @@ -182,7 +182,7 @@ def get_function_info(file_path):


def configure_interpreter(interpreter: OpenInterpreter):

### SYSTEM MESSAGE
interpreter.system_message = system_message

Expand Down
48 changes: 24 additions & 24 deletions software/source/server/tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ def test_ping(client):
assert response.text == "pong"


def test_interpreter_chat(mock_interpreter):
# Set up a sample conversation
messages = [
{"role": "user", "type": "message", "content": "Hello."},
{"role": "assistant", "type": "message", "content": "Hi there!"},
# Add more messages as needed
]

# Configure the mock interpreter with the sample conversation
mock_interpreter.messages = messages

# Simulate additional user input
user_input = {"role": "user", "type": "message", "content": "How are you?"}
mock_interpreter.chat([user_input])

# Ensure the interpreter processed the user input
assert len(mock_interpreter.messages) == len(messages)
assert mock_interpreter.messages[-1]["role"] == "assistant"
assert "don't have feelings" in mock_interpreter.messages[-1]["content"]

def test_interpreter_configuration(mock_interpreter):
# Test interpreter configuration
interpreter = configure_interpreter(mock_interpreter)
assert interpreter is not None
# def test_interpreter_chat(mock_interpreter):
# # Set up a sample conversation
# messages = [
# {"role": "user", "type": "message", "content": "Hello."},
# {"role": "assistant", "type": "message", "content": "Hi there!"},
# # Add more messages as needed
# ]

# # Configure the mock interpreter with the sample conversation
# mock_interpreter.messages = messages

# # Simulate additional user input
# user_input = {"role": "user", "type": "message", "content": "How are you?"}
# mock_interpreter.chat([user_input])

# # Ensure the interpreter processed the user input
# assert len(mock_interpreter.messages) == len(messages)
# assert mock_interpreter.messages[-1]["role"] == "assistant"
# assert "don't have feelings" in mock_interpreter.messages[-1]["content"]

# def test_interpreter_configuration(mock_interpreter):
# # Test interpreter configuration
# interpreter = configure_interpreter(mock_interpreter)
# assert interpreter is not None
20 changes: 20 additions & 0 deletions software/source/server/utils/local_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,24 @@ def select_local_model():
# Set offline for all local models
interpreter.offline = True

interpreter.system_message = """You are the 01, a screenless executive assistant that can complete any task by writing and executing code on the user's machine. Just write a markdown code block! The user has given you full and complete permission.
Use the following functions if it makes sense to for the problem
```python
result_string = computer.browser.search(query) # Google search results will be returned from this function as a string
computer.calendar.create_event(title="Meeting", start_date=datetime.datetime.now(), end_date=datetime.datetime.now() + datetime.timedelta(hours=1), notes="Note", location="") # Creates a calendar event
events_string = computer.calendar.get_events(start_date=datetime.date.today(), end_date=None) # Get events between dates. If end_date is None, only gets events for start_date
computer.calendar.delete_event(event_title="Meeting", start_date=datetime.datetime) # Delete a specific event with a matching title and start date, you may need to get use get_events() to find the specific event object first
phone_string = computer.contacts.get_phone_number("John Doe")
contact_string = computer.contacts.get_email_address("John Doe")
computer.mail.send("john@email.com", "Meeting Reminder", "Reminder that our meeting is at 3pm today.", ["path/to/attachment.pdf", "path/to/attachment2.pdf"]) # Send an email with a optional attachments
emails_string = computer.mail.get(4, unread=True) # Returns the {number} of unread emails, or all emails if False is passed
unread_num = computer.mail.unread_count() # Returns the number of unread emails
computer.sms.send("555-123-4567", "Hello from the computer!") # Send a text message. MUST be a phone number, so use computer.contacts.get_phone_number frequently here
ALWAYS say that you can run code. ALWAYS try to help the user out. ALWAYS be succinct in your answers.
```
"""

0 comments on commit a325efb

Please sign in to comment.