This repository has been archived by the owner on Sep 7, 2024. It is now read-only.
generated from TIL-24/til-24-base
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge from TIL-24/til-24-base@9352746
- Loading branch information
1 parent
2ba3f92
commit 3619e57
Showing
44 changed files
with
341 additions
and
310 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
websockets | ||
requests | ||
asyncio | ||
asyncio | ||
httpx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,40 @@ | ||
from random import randint | ||
from typing import Dict, List | ||
from finals_manager import FinalsManager | ||
import requests | ||
|
||
|
||
class AutoManager(FinalsManager): | ||
def __init__(self, local_ip: str): | ||
super().__init__() | ||
self.local_ip = local_ip | ||
|
||
def run_asr(self, audio_bytes: bytes) -> str: | ||
async def run_asr(self, audio_bytes: bytes) -> str: | ||
print("Running ASR") | ||
return "asr" | ||
|
||
def run_nlp(self, transcript: str) -> Dict[str, str]: | ||
async def run_nlp(self, transcript: str) -> Dict[str, str]: | ||
print("Running NLP") | ||
return { | ||
"target": "airplane", | ||
"heading": f"{randint(1,360):03}", | ||
"tool": "surface-to-air missiles", | ||
} | ||
|
||
def run_vlm(self, image_bytes: bytes, caption: str) -> List[int]: | ||
async def run_vlm(self, image_bytes: bytes, caption: str) -> List[int]: | ||
print("Running VLM") | ||
return [0, 0, 0, 0] | ||
|
||
def send_heading(self, heading: str) -> bytes: | ||
async def send_heading(self, heading: str) -> bytes: | ||
assert heading.isdigit(), "The heading string contains non-digit characters" | ||
print(f"Sending cannon heading {heading}") | ||
results = requests.post( | ||
results = await self.async_post( | ||
f"http://{self.local_ip}:5003/send_heading", json={"heading": heading} | ||
) | ||
# snapshot of image | ||
return results.content | ||
|
||
def reset_cannon(self): | ||
async def reset_cannon(self): | ||
print("Resetting cannon to original position") | ||
results = requests.post(f"http://{self.local_ip}:5003/reset_cannon") | ||
results = await self.async_post(f"http://{self.local_ip}:5003/reset_cannon") | ||
print(results.text) | ||
return results.json() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,42 @@ | ||
import json | ||
import websockets | ||
from abc import ABC, abstractmethod | ||
from typing import Any, Dict, List | ||
from typing import Any, Dict, List, Optional | ||
import httpx | ||
|
||
|
||
class FinalsManager(ABC): | ||
def __init__(self): | ||
print("initializing participant finals server manager") | ||
self.client = httpx.AsyncClient() | ||
|
||
def send_result( | ||
async def exit(self): | ||
await self.client.aclose() | ||
|
||
async def async_post(self, endpoint: str, json: Optional[Dict] = None): | ||
return await self.client.post(endpoint, json=json) | ||
|
||
async def send_result( | ||
self, websocket: websockets.WebSocketClientProtocol, data: Dict[str, Any] | ||
): | ||
return websocket.send(json.dumps(data)) | ||
return await websocket.send(json.dumps(data)) | ||
|
||
@abstractmethod | ||
def run_asr(self, audio_bytes: bytes) -> str: | ||
async def run_asr(self, audio_bytes: bytes) -> str: | ||
raise NotImplemented | ||
|
||
@abstractmethod | ||
def run_nlp(self, transcript: str) -> Dict[str, str]: | ||
async def run_nlp(self, transcript: str) -> Dict[str, str]: | ||
raise NotImplemented | ||
|
||
@abstractmethod | ||
def send_heading(self, heading: str) -> bytes: | ||
async def send_heading(self, heading: str) -> bytes: | ||
raise NotImplemented | ||
|
||
@abstractmethod | ||
def reset_cannon(self) -> None: | ||
async def reset_cannon(self) -> None: | ||
raise NotImplemented | ||
|
||
def run_vlm(self, image_bytes: bytes, caption: str) -> List[int]: | ||
@abstractmethod | ||
async def run_vlm(self, image_bytes: bytes, caption: str) -> List[int]: | ||
raise NotImplemented |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.