diff --git a/examples/python-operator-dataflow/README.md b/examples/python-operator-dataflow/README.md index e3b6eb0f3..e678f6241 100644 --- a/examples/python-operator-dataflow/README.md +++ b/examples/python-operator-dataflow/README.md @@ -19,7 +19,7 @@ cargo run --example python-operator-dataflow ## Installation ```bash -conda create -n example_env python=3.12 +conda create -n example_env python=3.11 pip install -r requirements.txt ``` @@ -48,109 +48,8 @@ send 200 200 200 400 to topic line record ``` -```bash -wget https://raw.githubusercontent.com/dora-rs/dora/v0.3.2/examples/python-operator-dataflow/keyboard_op.py -wget https://raw.githubusercontent.com/dora-rs/dora/v0.3.2/examples/python-operator-dataflow/microphone_op.py -wget https://raw.githubusercontent.com/dora-rs/dora/v0.3.2/examples/python-operator-dataflow/whisper_op.py -wget https://raw.githubusercontent.com/dora-rs/dora/v0.3.2/examples/python-operator-dataflow/sentence_transformers_op.py -wget https://raw.githubusercontent.com/dora-rs/dora/v0.3.2/examples/python-operator-dataflow/llm_op.py -wget https://raw.githubusercontent.com/dora-rs/dora/v0.3.2/examples/python-operator-dataflow/file_saver_op.py -``` - -and adding the following to the dataflow configuration: - -```yaml -nodes: - - id: webcam - operator: - python: webcam.py - inputs: - tick: dora/timer/millis/50 - outputs: - - image - - - id: object_detection - operator: - python: object_detection.py - inputs: - image: webcam/image - outputs: - - bbox - - - id: plot - operator: - python: plot.py - inputs: - image: webcam/image - bbox: object_detection/bbox - line: llm/line - keyboard_buffer: keyboard/buffer - user_message: keyboard/submitted - assistant_message: llm/assistant_message - - ## Speech to text - - id: keyboard - custom: - source: keyboard_op.py - outputs: - - buffer - - submitted - - record - - ask - - send - - change - inputs: - recording: whisper/text - - - id: microphone - operator: - python: microphone_op.py - inputs: - record: keyboard/record - outputs: - - audio - - - id: whisper - operator: - python: whisper_op.py - inputs: - audio: microphone/audio - outputs: - - text - - ## Code Modifier - - id: vectordb - operator: - python: sentence_transformers_op.py - inputs: - query: keyboard/change - saved_file: file_saver/saved_file - outputs: - - raw_file - - - id: llm - operator: - python: llm_op.py - inputs: - code_modifier: vectordb/raw_file - assistant: keyboard/ask - message_sender: keyboard/send - outputs: - - modified_file - - line - - assistant_message - - - id: file_saver - operator: - python: file_saver_op.py - inputs: - file: llm/modified_file - outputs: - - saved_file -``` - The keyboard, microphone, whisper node, works in a very similar fashion as the object detection dataflow and I'll let you check it out by yourself. The code modification flow works by first comparing an instruction with a vectordb of operators source code and then feeding the most similar operator to an llm with the instruction for code modification. -The end result is then saved using the file saver +The end result is then saved using a file saver. diff --git a/examples/python-operator-dataflow/dataflow_llm.yml b/examples/python-operator-dataflow/dataflow_llm.yml index faf978af4..41bc72050 100644 --- a/examples/python-operator-dataflow/dataflow_llm.yml +++ b/examples/python-operator-dataflow/dataflow_llm.yml @@ -84,4 +84,4 @@ nodes: inputs: file: llm/modified_file outputs: - - saved_file \ No newline at end of file + - saved_file diff --git a/examples/python-operator-dataflow/merge.py b/examples/python-operator-dataflow/merge.py deleted file mode 100644 index cd60745d5..000000000 --- a/examples/python-operator-dataflow/merge.py +++ /dev/null @@ -1,12 +0,0 @@ -import pyarrow as pa - -with pa.memory_map("image.arrow", "r") as source: - df_i = pa.ipc.open_file(source).read_all() - -with pa.memory_map("bbox.arrow", "r") as source: - df_b = pa.ipc.open_file(source).read_all() - -df_i = df_i.to_pandas() -df_b = df_b.to_pandas() - -df = df_i.merge(df_b, on="trace_id") diff --git a/examples/python-operator-dataflow/requirements.txt b/examples/python-operator-dataflow/requirements.txt index 3fb39579d..71ccb110c 100644 --- a/examples/python-operator-dataflow/requirements.txt +++ b/examples/python-operator-dataflow/requirements.txt @@ -54,4 +54,4 @@ transformers pylcs accelerate optimum -auto-gptq>=0.7.1 \ No newline at end of file +auto-gptq>=0.7.1 diff --git a/examples/python-operator-dataflow/sentence_transformers_op.py b/examples/python-operator-dataflow/sentence_transformers_op.py index cd045211d..c4619cf7e 100644 --- a/examples/python-operator-dataflow/sentence_transformers_op.py +++ b/examples/python-operator-dataflow/sentence_transformers_op.py @@ -4,17 +4,9 @@ from dora import DoraStatus import os import sys -import inspect import torch import pyarrow as pa -SHOULD_NOT_BE_INCLUDED = [ - "utils.py", - "sentence_transformers_op.py", - "chatgpt_op.py", - "llm_op.py", -] - SHOULD_BE_INCLUDED = [ "webcam.py", "object_detection.py", diff --git a/examples/python-operator-dataflow/webcam.py b/examples/python-operator-dataflow/webcam.py index c7d451919..43ce7e207 100755 --- a/examples/python-operator-dataflow/webcam.py +++ b/examples/python-operator-dataflow/webcam.py @@ -66,7 +66,7 @@ def on_event( else: print("received unexpected event:", event_type) - if time.time() - self.start_time < 200 or CI != "true": + if time.time() - self.start_time < 20 or CI != "true": return DoraStatus.CONTINUE else: return DoraStatus.STOP