Skip to content

Commit

Permalink
Black formatting update
Browse files Browse the repository at this point in the history
  • Loading branch information
Purg committed Sep 27, 2024
1 parent e8d1bbd commit c61674a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ rich = "==13.7.1"
chumpy = "==0.66"
#mmpose = "==0.24"
mmpose = {git = "https://github.com/periakiva/mmpose.git", branch="exp"}
mmcv= "==1.3.8"
mmcv = "==1.3.8"
torch = {url = "https://download.pytorch.org/whl/cu111/torch-1.9.1%2Bcu111-cp38-cp38-linux_x86_64.whl"}
torchvision = {url = "https://download.pytorch.org/whl/cu111/torchvision-0.10.1%2Bcu111-cp38-cp38-linux_x86_64.whl"}
detectron2 = {url = "https://dl.fbaipublicfiles.com/detectron2/wheels/cu111/torch1.9/detectron2-0.6%2Bcu111-cp38-cp38-linux_x86_64.whl"}
Expand Down
11 changes: 6 additions & 5 deletions ros/angel_system_nodes/angel_system_nodes/audio/asr.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
from sensor_msgs.msg import Image

import nltk
nltk.download('punkt')

nltk.download("punkt")
from nltk.tokenize import sent_tokenize
import rclpy

Expand Down Expand Up @@ -267,7 +268,7 @@ def _publish_text(self, text: str):
):
# If Angel keyword is not found, don't publish the utterance
return

self.log.info("Publish thinking feedback")
self.publish_feedback_response()

Expand All @@ -282,12 +283,12 @@ def _publish_text(self, text: str):
index = text.lower().find(word)
if index != -1:
# Remove everything before the word
result_text = text[index+6:]
result_text = text[index + 6 :]
break

published_msg.utterance_text = result_text

if self.pov_frame is None or len(self.pov_frame)<=1:
if self.pov_frame is None or len(self.pov_frame) <= 1:
published_msg.pov_frame = ""
self.log.info("No pov frame available")
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ def get_response(self, msg: DialogueUtterance, optional_fields: str) -> str:
response_text = ""
try:
if self.is_openai_ready:
response_text = self.prompt_gpt(msg.utterance_text, optional_fields, msg.pov_frame)
response_text = self.prompt_gpt(
msg.utterance_text, optional_fields, msg.pov_frame
)
except RuntimeError as err:
self.log.info(err)
response_text = "I'm sorry. I don't know how to answer your statement."
Expand Down Expand Up @@ -156,7 +158,9 @@ def publish_generated_response(
)
self._qa_publisher.publish(publish_msg)

def prompt_gpt(self, question, optional_fields: str, pov_frame: str, model: str = "gpt-4o"):
def prompt_gpt(
self, question, optional_fields: str, pov_frame: str, model: str = "gpt-4o"
):
prompt = self.prompt.format(question=question, taskactivity=optional_fields)
self.log.info(f'Prompting OpenAI with\n{question} with "{optional_fields}"\n')

Expand All @@ -169,7 +173,9 @@ def prompt_gpt(self, question, optional_fields: str, pov_frame: str, model: str
"temperature": 0.0,
"max_tokens": 128,
}
self.log.info(f'Prompting OpenAI with\n{question} with "{optional_fields}" without pov frame.\n')
self.log.info(
f'Prompting OpenAI with\n{question} with "{optional_fields}" without pov frame.\n'
)
else:
payload = {
"model": model,
Expand All @@ -193,7 +199,9 @@ def prompt_gpt(self, question, optional_fields: str, pov_frame: str, model: str
"temperature": 0.0,
"max_tokens": 128,
}
self.log.info(f'Prompting OpenAI with\n{question} with "{optional_fields}" and pov frame.\n')
self.log.info(
f'Prompting OpenAI with\n{question} with "{optional_fields}" and pov frame.\n'
)

req = requests.post(
"https://api.openai.com/v1/chat/completions",
Expand Down

0 comments on commit c61674a

Please sign in to comment.