Skip to content

Commit

Permalink
better debug tools
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason committed Mar 30, 2024
1 parent 7ea29d2 commit 1a2d0d3
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 16 deletions.
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ jsonlines
nltk
Pillow
groq
sshtunnel
psycopg2
8 changes: 8 additions & 0 deletions utils/timeline_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@
world = ""
last_death_at_step = 0
last_death_at_row = 0
if "--convo" in sys.argv:
convos = True
else
convos = False
with jsonlines.open(path, "r") as jsonl_file:
for i, row in enumerate(jsonl_file):
obj = json.loads(row)
max_step = obj.get("step")
step_type = obj.get("step_type")
step_types[step_type] = step_types.get(step_type, 0) + 1
sim_id = obj.get("sim_id")
if convos and step_type == "talk":
print(obj)
if step_type == "agent_init":
agents[obj["agent_id"]] = {}
agents[obj["agent_id"]]["name"] = obj["name"]
Expand All @@ -36,6 +42,8 @@
scenario = obj["data"]["scenario"]
world = obj["data"]["environment"]



total_steps +=1
human_agents = dict(filter(lambda item: item[1]["kind"] == "human", agents.items()))
print(f"matrix info sim_id: {sim_id}")
Expand Down
1 change: 1 addition & 0 deletions web/.env.development
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
REDIS_URL=redis://localhost:6379
NEXT_PUBLIC_API_URL=http://localhost:3000/api/simulations
NEXT_PUBLIC_MOUNTED=false
NEXT_PUBLIC_ASSET_DOMAIN=http://localhost:3004/
39 changes: 23 additions & 16 deletions web/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,30 @@ const Sidebar: React.FC<SidebarProps> = (
}, [isPlaying]);

const fetchAudioData = async (sim_id: string, step_id: number, substep_id: number, agent_name: string, lang: string, content: string): Promise<string> => {
try {
const res = await fetch(
`${process.env.NEXT_PUBLIC_ASSET_DOMAIN}/audio?mid=${sim_id}&step=${step_id}&substep=${substep_id}&agent=${agent_name}&lang=${lang}&c=${btoa(content)}`,
{ mode: 'cors' }
);
if (!res.ok) {
throw new Error('Failed to fetch data');
}

const audioBlob = await res.blob();
const audioUrl = URL.createObjectURL(audioBlob);
return audioUrl;
} catch (error) {
console.error('Error fetching audio:', error);
return "";
try {
const res = await fetch(
`${process.env.NEXT_PUBLIC_ASSET_DOMAIN}/audio?mid=${sim_id}&step=${step_id}&substep=${substep_id}&agent=${agent_name}&lang=${lang}&c=${btoa(content)}`,
{ mode: 'cors' }
);
if (!res.ok) {
throw new Error('Failed to fetch data');
}
};

const audioBlob = await res.blob();
const audioUrl = URL.createObjectURL(audioBlob);

// Preload the audio file
const audio = new Audio(audioUrl);
audio.preload = 'auto';
audio.load();

return audioUrl;
} catch (error) {
console.error('Error fetching audio:', error);
return "";
}
};


const addToAudioQueue = (audioClipUrl: Promise<string>) => {
setAudioQueue((oldQueue) => [...oldQueue, audioClipUrl]);
Expand Down

0 comments on commit 1a2d0d3

Please sign in to comment.