Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Issue 42 switch statement #46

Open
wants to merge 6 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
Binary file added .DS_Store
Binary file not shown.
5 changes: 4 additions & 1 deletion app/remotellama.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ class LlamaInterface:
headers = {"Content-Type": "application/json"}
def query(question):
data = {"prompt": question}
response = requests.post(LlamaInterface.url + 'llama', headers=LlamaInterface.headers, json=data)
try:
response = requests.post(LlamaInterface.url + 'llama', headers=LlamaInterface.headers, json=data)
except requests.exceptions.ConnectTimeout:
return "Timeout Error Has Occurred"
response_data = response.json()
# Check if the response is a dictionary before trying to access it
if isinstance(response_data, dict):
Expand Down
48 changes: 26 additions & 22 deletions app/web_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,32 @@ def parse_command(command: str) -> Union[str, dict]:
"""
command_original = command
command = command.lower()
# Clear command
if command == "cls" or command == "clear":
return "clear"
# Help menu command
if command == "help":
return utils.read_from_file("static\\resources\\help_menu.html")
# Capture frame command
if command == "capture":
return "capture"
# Open code in IDE command
if command == "open":
return "open"
# List videos command
if command == "list-videos":
return list_videos()
# Available videos for autocomplete
if command == "available-videos":
return available_videos()
# Invalid play-video command
if command == "play-video":
return "<span class=\"text-red-500\">Invalid usage of play-video. Video must be specified. " \
"Type help for more information</span>"

# Dictionary of valid commands with key:value pairs
valid_commands = {
# Clear command
'cls': 'clear',
'clear': 'clear',
# Help menu command
'help': utils.read_from_file("static\\resources\\help_menu.html"),
# Capture frame command
'capture': 'capture',
# Open code in IDE command
'open': 'open',
# List videos command
'list-videos': list_videos(),
# Available videos for autocomplete
'available-videos': available_videos(),
# Invalid play-video command
'play-video': "<span class=\"text-red-500\">Invalid usage of play-video. Video must be specified. "
"Type help for more information</span>"
}

result = valid_commands.get(command, None)

if result is not None:
return result

# Multiple word/option commands
return parse_split_command(command_original)

Expand Down