← Back
Test Node Code
June 5 2024
from typing import Literal, List

class PromptStep(BaseModel):
   # define the input, output, steps, template function, protocols, all here, etc
   # ... 
   # prompt: str
   pass

class Node(BaseModel):
   task: str
   model: Literal["gpt-3.5-turbo"]
   prompt_steps: List[PromptStep]
   model_outputs: List[str] = []

# 1: Here are 10 cleansed e-commerce product names: - 1, -2 ... I will provide product names, and your job is to standardise them into friendly e-commerce product names. Do you understand?
# 1: ...
# 1.1: Provide input.
# 1.1: ...

# 2: Here is the output from a system which converts product names into clean product names. Pick it apart and address 5 pros and 5 cons of its output.
# 2: ...

# 3: Here is the output from a system which picks apart responses and adjusts them. Pick the output from the body of text. ONLY reply the output, do not provide any other commentary.
# 3: ...

ProductCleaner = Node(
   task="converts product names into clean product names", 
   model="gpt-3.5-turbo",  
   prompt_steps=[PromptStep()]
)

ProConPickerRewriter = Node(
   task="picks apart responses and adjusts them",
   model="gpt-3.5-turbo",
   prompt_steps=[PromptStep()]
)

OutputFinder = Node(
   task="picks out the output from a paragraph",
   model="gpt-3.5-turbo",
   prompt_steps=[PromptStep()]
)

def run_node(node: Node):
   for step in node.prompt_steps: # ... run prompt steps, add to model_outputs 
      output = "some model output"
      node.model_outputs.append(output)

def connect_nodes(a: Node, b: Node):
   pre_prompt = f"Here is an output from a system which {a.task}. {b.prompt_steps[0].prompt}" # combine a's task
   # ... manage connection

Sincerely, thanks for reading!
Any questions or comments, reach out!
jack@dataology.com.au