Add QuestionThinking and clean up codebase#2403
Closed
johnjosephhorton wants to merge 52 commits intoadd_runner_to_edslfrom
Closed
Add QuestionThinking and clean up codebase#2403johnjosephhorton wants to merge 52 commits intoadd_runner_to_edslfrom
johnjosephhorton wants to merge 52 commits intoadd_runner_to_edslfrom
Conversation
…nfig Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Delete vibes subdirectories from surveys, results, dataset, scenarios, questions, and tests. Remove vibe-related methods (vibe_help, vibe_filter, vibe_plot, vibe_sql, vibe_analyze, from_vibes) and imports from the remaining codebase. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…nto add_runner_to_edsl
The widgets module (anywidget-based UI components) is no longer needed. Deletes the entire edsl/widgets/ directory and removes widget-dependent methods (help, inspect, view) from base_class, jobs, questions, results, and survey modules. Inlines widget short name validation in coop.py. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Break up the large Results class by moving scoring/weighting to extras/, extracting representation logic and transcript generation into separate modules, and simplifying the serializer and filter. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove conjure, reports, assistants, scenarioml, polly, sqlite_list, and textual_interactive_survey modules. Refactor buckets, results, questions, and related utilities. Update tests and dependencies. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The _db() and sql() methods on Dataset now use Python's built-in sqlite3 and csv modules instead of pandas and SQLAlchemy, removing two heavy dependencies from the SQL query path. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Rewrites SQLiteDict to use sqlite3 directly instead of SQLAlchemy ORM. Removes the orm.py model definitions (no longer needed). Updates Cache.close() to use the new SQLiteDict.close() instead of engine.dispose(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
sqlalchemy is no longer needed for core functionality (caching and sql() now use stdlib sqlite3). It remains available in the inference, runner, and full extras for the runner's PostgreSQL storage backend. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace all tabulate usage with a built-in _simple_table() function that supports grid, simple, pipe, and markdown formats - Remove restrictedpython (was not imported anywhere in edsl/) - Remove pydantic-settings (only used in legacy_extenions_code/) - Make sqlalchemy imports lazy in runner/__init__.py, service.py, and storage_hybrid.py so the runner module loads without it Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
black is only used for code formatting in survey export, py file handler, and coop upload. All three now gracefully degrade (skip formatting) when black isn't installed. setuptools was not imported anywhere at runtime (remains in build-system.requires). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Introduces DiGraph builder with pluggable rendering: - MermaidRenderer: text-based output, zero dependencies - PydotRenderer: PNG output via pydot/graphviz All three visualization modules (survey flow, job flow, composite macro) now use DiGraph and accept a renderer= parameter. pydot is moved from required to optional (in viz and full extras). When pydot is not installed, mermaid is used automatically. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
JupyterLab 4+ natively renders ```mermaid code blocks via _repr_markdown_(). Replace the script-injection approach in _repr_html_ with proper markdown output. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…de labels - Default graph renderer is now mermaid (zero dependencies) instead of pydot - Add ASCII tree renderer for terminal display (__repr__ and show()) - Survey flow nodes now show question type icon, name, and text preview Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When running in Jupyter, __repr__ now returns empty string since _repr_markdown_ already handles the rich mermaid display. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move `import openai` from module-level to first-use in service classes. Model(), Survey, and serialization all work without openai installed. The SDK is only imported when a client is actually created (i.e., at inference time). Move openai from required to optional in pyproject.toml (included in inference and full extras). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove results_weighting.py and results_weighting_strategies.py from edsl/results/extras - Fix agent_list_factories.from_scenario_list to handle agent_parameters (instruction, name) - Fix OpenAIService import path for lazy-loaded services - Fix show_flow doctest for new ASCII output - Update ModelList.table doctest for new bordered table format Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… dep - Add restrictedpython to required dependencies (fixes ModuleNotFoundError in CI) - Split dev dependencies into test group (pytest, coverage) and dev group (sphinx, mypy, linting) - CI test_suite.yml: use --without dev to skip sphinx/mypy/pylint (~15 packages) - CI build_package_source.yml: use --without dev,test to skip all non-core deps - Remove Graphviz apt-get install step from test CI (pydot renderer is optional) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
pydantic is imported at module level in edsl/questions/exceptions.py but was not listed as a required dependency, causing ModuleNotFoundError when installing from source. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- test_exports: add pytest.importorskip("pandas") since to_pandas() needs it
- test_notebooks: use importorskip for nbformat/nbconvert instead of bare imports
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Delete edsl/dataset/kl_divergence.py (depends on numpy, not needed) - Remove kl_divergence method from DatasetOperationsMixin - Allow test-starter-tutorial to pass when all tests are skipped (exit 5) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ataset.merge - Skip test_version_numbers on Python < 3.11 (tomllib not available) - Rewrite Dataset.merge as pure Python left join instead of using pandas Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
These methods depended on pandas internally and aren't needed. Removed: confusion_matrix, _confusion_matrix_rows, perplexity, true_positive_count, false_negative_count, percent_correctly_predicted, and DatasetNotConfusionMatrixError. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
These methods depended on python-docx (optional). Removed: _prepare_report_data, _report_markdown, _report_docx, report, and report_from_template from DatasetOperationsMixin. Updated references in output_formatter and referee_report example. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Skip doctests requiring pandas, docx, PIL (optional deps) - Remove unused fake_openai_call.py from language_models/unused - Fix SurveyExport.code doctest to not depend on exact output format - Exclude inference_services/services from doctest collection (SDK imports) - Remove pandas doctest from AgentList class docstring Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The lock file was out of sync with pyproject.toml, causing poetry install in CI to potentially miss dependencies like pydantic. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
Author
|
This is how it works: """Example: QuestionThinking in a pipeline with agent, summarizer, and verification."""
from edsl import QuestionThinking
from edsl import QuestionFreeText, QuestionYesNo, Agent, Survey, Model
# A verbose agent who gives detailed answers
agent = Agent(
traits={
"persona": "You are a history professor who gives detailed, "
"thorough answers with lots of context and examples."
}
)
model = Model("gpt-4o-mini")
# Step 1: Ask the agent a question (uses agent persona + survey model)
q1 = QuestionFreeText(
question_name="history",
question_text="Explain the causes and consequences of the French Revolution.",
)
# Step 2: Summarize with QuestionThinking (bypasses agent persona, uses its own model/system_prompt)
q2 = QuestionThinking(
question_name="summary",
question_text="Summarize the following text in 2 sentences: {{ history.answer }}",
model="gpt-4o-mini",
system_prompt="You are a concise summarizer. Output only the summary, nothing else.",
)
# Step 3: Ask the agent to verify the summary (uses agent persona again)
q3 = QuestionYesNo(
question_name="accurate",
question_text=(
"Original text: {{ history.answer }}\n\n"
"Summary: {{ summary.answer }}\n\n"
"Is this an accurate summary of the original text?"
),
)
# Build the survey with memory/piping dependencies
survey = Survey(questions=[q1, q2, q3])
results = survey.by(agent).by(model).run(disable_remote_inference=True)
print(results.select("answer.*").table())% Producing output: ┏━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ answer.accurate ┃ answer.history ┃ answer.summary ┃
┡━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ Yes │ The French Revolution, which began in 1789 and lasted until 1799, was a pivotal │ The French Revolution (1789-1799) marked the decline of absolute monarchy and the │
│ │ event in world history that marked the decline of absolute monarchy and the rise │ rise of republicanism due to social inequality, economic hardship, political │
│ │ of republicanism and democratic ideals. The causes and consequences of the French │ discontent, weak leadership, and immediate triggers like the Estates-General and │
│ │ Revolution are complex and interwoven, involving a mix of social, economic, │ the storming of the Bastille. Its consequences included the overthrow of the │
│ │ political, and intellectual factors. │ monarchy, the rise of radicalism and the Reign of Terror, significant social and │
│ │ │ political reforms, the emergence of Napoleon Bonaparte, and inspiration for future │
│ │ ### Causes of the French Revolution │ revolutionary movements worldwide. │
│ │ │ │
│ │ 1. **Social Inequality**: French society was divided into three estates. The First │ │
│ │ Estate consisted of the clergy, the Second Estate comprised the nobility, and the │ │
│ │ Third Estate included the common people, which made up about 98% of the │ │
│ │ population. The Third Estate bore the brunt of taxation while having little │ │
│ │ political power or representation, leading to widespread discontent. │ │
│ │ │ │
│ │ 2. **Economic Hardship**: By the late 18th century, France faced a severe │ │
│ │ financial crisis. The government was deeply in debt, partly due to its involvement │ │
│ │ in the American Revolution and extravagant spending by King Louis XVI and his │ │
│ │ court. Poor harvests in the late 1780s led to food shortages and rising bread │ │
│ │ prices, exacerbating the plight of the common people and stirring unrest. │ │
│ │ │ │
│ │ 3. **Political Discontent**: The absolute monarchy, characterized by the rule of │ │
│ │ King Louis XVI, faced growing criticism. Enlightenment thinkers like Voltaire, │ │
│ │ Rousseau, and Montesquieu challenged traditional authority and advocated for │ │
│ │ liberty, equality, and fraternity. Their ideas inspired the educated bourgeoisie │ │
│ │ (the middle class) to seek more political power and reform. │ │
│ │ │ │
│ │ 4. **Weak Leadership**: King Louis XVI was seen as indecisive and ineffective. His │ │
│ │ inability to address the financial crisis and respond to the demands of the │ │
│ │ populace led to a loss of confidence in the monarchy. The calling of the │ │
│ │ Estates-General in 1789, the first such assembly since 1614, was an attempt to │ │
│ │ address the crisis but ultimately led to the Third Estate asserting its power. │ │
│ │ │ │
│ │ 5. **Immediate Triggers**: The immediate catalyst for the revolution was the │ │
│ │ convening of the Estates-General in May 1789, followed by the formation of the │ │
│ │ National Assembly by the Third Estate in June. The Tennis Court Oath, where │ │
│ │ members vowed not to disband until a new constitution was established, marked a │ │
│ │ significant turning point. The storming of the Bastille on July 14, 1789, │ │
│ │ symbolized the uprising against tyranny and is often regarded as the revolution's │ │
│ │ start. │ │
│ │ │ │
│ │ ### Consequences of the French Revolution │ │
│ │ │ │
│ │ 1. **End of Monarchical Rule**: The revolution led to the overthrow of King Louis │ │
│ │ XVI and the establishment of a republic. In 1793, Louis XVI was executed by │ │
│ │ guillotine, marking a definitive end to centuries of absolute monarchy in France. │ │
│ │ │ │
│ │ 2. **Rise of Radicalism and the Reign of Terror**: The revolution gave rise to │ │
│ │ radical factions, most notably the Jacobins, who implemented the Reign of Terror │ │
│ │ (1793-1794) under leaders like Maximilien Robespierre. Thousands were executed, │ │
│ │ including many perceived enemies of the revolution, leading to a climate of fear │ │
│ │ and repression. │ │
│ │ │ │
│ │ 3. **Social and Political Reforms**: The revolution brought about significant │ │
│ │ social changes, including the abolition of feudal privileges, the establishment of │ │
│ │ secularism, and the promotion of civil rights. The Declaration of the Rights of │ │
│ │ Man and of the Citizen (1789) laid the groundwork for modern human rights. │ │
│ │ │ │
│ │ 4. **Rise of Napoleon Bonaparte**: The instability following the revolution │ │
│ │ eventually led to the rise of Napoleon Bonaparte, who established himself as │ │
│ │ Emperor of the French in 1804. His rule spread revolutionary ideals across Europe, │ │
│ │ but also led to authoritarian governance. │ │
│ │ │ │
│ │ 5. **Inspiration for Future Revolutions**: The French Revolution had a profound │ │
│ │ impact beyond France, inspiring revolutionary movements around the world, │ │
│ │ including in Latin America, Haiti, and later in Europe during the 19th century. It │ │
│ │ demonstrated the power of popular movements and the potential for change, │ │
│ │ influencing the development of modern democratic and nationalistic movements. │ │
└─────────────────┴────────────────────────────────────────────────────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────────────────┘ |
Collaborator
Author
|
@onmyraedar we will eventually have to add this to humanize - the QuestionThinking isn't displayed to the user but is instead a computation step between presentation. |
Collaborator
Author
|
Closing this because I cherry-picked the QuestionThinking into a different branch |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
QuestionThinkingquestion type for chain-of-thought reasoningTest plan
QuestionThinkingworks end-to-end with a modelpytest tests/)🤖 Generated with Claude Code