Add CLI command and improve documentation formatting
Included a CLI command in the README and added console log examples for clarity. Enhanced readability through punctuation fixes and expanded error handling section with better logging examples.
This commit is contained in:
66
README.md
66
README.md
@@ -2,9 +2,12 @@
|
|||||||
|
|
||||||
> A TypeScript/JavaScript library for building dynamic, LLM-driven workflows using a region-based execution model
|
> A TypeScript/JavaScript library for building dynamic, LLM-driven workflows using a region-based execution model
|
||||||
|
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
|
CLI: `npx workflow-function-manifold`
|
||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
- [Overview](#overview)
|
- [Overview](#overview)
|
||||||
- [Installation](#installation)
|
- [Installation](#installation)
|
||||||
@@ -21,10 +24,10 @@
|
|||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
`workflow-function-manifold` enables you to create dynamic workflows that:
|
`workflow-function-manifold` enables you to create dynamic workflows that:
|
||||||
- Navigate between different execution regions based on LLM-interpreted intents
|
- Navigate between different execution regions based on LLM-interpreted intents.
|
||||||
- Execute operations within regions based on state and context
|
- Execute operations within regions based on state and context.
|
||||||
- Maintain workflow state across operations
|
- Maintain workflow state across operations.
|
||||||
- Support flexible region-to-region connections
|
- Support flexible region-to-region connections.
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
graph TD
|
graph TD
|
||||||
@@ -83,10 +86,14 @@ const analysisRegion = new ManifoldRegion('analysis', [analysisOperator]);
|
|||||||
manifold.addRegion(analysisRegion);
|
manifold.addRegion(analysisRegion);
|
||||||
|
|
||||||
// Execute workflow
|
// Execute workflow
|
||||||
await manifold.navigate('analyze the data');
|
await manifold.navigate('analyze the data'); // This navigates to the 'analysis' region
|
||||||
await manifold.executeWorkflow('analyze the data');
|
await manifold.executeWorkflow('analyze the data'); // Executes the operator in the 'analysis' region
|
||||||
|
|
||||||
|
console.log(manifold.state); // { analyzed: true }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> **Note:** The `DummyLlmService` matches specific keywords in prompts. Ensure your prompts contain keywords like `'analyze'`, `'process'`, or `'transform'` for the default operators to function.
|
||||||
|
|
||||||
## Core Components
|
## Core Components
|
||||||
|
|
||||||
### WorkflowFunctionManifold
|
### WorkflowFunctionManifold
|
||||||
@@ -189,6 +196,8 @@ for (const prompt of prompts) {
|
|||||||
await manifold.navigate(prompt);
|
await manifold.navigate(prompt);
|
||||||
await manifold.executeWorkflow(prompt);
|
await manifold.executeWorkflow(prompt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(manifold.state); // Final state after all operations
|
||||||
```
|
```
|
||||||
|
|
||||||
## API Reference
|
## API Reference
|
||||||
@@ -238,6 +247,8 @@ const operator = new WorkflowOperator('example', async (state) => {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The updated state persists across operators and regions.
|
||||||
|
|
||||||
## LLM Integration
|
## LLM Integration
|
||||||
|
|
||||||
The system uses LLM services for intent recognition. The default `DummyLlmService` provides basic intent matching, but you can implement your own LLM service:
|
The system uses LLM services for intent recognition. The default `DummyLlmService` provides basic intent matching, but you can implement your own LLM service:
|
||||||
@@ -254,32 +265,24 @@ class CustomLLMService {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### **Error Handling**
|
## Error Handling
|
||||||
|
|
||||||
This library includes basic error handling to ensure workflows continue running smoothly, even when unexpected issues arise.
|
This library includes basic error handling to ensure workflows run smoothly, even when unexpected issues arise.
|
||||||
|
|
||||||
#### **Navigation Errors**
|
### Navigation Errors
|
||||||
|
- If a prompt doesn't match a valid adjacent region:
|
||||||
|
- Logs a warning: `No valid region found for prompt: "<prompt>"`.
|
||||||
|
|
||||||
If a prompt doesn't match a valid adjacent region, the system will:
|
### Operator Execution Errors
|
||||||
- Log a warning: `No valid region found for prompt: "<prompt>"`
|
- If no matching operator is found:
|
||||||
- Continue without changing the current region.
|
- Logs a warning: `No matching operator found for intent: <intent>`.
|
||||||
|
|
||||||
#### **Operator Execution Errors**
|
### LLM Query Errors
|
||||||
|
- If issues arise during LLM queries:
|
||||||
If no matching operator is found for a prompt, or an operator encounters an error during execution:
|
- Logs an error: `Error during navigation for prompt "<prompt>": <error message>`.
|
||||||
- Log a warning: `No matching operator found for intent: <intent>`
|
|
||||||
- Log an error if execution fails: `Error during workflow execution for prompt "<prompt>": <error message>`
|
|
||||||
|
|
||||||
#### **LLM Query Errors**
|
|
||||||
|
|
||||||
In case of issues querying the LLM service:
|
|
||||||
- Log an error: `Error during navigation for prompt "<prompt>": <error message>`
|
|
||||||
|
|
||||||
#### **Example Error Logging**
|
|
||||||
|
|
||||||
|
### Example Error Logging
|
||||||
```javascript
|
```javascript
|
||||||
const manifold = new WorkflowFunctionManifold(new DummyLlmService());
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await manifold.navigate('unknown command');
|
await manifold.navigate('unknown command');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -293,14 +296,13 @@ try {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
1. Fork the repository
|
1. Fork the repository.
|
||||||
2. Create your feature branch: `git checkout -b feature/my-feature`
|
2. Create your feature branch: `git checkout -b feature/my-feature`.
|
||||||
3. Commit your changes: `git commit -am 'Add new feature'`
|
3. Commit your changes: `git commit -am 'Add new feature'`.
|
||||||
4. Push to the branch: `git push origin feature/my-feature`
|
4. Push to the branch: `git push origin feature/my-feature`.
|
||||||
5. Submit a pull request
|
5. Submit a pull request.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user