Skip to content

Instantly share code, notes, and snippets.

View fsndzomga's full-sized avatar

Franck Stéphane Ndzomga fsndzomga

View GitHub Profile
from pydantic import BaseModel, Field
from typing import Optional
import dspy
from dspy.experimental import SyntheticDataGenerator
llm = dspy.OpenAI(model='gpt-3.5-turbo',api_key=openai_key)
dspy.settings.configure(lm=llm)
class RPGPlayer(BaseModel):
import dspy
from dspy.experimental import SyntheticDataGenerator
from pydantic import BaseModel, Field
llm = dspy.OpenAI(model='gpt-3.5-turbo',api_key=openai_key)
dspy.settings.configure(lm=llm)
class SyntheticFacts(BaseModel):
fact: str = Field(..., description="a statement")
from pydantic import BaseModel
import dspy
import random
def synthetic_data_generation(schema_class: BaseModel, sample_size: int):
class_name = f"{schema_class.__name__}Signature"
# Fetch schema information
data_schema = schema_class.model_json_schema()
properties = data_schema['properties']
# Synthetic Prompt Optimization
from dspy.teleprompt import BootstrapFewShot
from dspy.evaluate import answer_exact_match
text = "Barack Obama was not President of the USA"
# define the fact as input to the lie detector
trainset = [x.with_inputs('fact') for x in few_shot_examples]
# define the signature to be used in by the lie detector module
# Synthetic data generation using DSPy
from typing import List
import dspy
llm = dspy.OpenAI(model='gpt-3.5-turbo',api_key=openai_key)
dspy.settings.configure(lm=llm)
class FactGeneration(dspy.Signature):
"""Generate facts and their veracity"""
# Synthetic data generation using DSPy
from typing import List
import dspy
llm = dspy.OpenAI(model='gpt-3.5-turbo',api_key=openai_key)
dspy.settings.configure(lm=llm)
class FactGeneration(dspy.Signature):
"""Generate facts and their veracity, it should be different than old data"""
import requests
import yfinance as yf
from yahooquery import Ticker
import warnings
# Ignore all warnings
warnings.filterwarnings('ignore')
import dspy
llm = dspy.OpenAI(model='gpt-3.5-turbo',api_key=openai_key)
dspy.settings.configure(lm=llm)
# Implementation of a lie detector without optimization
text = "Barack Obama was not President of the USA"
import streamlit as st
import pandas as pd
from data_generation import generate_dataset, generate_parts_of_dataset
# Sidebar with company logo and use case navigation
# Use Markdown to increase font size for the title
st.sidebar.markdown("""
<style>
.big-font {
font-size:20px !important;
import pandas as pd
from dotenv import load_dotenv
from pydantic import BaseModel, create_model
from typing import List, Any, Type
from anonLLM.llm import OpenaiLanguageModel
load_dotenv()
llm = OpenaiLanguageModel(anonymize=False, temperature=1)