mirror of
https://github.com/aljazceru/Tutorial-Codebase-Knowledge.git
synced 2025-12-18 15:04:20 +01:00
26 lines
778 B
Python
26 lines
778 B
Python
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 |