{"id":19154311,"url":"https://github.com/baloise/kwansi_example","last_synced_at":"2026-06-15T11:30:19.002Z","repository":{"id":259426694,"uuid":"873471491","full_name":"baloise/kwansi_example","owner":"baloise","description":"An example implementation of the lordamp/kwansi wrapper for DSPy","archived":false,"fork":false,"pushed_at":"2024-10-16T11:28:53.000Z","size":61,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-01-03T19:26:23.041Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/baloise.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-16T08:21:02.000Z","updated_at":"2024-10-24T09:52:32.000Z","dependencies_parsed_at":"2024-10-25T09:32:23.366Z","dependency_job_id":null,"html_url":"https://github.com/baloise/kwansi_example","commit_stats":null,"previous_names":["baloise/kwansi_example"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baloise%2Fkwansi_example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baloise%2Fkwansi_example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baloise%2Fkwansi_example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baloise%2Fkwansi_example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/baloise","download_url":"https://codeload.github.com/baloise/kwansi_example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240238078,"owners_count":19769860,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T08:26:24.000Z","updated_at":"2026-06-15T11:30:18.947Z","avatar_url":"https://github.com/baloise.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kwansi Example Implementation\n\nThis repository contains an example implementation of Kwansi, a wrapper for [DSPy](https://dspy-docs.vercel.app/docs) that makes its optimizers easier to use. You can find Kwansi here: https://github.com/baloise/kwansi, which also includes a documentation about its core functions.\n\n## Overview\n\nThis example demonstrates how to use Kwansi to optimize a tweet creation task. It covers:\n- Setting up the environment\n- Preparing training data\n- Creating a task\n- Defining metrics\n- Running the optimizer\n- Testing the optimized model\n\n## Installation\n\n1. Clone this repository:\n   ```\n   git clone https://github.com/lordamp/kwansi-example.git\n   cd kwansi-example\n   ```\n\n2. Install the required packages:\n   ```\n   pip install -r requirements.txt\n   ```\n\n3. Set up your OpenAI API key in a `.env` file:\n   ```\n   OPENAI_API_KEY=your-api-key-here\n   ```\n\n## Usage\n\n1. Run the main script:\n   ```\n   python example_implementation.py\n   ```\n\n2. For a step-by-step walkthrough, see the [`example_implementation.ipynb`](https://github.com/baloise/kwansi_example/blob/main/example_implementation.ipynb) Jupyter notebook.\n\n## File Structure\n\n- `example_implementation.py`: The example implementation of Kwansi. Run this to execute the whole example.\n- `example_implementation.ipynb`: The step-by-step walkthrough of the example implementation as a Jupyter notebook.\n- `components/`: Custom task and evaluator definitions\n    - `task.py`: The task instructions we're trying to optimize\n    - `assessors.py`: The assessor evaluators used to evaluate the task (LLM-based evaluators)\n    - `metrics.py`: The metrics used to evaluate the task (binary metrics)\n    - `custom_combiner.py`: A custom combiner function for the evaluators\n- `data/`: Example data for the task\n    - `example_data.json`: The prepared data used for training the optimizer\n- `outputs/`: Directory for storing the compiled instructions (empty at the start)\n\n\n## Further Documentation\n\nFor more detailed information about Kwansi, please visit the [Kwansi documentation](https://github.com/lordamp/kwansi). If you want to learn more about the underlying DSPy framework, please visit the [DSPy documentation](https://dspy-docs.vercel.app/docs).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaloise%2Fkwansi_example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaloise%2Fkwansi_example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaloise%2Fkwansi_example/lists"}