Skip to content

Instantly share code, notes, and snippets.

View inayet's full-sized avatar
💭
Active

Inayet Hadi inayet

💭
Active
View GitHub Profile
@inayet
inayet / gen_cli.py
Created February 13, 2024 15:39 — forked from seanchatmangpt/gen_cli.py
Draft of DSPy CLI
import dsp
import pathlib
import typer
from typetemp.functional import render
import dspy
from utils.create_prompts import create_pydantic_class
@inayet
inayet / gen_pydantic_instance.py
Created February 13, 2024 15:39 — forked from seanchatmangpt/gen_pydantic_instance.py
Generating Signature classes
import ast
import logging
import inspect
from typing import Type, TypeVar
from dspy import Assert, Module, ChainOfThought, Signature, InputField, OutputField
from pydantic import BaseModel, ValidationError
logger = logging.getLogger(__name__)
logger.setLevel(logging.ERROR)
@inayet
inayet / chatgpt_conversation_parser.py
Created February 13, 2024 15:39 — forked from seanchatmangpt/chatgpt_conversation_parser.py
Search through your ChatGPT history
import ijson
import tiktoken
# Define the path to your large JSON file
json_file_path = "/Users/candacechatman/dev/rdddy/data/conversations.json"
from pydantic import BaseModel, Field, ValidationError
from typing import List, Optional, Any
@inayet
inayet / chatgpt_conversation_parser.py
Created February 13, 2024 15:39 — forked from seanchatmangpt/chatgpt_conversation_parser.py
ChatGPT log parser with Pydantic Models
import ijson
import tiktoken
# Define the path to your large JSON file
json_file_path = "/Users/candacechatman/dev/rdddy/data/conversations.json"
from pydantic import BaseModel, Field, ValidationError
from typing import List, Optional, Any
@inayet
inayet / test_gen_pydantic_instance.py
Created February 13, 2024 15:39 — forked from seanchatmangpt/test_gen_pydantic_instance.py
Unit tests for generating a pydantic instance
from rdddy.generators.gen_pydantic_instance import (
GenPydanticInstance,
)
import pytest
from unittest.mock import patch, MagicMock
from dspy import settings, OpenAI, DSPyAssertionError
from typing import Dict, Any, Optional
from pydantic import BaseModel, Field, ValidationError
@inayet
inayet / gen_pydantic_instance.py
Created February 13, 2024 15:39 — forked from seanchatmangpt/gen_pydantic_instance.py
Create a pydantic instance from a class
import ast
import logging
import inspect
from typing import Type, TypeVar
from dspy import Assert, Module, ChainOfThought, Signature, InputField, OutputField
from pydantic import BaseModel, ValidationError
logger = logging.getLogger(__name__)
logger.setLevel(logging.ERROR)
@inayet
inayet / VAVAILABILITYModel.py
Created February 13, 2024 15:39 — forked from seanchatmangpt/VAVAILABILITYModel.py
Just created 7 icalendar models in one function
from pydantic import BaseModel, Field, validator, root_validator, EmailStr, UrlStr
from typing import List, Optional
from datetime import datetime
class VAVAILABILITYModel(BaseModel):
"""A Pydantic model for RFC 5545 compliance."""
dtstart: datetime = Field(default=None, title="", description="The start date and time of the event.", required)
dtend: datetime = Field(default=None, title="", description="The end date and time of the event.", required)
summary: str = Field(default=None, title="", description="A brief summary or title of the event.", max_length=255)
@inayet
inayet / contact_model.py
Created February 13, 2024 15:39 — forked from seanchatmangpt/contact_model.py
Generate a pydantic class from a prompt
from datetime import datetime
from pydantic import BaseModel, Field, validator, root_validator, EmailStr, UrlStr
class ContactModel(BaseModel):
"""A Pydantic model representing a contact in the friend of a friend ontology."""
name: str = Field(default=None, title="", description="The name of the contact.", min_length=2, max_length=50)
email: EmailStr = Field(default=None, title="", description="The email address of the contact.", min_length=5, max_length=50)
phone_number: str = Field(default=None, title="", description="The phone number of the contact.", min_length=10, max_length=15)
address: str = Field(default=None, title="", description="The address of the contact.", min_length=10, max_length=100)
@inayet
inayet / signature_factory.py
Created February 13, 2024 15:39 — forked from seanchatmangpt/signature_factory.py
Create Signature classes at runtime.
import dspy
from dspy import Signature
from dspy.signatures.field import InputField, OutputField
from pydantic import BaseModel, Field
from rdddy.generators.gen_pydantic_instance import GenPydanticInstance
class InputFieldModel(BaseModel):
@inayet
inayet / gen_pydantic_instance.py
Created February 13, 2024 15:39 — forked from seanchatmangpt/gen_pydantic_instance.py
Convert your prompt into a pydantic instance.
import ast
import logging
import inspect
from typing import Type, TypeVar
from dspy import Assert, Module, ChainOfThought, Signature, InputField, OutputField
from pydantic import BaseModel, ValidationError
logger = logging.getLogger(__name__)
logger.setLevel(logging.ERROR)