mirror of
https://github.com/aljazceru/Tutorial-Codebase-Knowledge.git
synced 2025-12-18 23:14:21 +01:00
Initial commit
This commit is contained in:
26
nodes.py
Normal file
26
nodes.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from pocketflow import Node
|
||||
from utils.call_llm import call_llm
|
||||
|
||||
class GetQuestionNode(Node):
|
||||
def exec(self, _):
|
||||
# Get question directly from user input
|
||||
user_question = input("Enter your question: ")
|
||||
return user_question
|
||||
|
||||
def post(self, shared, prep_res, exec_res):
|
||||
# Store the user's question
|
||||
shared["question"] = exec_res
|
||||
return "default" # Go to the next node
|
||||
|
||||
class AnswerNode(Node):
|
||||
def prep(self, shared):
|
||||
# Read question from shared
|
||||
return shared["question"]
|
||||
|
||||
def exec(self, question):
|
||||
# Call LLM to get the answer
|
||||
return call_llm(question)
|
||||
|
||||
def post(self, shared, prep_res, exec_res):
|
||||
# Store the answer in shared
|
||||
shared["answer"] = exec_res
|
||||
Reference in New Issue
Block a user