- id: setup_qa_system
name: setup_qa_system
tool: INPUT_JSON_WITH_VALIDATION
input:
- name: value
value: {
"questions": [
"What are the minimum system requirements?",
"How do I configure network settings?",
"What should I do if the system fails to start?",
"How often should I perform maintenance?",
"What are the warranty terms?"
]
}
- id: answer_questions
name: answer_questions
tool: PYTHON_SANDBOX_RUN
input:
- name: script
value: |
import json
questions = {{steps.setup_qa_system.result.questions}}
qa_pairs = []
for i, question in enumerate(questions):
qa_pairs.append({
"id": f"q_{i+1}",
"question": question,
"status": "pending"
})
print(json.dumps({"qa_pairs": qa_pairs}))
- id: get_answer_1
name: get_answer_1
tool: LLAMA_CLOUD_QUERY
config:
- name: api_key
value: "{{secrets.LLAMA_CLOUD_API_KEY}}"
- name: project_id
value: "your_project_id"
input:
- name: query
value: "{{steps.answer_questions.result.qa_pairs[0].question}}"
- name: include_sources
value: true
- id: get_answer_2
name: get_answer_2
tool: LLAMA_CLOUD_QUERY
config:
- name: api_key
value: "{{secrets.LLAMA_CLOUD_API_KEY}}"
- name: project_id
value: "your_project_id"
input:
- name: query
value: "{{steps.answer_questions.result.qa_pairs[1].question}}"
- name: include_sources
value: true
- id: compile_faq
name: compile_faq
tool: PYTHON_SANDBOX_RUN
input:
- name: script
value: |
import json
# Compile all Q&A pairs
faq_items = [
{
"question": "{{steps.answer_questions.result.qa_pairs[0].question}}",
"answer": "{{steps.get_answer_1.result.response}}",
"sources": "{{steps.get_answer_1.result.sources}}"
},
{
"question": "{{steps.answer_questions.result.qa_pairs[1].question}}",
"answer": "{{steps.get_answer_2.result.response}}",
"sources": "{{steps.get_answer_2.result.sources}}"
}
]
# Format as FAQ document
faq_markdown = "# Frequently Asked Questions\n\n"
for i, item in enumerate(faq_items, 1):
faq_markdown += f"## {i}. {item['question']}\n\n"
faq_markdown += f"{item['answer']}\n\n"
if item['sources']:
faq_markdown += f"*Sources: {item['sources']}*\n\n"
faq_markdown += "---\n\n"
print(json.dumps({"faq_document": faq_markdown}))