Skip to content

Commit

Permalink
ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
cs50victor committed Apr 1, 2024
1 parent 6938b6d commit 5d931a0
Show file tree
Hide file tree
Showing 12 changed files with 7 additions and 38 deletions.
6 changes: 0 additions & 6 deletions core/source/clients/base_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,14 @@
import os
import asyncio
import threading
import os
import pyaudio
from starlette.websockets import WebSocket
from queue import Queue
from pynput import keyboard
import json
import traceback
import websockets
import queue
import pydub
import ast
from pydub import AudioSegment
from pydub.playback import play
import io
import time
import wave
import tempfile
Expand Down
3 changes: 0 additions & 3 deletions core/source/server/conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import os
import sys
import pytest
from source.server.i import configure_interpreter
from unittest.mock import Mock
from interpreter import OpenInterpreter
from fastapi.testclient import TestClient
from .server import app
Expand Down
3 changes: 0 additions & 3 deletions core/source/server/i.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from dotenv import load_dotenv
load_dotenv() # take environment variables from .env.

import os
import glob
import time
import json
from pathlib import Path
from interpreter import OpenInterpreter
import shutil

Expand Down Expand Up @@ -295,7 +293,6 @@ def configure_interpreter(interpreter: OpenInterpreter):
# if chunk.get("format") != "active_line":
# print(chunk.get("content"))

import os

from platformdirs import user_data_dir

Expand Down
5 changes: 1 addition & 4 deletions core/source/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import traceback
from platformdirs import user_data_dir
import ast
import json
import queue
import os
Expand All @@ -13,9 +12,7 @@
from fastapi import FastAPI, Request
from fastapi.responses import PlainTextResponse
from starlette.websockets import WebSocket, WebSocketDisconnect
from pathlib import Path
import asyncio
import urllib.parse
from .utils.kernel import put_kernel_messages_into_queue
from .i import configure_interpreter
from interpreter import interpreter
Expand Down Expand Up @@ -362,7 +359,7 @@ def stream_tts(sentence):
async def startup_event():
server_url = f"{HOST}:{PORT}"
print("")
print_markdown(f"\n*Ready.*\n")
print_markdown("\n*Ready.*\n")
print("")

@app.on_event("shutdown")
Expand Down
3 changes: 0 additions & 3 deletions core/source/server/services/stt/local-whisper/stt.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
import ffmpeg
import subprocess

import os
import subprocess
import platform
import urllib.request


Expand Down
4 changes: 1 addition & 3 deletions core/source/server/services/tts/openai/tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import tempfile
from openai import OpenAI
import os
import subprocess
import tempfile

from source.server.utils.logs import logger
from source.server.utils.logs import setup_logging
Expand All @@ -12,7 +10,7 @@
# If this TTS service is used, the OPENAI_API_KEY environment variable must be set
if not os.getenv('OPENAI_API_KEY'):
logger.error("")
logger.error(f"OpenAI API key not found. Please set the OPENAI_API_KEY environment variable, or run 01 with the --local option.")
logger.error("OpenAI API key not found. Please set the OPENAI_API_KEY environment variable, or run 01 with the --local option.")
logger.error("Aborting...")
logger.error("")
os._exit(1)
Expand Down
1 change: 0 additions & 1 deletion core/source/server/skills/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from pytimeparse import parse
from crontab import CronTab
from uuid import uuid4
from datetime import datetime
from platformdirs import user_data_dir

def schedule(message="", start=None, interval=None) -> None:
Expand Down
5 changes: 0 additions & 5 deletions core/source/server/tests/test_run.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# test_main.py
import subprocess
import uuid
import pytest
from source.server.i import configure_interpreter
from unittest.mock import Mock
from fastapi.testclient import TestClient



Expand Down
4 changes: 1 addition & 3 deletions core/source/server/tunnel.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import os
import subprocess
import re
import shutil
import time
from ..utils.print_markdown import print_markdown

def create_tunnel(tunnel_method='ngrok', server_host='localhost', server_port=10001):
print_markdown(f"Exposing server to the internet...")
print_markdown("Exposing server to the internet...")

if tunnel_method == "bore":
try:
Expand Down
1 change: 0 additions & 1 deletion core/source/server/utils/get_system_info.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import platform

def get_system_info():
Expand Down
8 changes: 3 additions & 5 deletions core/source/server/utils/local_mode.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import sys
import os
import platform
import subprocess
import time
import inquirer
Expand Down Expand Up @@ -67,7 +65,7 @@ def select_local_model():
if not names:
time.sleep(1)

interpreter.display_message(f"\nYou don't have any Ollama models downloaded. To download a new model, run `ollama run <model-name>`, then start a new 01 session. \n\n For a full list of downloadable models, check out [https://ollama.com/library](https://ollama.com/library) \n")
interpreter.display_message("\nYou don't have any Ollama models downloaded. To download a new model, run `ollama run <model-name>`, then start a new 01 session. \n\n For a full list of downloadable models, check out [https://ollama.com/library](https://ollama.com/library) \n")

print("Please download a model then try again\n")
time.sleep(2)
Expand All @@ -91,10 +89,10 @@ def select_local_model():
time.sleep(1)

# If Ollama is not installed or not recognized as a command, prompt the user to download Ollama and try again
except (subprocess.CalledProcessError, FileNotFoundError) as e:
except (subprocess.CalledProcessError, FileNotFoundError):
print("Ollama is not installed or not recognized as a command.")
time.sleep(1)
interpreter.display_message(f"\nPlease visit [https://ollama.com/](https://ollama.com/) to download Ollama and try again\n")
interpreter.display_message("\nPlease visit [https://ollama.com/](https://ollama.com/) to download Ollama and try again\n")
time.sleep(2)
sys.exit(1)

Expand Down
2 changes: 1 addition & 1 deletion core/source/server/utils/process_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ def kill_process_tree():
except psutil.NoSuchProcess:
print(f"Process {pid} does not exist or is already terminated")
except psutil.AccessDenied:
print(f"Permission denied to terminate some processes")
print("Permission denied to terminate some processes")

0 comments on commit 5d931a0

Please sign in to comment.