-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1dccc85
commit ec10e53
Showing
40 changed files
with
377 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" | |
|
||
[tool.poetry] # https://python-poetry.org/docs/pyproject/ | ||
name = "dspygen" | ||
version = "2024.4.10.2" | ||
version = "2024.4.11" | ||
description = "A Ruby on Rails style framework for the DSPy (Demonstrate, Search, Predict) project for Language Models like GPT, BERT, and LLama." | ||
authors = ["Sean Chatman <[email protected]>"] | ||
readme = "README.md" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# pep8_python_source_code.py | ||
|
||
class KeywordDiscovery: | ||
"""AI-powered keyword discovery module.""" | ||
def __init__(self, data_source): | ||
self.data_source = data_source | ||
|
||
def discover_keywords(self): | ||
"""Generate a list of potential profitable keywords.""" | ||
pass | ||
|
||
class ContentGenerator: | ||
"""Content generation system using AI.""" | ||
def __init__(self): | ||
pass | ||
|
||
def generate_content(self, keywords): | ||
"""Generate ad content optimized for click-through rates and conversions.""" | ||
pass | ||
|
||
class CampaignManager: | ||
"""Manage and track PPC campaigns.""" | ||
def __init__(self): | ||
pass | ||
|
||
def create_campaign(self, content): | ||
"""Set up and track PPC campaigns.""" | ||
pass | ||
|
||
def monitor_performance(self): | ||
"""Monitor and optimize campaign performance.""" | ||
pass | ||
|
||
class FinancialManager: | ||
"""Handle revenue tracking and automate revenue deposits.""" | ||
def __init__(self, bank_account): | ||
self.bank_account = bank_account | ||
|
||
def track_revenue(self): | ||
"""Monitor revenue generated.""" | ||
pass | ||
|
||
def deposit_revenue(self): | ||
"""Automate revenue deposits.""" | ||
pass | ||
|
||
class Dashboard: | ||
"""User-friendly dashboard for real-time insights.""" | ||
def __init__(self, campaign_manager, financial_manager): | ||
self.campaign_manager = campaign_manager | ||
self.financial_manager = financial_manager | ||
|
||
def display_insights(self): | ||
"""Display real-time insights.""" | ||
pass | ||
|
||
def main(): | ||
# Initialize required components | ||
data_source = "ExampleDataSource" | ||
bank_account = "123456789" | ||
revenue_system = RevenueGenerationSystem(data_source, bank_account) | ||
revenue_system.start() | ||
|
||
class RevenueGenerationSystem: | ||
"""Main revenue generation system.""" | ||
def __init__(self, data_source, bank_account): | ||
self.data_source = data_source | ||
self.bank_account = bank_account | ||
self.keywords = None | ||
self.content = None | ||
self.campaign = None | ||
|
||
def discover_keywords(self): | ||
"""Discover keywords for the AI-powered keyword discovery.""" | ||
self.keywords = KeywordDiscovery(self.data_source).discover_keywords() | ||
|
||
def generate_content(self): | ||
"""Generate content for the AI-powered content generator.""" | ||
self.content = ContentGenerator().generate_content(self.keywords) | ||
|
||
def create_campaign(self): | ||
"""Create a campaign for the campaign manager.""" | ||
self.campaign = CampaignManager().create_campaign(self.content) | ||
|
||
def monitor_performance(self): | ||
"""Monitor performance using the campaign manager and dashboard.""" | ||
CampaignManager().monitor_performance(self.campaign) | ||
Dashboard(CampaignManager(), FinancialManager(self.bank_account)).display_insights() | ||
|
||
def start(self): | ||
"""Start the revenue generation system.""" | ||
self.discover_keywords() | ||
self.generate_content() | ||
self.create_campaign() | ||
self.monitor_performance() | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
# Define the base directory for the POC | ||
baseDir="tagee" | ||
|
||
# Create the directory structure | ||
mkdir -p "$baseDir"/{docs,src/{core,ui/modules,ui/data,ui/utils},tests/{unit,integration},assets/{images,sounds},lib,scripts,config} | ||
|
||
# Create documentation files | ||
touch "$baseDir"/docs/{GettingStarted.md,CurriculumAlignment.md,TechnicalOverview.md} | ||
|
||
# Create source files | ||
# Core engine files | ||
touch "$baseDir"/src/core/{game_engine.py,narrative_engine.py,education_module.py} | ||
|
||
# UI component files | ||
touch "$baseDir"/src/ui/modules/{story_view.py,quiz_view.py,chatbot_view.py} | ||
touch "$baseDir"/src/ui/data/{story_data.py,quiz_data.py,chatbot_data.py} | ||
touch "$baseDir"/src/ui/utils/{ui_helpers.py,formatting_tools.py} | ||
|
||
# Test files | ||
touch "$baseDir"/tests/unit/{game_engine_test.py,narrative_engine_test.py,education_module_test.py} | ||
touch "$baseDir"/tests/integration/{story_integration_test.py,quiz_integration_test.py,chatbot_integration_test.py} | ||
|
||
# Asset placeholders | ||
touch "$baseDir"/assets/images/.keep | ||
touch "$baseDir"/assets/sounds/.keep | ||
|
||
# Library placeholder | ||
touch "$baseDir"/lib/.keep | ||
|
||
# Script files | ||
touch "$baseDir"/scripts/{setup.sh,deploy.sh,maintenance.sh} | ||
|
||
# Configuration files | ||
touch "$baseDir"/config/{dev.json,prod.json,test.json} | ||
|
||
# Root files | ||
touch "$baseDir"/{README.md,LICENSE,.gitignore} | ||
|
||
echo "TAG-EE POC directory and file structure created." |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
""" | ||
""" | ||
import dspy | ||
from dspygen.utils.dspy_tools import init_dspy | ||
|
||
|
||
class ExamPointWeightModule(dspy.Module): | ||
"""ExamPointWeightModule""" | ||
|
||
def __init__(self, **forward_args): | ||
super().__init__() | ||
self.forward_args = forward_args | ||
self.output = None | ||
|
||
def __or__(self, other): | ||
if other.output is None and self.output is None: | ||
self.forward(**self.forward_args) | ||
|
||
other.pipe(self.output) | ||
|
||
return other | ||
|
||
def forward(self, student_question): | ||
pred = dspy.Predict("student_question -> exam_score") | ||
self.output = pred(student_question=student_question).exam_score | ||
return self.output | ||
|
||
def pipe(self, input_str): | ||
raise NotImplementedError("Please implement the pipe method for DSL support.") | ||
# Replace TODO with a keyword from you forward method | ||
# return self.forward(TODO=input_str) | ||
|
||
|
||
from typer import Typer | ||
app = Typer() | ||
|
||
|
||
@app.command() | ||
def call(student_question): | ||
"""ExamPointWeightModule""" | ||
init_dspy() | ||
|
||
print(exam_point_weight_call(student_question=student_question)) | ||
|
||
|
||
|
||
def exam_point_weight_call(student_question): | ||
exam_point_weight = ExamPointWeightModule() | ||
return exam_point_weight.forward(student_question=student_question) | ||
|
||
|
||
|
||
def main(): | ||
init_dspy() | ||
student_question = "" | ||
print(exam_point_weight_call(student_question=student_question)) | ||
|
||
|
||
|
||
from fastapi import APIRouter | ||
router = APIRouter() | ||
|
||
@router.post("/exam_point_weight/") | ||
async def exam_point_weight_route(data: dict): | ||
# Your code generation logic here | ||
init_dspy() | ||
|
||
print(data) | ||
return exam_point_weight_call(**data) | ||
|
||
|
||
|
||
""" | ||
import streamlit as st | ||
# Streamlit form and display | ||
st.title("ExamPointWeightModule Generator") | ||
student_question = st.text_input("Enter student_question") | ||
if st.button("Submit ExamPointWeightModule"): | ||
init_dspy() | ||
result = exam_point_weight_call(student_question=student_question) | ||
st.write(result) | ||
""" | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import json | ||
from pathlib import Path | ||
from typing import TypeVar, Generic, Type, List, Optional | ||
|
||
from pydantic import BaseModel | ||
|
||
T = TypeVar('T', bound=BaseModel) | ||
|
||
|
||
class BaseRepository(Generic[T]): | ||
def __init__(self, model: Type[T], storage_file: Path): | ||
self.model = model | ||
self.storage_file = storage_file | ||
self.storage_file.touch(exist_ok=True) # Ensure file exists | ||
|
||
def _read_data(self) -> List[T]: | ||
"""Reads and returns all model instances from the storage file.""" | ||
try: | ||
with self.storage_file.open('r', encoding='utf-8') as file: | ||
data = json.load(file) | ||
return [self.model.parse_obj(item) for item in data] | ||
except (json.JSONDecodeError, FileNotFoundError): | ||
return [] | ||
|
||
def _write_data(self, data: List[T]) -> None: | ||
"""Writes the provided list of model instances to the storage file.""" | ||
with self.storage_file.open('w', encoding='utf-8') as file: | ||
json.dump([item.dict() for item in data], file, indent=4) | ||
|
||
def add(self, item: T) -> None: | ||
"""Adds a new model instance to the storage.""" | ||
items = self._read_data() | ||
items.append(item) | ||
self._write_data(items) | ||
|
||
def get(self, **criteria) -> Optional[T]: | ||
"""Retrieves a single model instance that matches the provided criteria.""" | ||
items = self._read_data() | ||
for item in items: | ||
if all(getattr(item, field) == value for field, value in criteria.items()): | ||
return item | ||
return None | ||
|
||
def remove(self, **criteria) -> bool: | ||
"""Removes model instances that match the provided criteria.""" | ||
items = self._read_data() | ||
items_before = len(items) | ||
items = [item for item in items if not all(getattr(item, field) == value for field, value in criteria.items())] | ||
self._write_data(items) | ||
return len(items) < items_before | ||
|
||
def update(self, item: T) -> None: | ||
"""Updates a model instance in the storage.""" | ||
items = self._read_data() | ||
for i, existing_item in enumerate(items): | ||
if existing_item.id == item.id: # Assuming each model has a unique 'id' field | ||
items[i] = item | ||
break | ||
self._write_data(items) | ||
|
||
def save(self, item: T) -> None: | ||
"""Updates a model instance if it exists, otherwise inserts it.""" | ||
items = self._read_data() | ||
for i, existing_item in enumerate(items): | ||
if existing_item.id == item.id: # Assuming each model has a unique 'id' field | ||
items[i] = item | ||
self._write_data(items) | ||
return | ||
self.add(item) | ||
|
||
def list_all(self) -> List[T]: | ||
"""Returns a list of all model instances.""" | ||
return self._read_data() | ||
|
||
|
||
def main(): | ||
"""Main function""" | ||
# Conversation Learnng Through Dialog Repository | ||
|
||
class ConversationRepository(BaseRepository[Conversation]): | ||
def __init__(self, storage_file: Path): | ||
super().__init__(Conversation, storage_file) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.