update cursor rule
This commit is contained in:
parent
ee4dc4e467
commit
4ab2bb6459
22
.cursorrules
22
.cursorrules
|
|
@ -140,6 +140,7 @@ Agentic Coding should be a collaboration between Human System Design and Agent I
|
||||||
```
|
```
|
||||||
my_project/
|
my_project/
|
||||||
├── main.py
|
├── main.py
|
||||||
|
├── nodes.py
|
||||||
├── flow.py
|
├── flow.py
|
||||||
├── utils/
|
├── utils/
|
||||||
│ ├── __init__.py
|
│ ├── __init__.py
|
||||||
|
|
@ -154,13 +155,12 @@ my_project/
|
||||||
- **`utils/`**: Contains all utility functions.
|
- **`utils/`**: Contains all utility functions.
|
||||||
- It's recommended to dedicate one Python file to each API call, for example `call_llm.py` or `search_web.py`.
|
- It's recommended to dedicate one Python file to each API call, for example `call_llm.py` or `search_web.py`.
|
||||||
- Each file should also include a `main()` function to try that API call
|
- Each file should also include a `main()` function to try that API call
|
||||||
- **`flow.py`**: Implements the system's flow, starting with node definitions followed by the overall structure.
|
- **`nodes.py`**: Contains all the node definitions.
|
||||||
```python
|
```python
|
||||||
# flow.py
|
# nodes.py
|
||||||
from pocketflow import Node, Flow
|
from pocketflow import Node
|
||||||
from utils.call_llm import call_llm
|
from utils.call_llm import call_llm
|
||||||
|
|
||||||
# Example with two nodes in a flow
|
|
||||||
class GetQuestionNode(Node):
|
class GetQuestionNode(Node):
|
||||||
def exec(self, _):
|
def exec(self, _):
|
||||||
# Get question directly from user input
|
# Get question directly from user input
|
||||||
|
|
@ -184,7 +184,15 @@ my_project/
|
||||||
def post(self, shared, prep_res, exec_res):
|
def post(self, shared, prep_res, exec_res):
|
||||||
# Store the answer in shared
|
# Store the answer in shared
|
||||||
shared["answer"] = exec_res
|
shared["answer"] = exec_res
|
||||||
|
```
|
||||||
|
- **`flow.py`**: Implements functions that create flows by importing node definitions and connecting them.
|
||||||
|
```python
|
||||||
|
# flow.py
|
||||||
|
from pocketflow import Flow
|
||||||
|
from nodes import GetQuestionNode, AnswerNode
|
||||||
|
|
||||||
|
def create_qa_flow():
|
||||||
|
"""Create and return a question-answering flow."""
|
||||||
# Create nodes
|
# Create nodes
|
||||||
get_question_node = GetQuestionNode()
|
get_question_node = GetQuestionNode()
|
||||||
answer_node = AnswerNode()
|
answer_node = AnswerNode()
|
||||||
|
|
@ -193,12 +201,12 @@ my_project/
|
||||||
get_question_node >> answer_node
|
get_question_node >> answer_node
|
||||||
|
|
||||||
# Create flow starting with input node
|
# Create flow starting with input node
|
||||||
qa_flow = Flow(start=get_question_node)
|
return Flow(start=get_question_node)
|
||||||
```
|
```
|
||||||
- **`main.py`**: Serves as the project's entry point.
|
- **`main.py`**: Serves as the project's entry point.
|
||||||
```python
|
```python
|
||||||
# main.py
|
# main.py
|
||||||
from flow import qa_flow
|
from flow import create_qa_flow
|
||||||
|
|
||||||
# Example main function
|
# Example main function
|
||||||
# Please replace this with your own main function
|
# Please replace this with your own main function
|
||||||
|
|
@ -208,6 +216,8 @@ my_project/
|
||||||
"answer": None # Will be populated by AnswerNode
|
"answer": None # Will be populated by AnswerNode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Create the flow and run it
|
||||||
|
qa_flow = create_qa_flow()
|
||||||
qa_flow.run(shared)
|
qa_flow.run(shared)
|
||||||
print(f"Question: {shared['question']}")
|
print(f"Question: {shared['question']}")
|
||||||
print(f"Answer: {shared['answer']}")
|
print(f"Answer: {shared['answer']}")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue