Skip to content

Commit 2bd5faa

Browse files
Adding AgentModel.
1 parent 825e381 commit 2bd5faa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+13515
-1718
lines changed

README.md

Lines changed: 49 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,43 @@ pip install dslmodel
1212

1313
## Overview
1414

15-
**DSLModel** is a powerful Python framework for declarative model creation using templates and concurrent execution. Built atop `Pydantic` for data validation and `DSPy` for model execution, DSLModel streamlines the development of dynamic models with features like:
15+
**DSLModel** is a powerful Python framework for declarative model creation using templates and concurrent execution.
16+
Built atop `Pydantic` for data validation and `DSPy` for model execution, DSLModel streamlines the development of
17+
dynamic models with features like:
1618

1719
- **Dynamic Field Generation:** Utilize Jinja2 templates for flexible model definitions.
1820
- **Concurrent Execution:** Leverage concurrent processing to optimize performance.
1921
- **Workflow Management:** Define and execute complex workflows with conditional logic and loops.
2022
- **Finite State Machines:** Incorporate state machine patterns for managing state transitions.
2123
- **Data Handling Utilities:** Read from and write to various data formats seamlessly.
22-
- **Notebook Generation:** Programmatically create and manage IPython notebooks.
2324
- **AI-Assisted Development:** Enhance productivity with AI-driven tools for code generation.
2425

2526
## Table of Contents
2627

2728
- [DSLModel](#dslmodel)
28-
- [Custom GPT: DSLModel Assistant v2024.10.10](#custom-gpt-dslmodel-assistant-v20241010)
29-
- [Overview](#overview)
30-
- [Table of Contents](#table-of-contents)
31-
- [Installation](#installation)
32-
- [Getting Started](#getting-started)
33-
- [Defining Models](#defining-models)
34-
- [Generating Data from Templates](#generating-data-from-templates)
35-
- [Concurrent Execution](#concurrent-execution)
36-
- [Workflow Management](#workflow-management)
37-
- [Workflow YAML](#workflow-yaml)
38-
- [Finite State Machines](#finite-state-machines)
39-
- [Data Handling](#data-handling)
40-
- [Notebook Generation](#notebook-generation)
41-
- [Architecture](#architecture)
42-
- [Core Components](#core-components)
43-
- [Data Flow](#data-flow)
44-
- [Development](#development)
45-
- [Setup](#setup)
46-
- [Testing](#testing)
47-
- [Contributing](#contributing)
48-
- [Deployment](#deployment)
49-
- [Deployment Pipeline](#deployment-pipeline)
50-
- [License](#license)
51-
- [Contact](#contact)
29+
- [Custom GPT: DSLModel Assistant v2024.10.10](#custom-gpt-dslmodel-assistant-v20241010)
30+
- [Overview](#overview)
31+
- [Table of Contents](#table-of-contents)
32+
- [Installation](#installation)
33+
- [Getting Started](#getting-started)
34+
- [Defining Models](#defining-models)
35+
- [Generating Data from Templates](#generating-data-from-templates)
36+
- [Concurrent Execution](#concurrent-execution)
37+
- [Workflow Management](#workflow-management)
38+
- [Workflow YAML](#workflow-yaml)
39+
- [Finite State Machines](#finite-state-machines)
40+
- [Data Handling](#data-handling)
41+
- [Architecture](#architecture)
42+
- [Core Components](#core-components)
43+
- [Data Flow](#data-flow)
44+
- [Development](#development)
45+
- [Setup](#setup)
46+
- [Testing](#testing)
47+
- [Contributing](#contributing)
48+
- [Deployment](#deployment)
49+
- [Deployment Pipeline](#deployment-pipeline)
50+
- [License](#license)
51+
- [Contact](#contact)
5252

5353
## Installation
5454

@@ -83,6 +83,7 @@ class Participant(DSLModel):
8383
name: str = Field("{{ fake_name() }}", description="Name of the participant.")
8484
role: str = Field("{{ fake_job() }}", description="Role of the participant.")
8585

86+
8687
class Meeting(DSLModel):
8788
"""Represents a meeting and its participants."""
8889
name: str = Field(..., description="Name of the meeting.")
@@ -124,7 +125,6 @@ participants = [Participant() for _ in range(5)] # Created using Jinja defaults
124125
# Generate the Meeting
125126
init_lm() # Sets the lm to gpt-4o-mini
126127

127-
128128
meeting_template = """
129129
Fortune 500 Meeting about {{ fake_bs() }}
130130
Participants:
@@ -161,7 +161,7 @@ init_lm() # Sets the lm to gpt-4o-mini
161161
results = run_dsls(tasks, max_workers=5)
162162

163163
for i, result in enumerate(results):
164-
print(f"Participant {i+1}: {result}")
164+
print(f"Participant {i + 1}: {result}")
165165
```
166166

167167
### Workflow Management
@@ -174,28 +174,28 @@ from dslmodel.workflow import Workflow, Job, Action, Condition, CronSchedule
174174
condition = Condition(expr="len(participants) > 3")
175175

176176
action1 = Action(
177-
name="Generate Participants",
178-
code="participants.extend([Participant() for _ in range(5)])"
177+
name="Generate Participants",
178+
code="participants.extend([Participant() for _ in range(5)])"
179179
)
180180

181181
action2 = Action(
182-
name="Notify Organizer",
183-
code="print('Organizer notified.')",
184-
cond=condition
182+
name="Notify Organizer",
183+
code="print('Organizer notified.')",
184+
cond=condition
185185
)
186186

187187
job = Job(
188-
name="Setup Meeting",
189-
steps=[action1, action2]
188+
name="Setup Meeting",
189+
steps=[action1, action2]
190190
)
191191

192192
trigger = CronSchedule(cron="0 9 * * MON") # Every Monday at 9 AM
193193

194194
workflow = Workflow(
195-
name="Weekly Meeting Setup",
196-
triggers=[trigger],
197-
jobs=[job],
198-
context={"participants": []}
195+
name="Weekly Meeting Setup",
196+
triggers=[trigger],
197+
jobs=[job],
198+
context={"participants": []}
199199
)
200200

201201
workflow.execute()
@@ -210,7 +210,7 @@ workflow:
210210
- type: "CronSchedule"
211211
cron: "0 9 * * MON" # Every Monday at 9 AM
212212
context:
213-
participants: []
213+
participants: [ ]
214214
jobs:
215215
- name: "Setup Meeting"
216216
steps:
@@ -226,12 +226,12 @@ workflow:
226226
227227
Manage state transitions using `FSMMixin`.
228228

229-
230229
```python
231230
import logging
232231
from enum import Enum, auto
233232
from dslmodel.mixins import FSMMixin, trigger
234233
234+
235235
class SalesState(Enum):
236236
INITIALIZING = auto()
237237
RESEARCHING = auto()
@@ -305,41 +305,18 @@ data_writer = DataWriter(data=data, file_path="output/data_output.csv")
305305
data_writer.forward()
306306
```
307307

308-
### Notebook Generation
309-
310-
Programmatically create and manage IPython notebooks.
311-
312-
```python
313-
from dslmodel.generators import IPythonNotebookGenerator
314-
315-
316-
# The generator is a DSLModel, so it can be used like any other DSLModel
317-
notebook_gen = IPythonNotebookGenerator()
318-
319-
# Add a markdown cell
320-
notebook_gen.add_markdown_cell(["# Welcome to DSLModel Notebook", "Demonstrating notebook generation."])
321-
322-
# Add a code cell
323-
notebook_gen.add_code_cell(["print('Hello, DSLModel!')"])
324-
325-
# Save the notebook
326-
notebook_gen.save("notebooks/demo_notebook.ipynb")
327-
```
328-
329308
## Architecture
330309

331310
### Core Components
332311

333312
- **DSLModel:** Core framework for declarative model creation using templates.
334313
- **Mixins:**
335-
- `ToolMixin`: Adds dynamic tool execution capabilities.
336-
- `FSMMixin`: Provides finite state machine functionality.
314+
- `ToolMixin`: Adds dynamic tool execution capabilities.
315+
- `FSMMixin`: Provides finite state machine functionality.
337316
- **Workflow Components:**
338-
- `Workflow`, `Job`, `Action`, `Condition`, `CronTrigger`: Orchestrate complex workflows.
317+
- `Workflow`, `Job`, `Action`, `Condition`, `CronTrigger`: Orchestrate complex workflows.
339318
- **Data Handling Utilities:**
340-
- `DataReader`, `DataWriter`: Handle data ingestion and output.
341-
- **Notebook Models:**
342-
- `IPythonNotebookGenerator`: Generate and manage IPython notebooks.
319+
- `DataReader`, `DataWriter`: Handle data ingestion and output.
343320

344321
### Data Flow
345322

@@ -386,7 +363,8 @@ Ensure test coverage is at least 90%.
386363

387364
### Contributing
388365

389-
Contributions are welcome! Please follow the [contribution guidelines](CONTRIBUTING.md) and adhere to the code of conduct.
366+
Contributions are welcome! Please follow the [contribution guidelines](CONTRIBUTING.md) and adhere to the code of
367+
conduct.
390368

391369
## Deployment
392370

@@ -410,4 +388,5 @@ Distributed under the MIT License. See [LICENSE](LICENSE) for more information.
410388

411389
---
412390

413-
By following this guide, you can effectively utilize DSLModel for declarative model creation, workflow management, data handling, state machine implementation, and AI-assisted development.
391+
By following this guide, you can effectively utilize DSLModel for declarative model creation, workflow management, data
392+
handling, state machine implementation, and AI-assisted development.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from pydantic import Field, validator, root_validator, EmailStr
2+
from typing import List, Optional
3+
from datetime import datetime
4+
from dslmodel import DSLModel
5+
6+
7+
class DSLModelClassTemplateSpecificationModel(DSLModel):
8+
"""A model for specifying the template of a DSLModel class, including its class name and description."""
9+
problem: str = Field(default=None, alias: "Problem", title="", description="A field to describe a problem or issue.")
10+
hypothesis: str = Field(default=None, alias: "Hypothesis", title="", description="A useful description for the Hypothesis field.")
11+
evidence: str = Field(default=None, alias: "Evidence", title="", description="A description of the evidence provided to support a claim or argument.")
12+
conclusion: str = Field(default=None, alias: "Conclusion", title="", description="A conclusion or summary of the main points.")
13+

dslmodel-slides/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
.DS_Store
3+
dist
4+
*.local
5+
.vite-inspect
6+
.remote-assets
7+
components.d.ts

dslmodel-slides/.npmrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# for pnpm
2+
shamefully-hoist=true
3+
auto-install-peers=true

dslmodel-slides/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Welcome to [Slidev](https://github.com/slidevjs/slidev)!
2+
3+
To start the slide show:
4+
5+
- `npm install`
6+
- `npm run dev`
7+
- visit <http://localhost:3030>
8+
9+
Edit the [slides.md](./slides.md) to see the changes.
10+
11+
Learn more about Slidev at the [documentation](https://sli.dev/).
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<script setup lang="ts">
2+
import { ref } from 'vue'
3+
4+
const props = defineProps({
5+
count: {
6+
default: 0,
7+
},
8+
})
9+
10+
const counter = ref(props.count)
11+
</script>
12+
13+
<template>
14+
<div flex="~" w="min" border="~ main rounded-md">
15+
<button
16+
border="r main"
17+
p="2"
18+
font="mono"
19+
outline="!none"
20+
hover:bg="gray-400 opacity-20"
21+
@click="counter -= 1"
22+
>
23+
-
24+
</button>
25+
<span m="auto" p="2">{{ counter }}</span>
26+
<button
27+
border="l main"
28+
p="2"
29+
font="mono"
30+
outline="!none"
31+
hover:bg="gray-400 opacity-20"
32+
@click="counter += 1"
33+
>
34+
+
35+
</button>
36+
</div>
37+
</template>

dslmodel-slides/netlify.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[build]
2+
publish = "dist"
3+
command = "npm run build"
4+
5+
[build.environment]
6+
NODE_VERSION = "20"
7+
8+
[[redirects]]
9+
from = "/.well-known/*"
10+
to = "/.well-known/:splat"
11+
status = 200
12+
13+
[[redirects]]
14+
from = "/*"
15+
to = "/index.html"
16+
status = 200

dslmodel-slides/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "dslmodel-slides",
3+
"type": "module",
4+
"private": true,
5+
"scripts": {
6+
"build": "slidev build",
7+
"dev": "slidev --open",
8+
"export": "slidev export"
9+
},
10+
"dependencies": {
11+
"@slidev/cli": "^0.50.0-beta.8",
12+
"@slidev/theme-default": "latest",
13+
"@slidev/theme-seriph": "latest",
14+
"vue": "^3.5.13"
15+
}
16+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Imported Slides
2+
3+
You can split your slides.md into multiple files and organize them as you want using the `src` attribute.
4+
5+
#### `slides.md`
6+
7+
```markdown
8+
# Page 1
9+
10+
Page 2 from main entry.
11+
12+
---
13+
14+
## src: ./subpage.md
15+
```
16+
17+
<br>
18+
19+
#### `subpage.md`
20+
21+
```markdown
22+
# Page 2
23+
24+
Page 2 from another file.
25+
```
26+
27+
[Learn more](https://sli.dev/guide/syntax.html#importing-slides)

0 commit comments

Comments
 (0)