Spaces:
Paused
Paused
Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +36 -0
- external/TinyTroupe/.env.example +11 -0
- external/TinyTroupe/.gitattributes +1 -0
- external/TinyTroupe/.github/copilot-instructions.md +80 -0
- external/TinyTroupe/.github/project-copilot-instructions.md +15 -0
- external/TinyTroupe/.github/prompts/improve.prompt.md +16 -0
- external/TinyTroupe/.github/prompts/open-ended_ideas.prompt.md +15 -0
- external/TinyTroupe/.github/prompts/write_tests.prompt.md +11 -0
- external/TinyTroupe/.github/workflows/bandit.yml +52 -0
- external/TinyTroupe/.github/workflows/codeql.yml +92 -0
- external/TinyTroupe/.gitignore +175 -0
- external/TinyTroupe/CODE_OF_CONDUCT.md +9 -0
- external/TinyTroupe/LICENSE +21 -0
- external/TinyTroupe/MANIFEST.in +4 -0
- external/TinyTroupe/README.md +637 -0
- external/TinyTroupe/RESPONSIBLE_AI_FAQ.md +57 -0
- external/TinyTroupe/SECURITY.md +41 -0
- external/TinyTroupe/SUPPORT.md +14 -0
- external/TinyTroupe/build_and_install_package_from_repo.bat +3 -0
- external/TinyTroupe/build_package.bat +2 -0
- external/TinyTroupe/data/empirical/07.19.2025 - Market Research - Bottled Gazpacho - Raw Data.csv +53 -0
- external/TinyTroupe/data/extractions/appartment_rent_ad.extraction.json +8 -0
- external/TinyTroupe/data/extractions/appartment_rent_ad_1.extraction.json +71 -0
- external/TinyTroupe/data/extractions/synthetic_data_generation.out.csv +12 -0
- external/TinyTroupe/data/extractions/wordprocessor/Document/Lisa Carter - Resume.Lisa Carter.docx +0 -0
- external/TinyTroupe/data/extractions/wordprocessor/Document/Lisa Carter - Resume.Lisa Carter.json +5 -0
- external/TinyTroupe/data/extractions/wordprocessor/Document/Lisa Carter - Resume.Lisa Carter.md +168 -0
- external/TinyTroupe/data/extractions/wordprocessor/Document/Resume of Lisa Carter.Lisa Carter.docx +0 -0
- external/TinyTroupe/data/extractions/wordprocessor/Document/Resume of Lisa Carter.Lisa Carter.json +5 -0
- external/TinyTroupe/data/extractions/wordprocessor/Document/Resume of Lisa Carter.Lisa Carter.md +102 -0
- external/TinyTroupe/data/extractions/wordprocessor/Document/Resume of Lisa.Lisa.docx +3 -0
- external/TinyTroupe/data/extractions/wordprocessor/Document/Resume of Lisa.Lisa.json +5 -0
- external/TinyTroupe/data/extractions/wordprocessor/Document/Resume of Lisa.Lisa.md +100 -0
- external/TinyTroupe/data/extractions/wordprocessor/Document/Resume.Lisa.docx +3 -0
- external/TinyTroupe/data/facts/business-facts.synthetic.txt +500 -0
- external/TinyTroupe/data/grounding_examples/finance/Nubank (NU) - 3Q24 Earnings Release.pdf +3 -0
- external/TinyTroupe/data/grounding_examples/finance/Vale do Rio Doce (VALE 3) - Transcript Vale’s 3Q24 Conference Call.pdf +3 -0
- external/TinyTroupe/data/grounding_examples/finance/Vale do Rio Doce (VALE 3) - Vale's Performance in 3Q24.pdf +3 -0
- external/TinyTroupe/data/grounding_examples/general/World Bank Annual Report 2024.pdf +3 -0
- external/TinyTroupe/data/grounding_examples/grounding_examples_1/don_quijote_project_gutenberg.txt +0 -0
- external/TinyTroupe/data/grounding_examples/grounding_examples_1/marus_aurelius_meditations_by_project_gutenberg.txt +0 -0
- external/TinyTroupe/data/grounding_examples/grounding_microsoft/2023_Microsoft_Annual_Report-LAPTOP-MGL2VFEC.pdf +3 -0
- external/TinyTroupe/data/grounding_examples/grounding_microsoft/2023_Microsoft_Annual_Report.docx +3 -0
- external/TinyTroupe/data/grounding_examples/grounding_microsoft/2023_Microsoft_Annual_Report.pdf +3 -0
- external/TinyTroupe/data/grounding_examples/grounding_microsoft/2024_Annual_Report.docx +3 -0
- external/TinyTroupe/data/grounding_examples/grounding_microsoft/2024_Annual_Report.pdf +3 -0
- external/TinyTroupe/docs/api/tinytroupe/agent/action_generator.html +1365 -0
- external/TinyTroupe/docs/api/tinytroupe/agent/grounding.html +1383 -0
- external/TinyTroupe/docs/api/tinytroupe/agent/index.html +0 -0
- external/TinyTroupe/docs/api/tinytroupe/agent/memory.html +0 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,39 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
external/TinyTroupe/data/extractions/wordprocessor/Document/Resume[[:space:]]of[[:space:]]Lisa.Lisa.docx filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
external/TinyTroupe/data/extractions/wordprocessor/Document/Resume.Lisa.docx filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
external/TinyTroupe/data/grounding_examples/finance/Nubank[[:space:]](NU)[[:space:]]-[[:space:]]3Q24[[:space:]]Earnings[[:space:]]Release.pdf filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
external/TinyTroupe/data/grounding_examples/finance/Vale[[:space:]]do[[:space:]]Rio[[:space:]]Doce[[:space:]](VALE[[:space:]]3)[[:space:]]-[[:space:]]Transcript[[:space:]]Vale’s[[:space:]]3Q24[[:space:]]Conference[[:space:]]Call.pdf filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
external/TinyTroupe/data/grounding_examples/finance/Vale[[:space:]]do[[:space:]]Rio[[:space:]]Doce[[:space:]](VALE[[:space:]]3)[[:space:]]-[[:space:]]Vale's[[:space:]]Performance[[:space:]]in[[:space:]]3Q24.pdf filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
external/TinyTroupe/data/grounding_examples/general/World[[:space:]]Bank[[:space:]]Annual[[:space:]]Report[[:space:]]2024.pdf filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
external/TinyTroupe/data/grounding_examples/grounding_microsoft/2023_Microsoft_Annual_Report-LAPTOP-MGL2VFEC.pdf filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
external/TinyTroupe/data/grounding_examples/grounding_microsoft/2023_Microsoft_Annual_Report.docx filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
external/TinyTroupe/data/grounding_examples/grounding_microsoft/2023_Microsoft_Annual_Report.pdf filter=lfs diff=lfs merge=lfs -text
|
| 45 |
+
external/TinyTroupe/data/grounding_examples/grounding_microsoft/2024_Annual_Report.docx filter=lfs diff=lfs merge=lfs -text
|
| 46 |
+
external/TinyTroupe/data/grounding_examples/grounding_microsoft/2024_Annual_Report.pdf filter=lfs diff=lfs merge=lfs -text
|
| 47 |
+
external/TinyTroupe/examples/images/spanish_bottled_gazpacho.jpg filter=lfs diff=lfs merge=lfs -text
|
| 48 |
+
external/TinyTroupe/publications/paper_artifacts_june-2025/Brainstorming[[:space:]]and[[:space:]]Focus[[:space:]]Group[[:space:]]Quantitative[[:space:]]Experimentation[[:space:]]2.1[[:space:]]-[[:space:]]treatment[[:space:]]run.ipynb filter=lfs diff=lfs merge=lfs -text
|
| 49 |
+
external/TinyTroupe/publications/paper_artifacts_june-2025/Brainstorming[[:space:]]and[[:space:]]Focus[[:space:]]Group[[:space:]]Quantitative[[:space:]]Experimentation[[:space:]]2.2[[:space:]]-[[:space:]]treatment[[:space:]]run.ipynb filter=lfs diff=lfs merge=lfs -text
|
| 50 |
+
external/TinyTroupe/publications/paper_artifacts_june-2025/Debating[[:space:]]Quantitative[[:space:]]Experimentation[[:space:]]1[[:space:]]-[[:space:]]treatment[[:space:]]run.ipynb filter=lfs diff=lfs merge=lfs -text
|
| 51 |
+
external/TinyTroupe/publications/paper_artifacts_june-2025/Populations[[:space:]]creation.ipynb filter=lfs diff=lfs merge=lfs -text
|
| 52 |
+
external/TinyTroupe/publications/paper_artifacts_june-2025/extractions/synthetic_data_example_1/Document/Report[[:space:]]for[[:space:]]AquaPure[[:space:]]Solutions-[[:space:]]Strategies[[:space:]]for[[:space:]]Modernizing[[:space:]]Water[[:space:]]Purification[[:space:]]Systems.Lisa[[:space:]]Carter.docx filter=lfs diff=lfs merge=lfs -text
|
| 53 |
+
external/TinyTroupe/publications/paper_artifacts_june-2025/extractions/synthetic_data_example_1/Document/Report[[:space:]]for[[:space:]]BioSphere[[:space:]]Innovations-[[:space:]]Feasibility[[:space:]]Study[[:space:]]for[[:space:]]Waste-to-Energy[[:space:]]Solution.Lisa[[:space:]]Carter.docx filter=lfs diff=lfs merge=lfs -text
|
| 54 |
+
external/TinyTroupe/publications/paper_artifacts_june-2025/extractions/synthetic_data_example_1/Document/Report[[:space:]]for[[:space:]]BrightPath[[:space:]]Industries-[[:space:]]Strategies[[:space:]]for[[:space:]]Enhancing[[:space:]]Supply[[:space:]]Chain[[:space:]]Resilience.Lisa[[:space:]]Carter.docx filter=lfs diff=lfs merge=lfs -text
|
| 55 |
+
external/TinyTroupe/publications/paper_artifacts_june-2025/extractions/synthetic_data_example_1/Document/Report[[:space:]]for[[:space:]]CleanFuture[[:space:]]Corp-[[:space:]]Strategies[[:space:]]for[[:space:]]Reshaping[[:space:]]Public[[:space:]]Image[[:space:]]and[[:space:]]Sustainability[[:space:]]Practices.Lisa[[:space:]]Carter.docx filter=lfs diff=lfs merge=lfs -text
|
| 56 |
+
external/TinyTroupe/publications/paper_artifacts_june-2025/extractions/synthetic_data_example_1/Document/Report[[:space:]]for[[:space:]]EcoFuture[[:space:]]Enterprises-[[:space:]]Strategies[[:space:]]for[[:space:]]Sourcing[[:space:]]Sustainable[[:space:]]Materials.Lisa[[:space:]]Carter.docx filter=lfs diff=lfs merge=lfs -text
|
| 57 |
+
external/TinyTroupe/publications/paper_artifacts_june-2025/extractions/synthetic_data_example_1/Document/Report[[:space:]]for[[:space:]]EcoTech[[:space:]]Solutions-[[:space:]]Strategies[[:space:]]for[[:space:]]Enhancing[[:space:]]Product[[:space:]]Appeal[[:space:]]and[[:space:]]Market[[:space:]]Presence.Lisa[[:space:]]Carter.docx filter=lfs diff=lfs merge=lfs -text
|
| 58 |
+
external/TinyTroupe/publications/paper_artifacts_june-2025/extractions/synthetic_data_example_1/Document/Report[[:space:]]for[[:space:]]GreenWave[[:space:]]Innovations-[[:space:]]Strategies[[:space:]]for[[:space:]]Reducing[[:space:]]Waste[[:space:]]and[[:space:]]Enhancing[[:space:]]Sustainability.Lisa[[:space:]]Carter.docx filter=lfs diff=lfs merge=lfs -text
|
| 59 |
+
external/TinyTroupe/publications/paper_artifacts_june-2025/extractions/synthetic_data_example_1/Document/Report[[:space:]]for[[:space:]]MultiLever-[[:space:]]Strategies[[:space:]]for[[:space:]]Addressing[[:space:]]Inflation[[:space:]]and[[:space:]]Enhancing[[:space:]]Consumer[[:space:]]Demand.Lisa[[:space:]]Carter.docx filter=lfs diff=lfs merge=lfs -text
|
| 60 |
+
external/TinyTroupe/publications/paper_artifacts_june-2025/extractions/synthetic_data_example_1/Document/Report[[:space:]]for[[:space:]]SolarWave[[:space:]]Technologies-[[:space:]]Strategies[[:space:]]for[[:space:]]Securing[[:space:]]Funding[[:space:]]for[[:space:]]Solar[[:space:]]Panel[[:space:]]Project.Lisa[[:space:]]Carter.docx filter=lfs diff=lfs merge=lfs -text
|
| 61 |
+
external/TinyTroupe/publications/paper_artifacts_june-2025/extractions/synthetic_data_example_1/Document/Report[[:space:]]for[[:space:]]TerraBuild-[[:space:]]Strategies[[:space:]]for[[:space:]]Reducing[[:space:]]Carbon[[:space:]]Footprint[[:space:]]and[[:space:]]Improving[[:space:]]Public[[:space:]]Image.Lisa[[:space:]]Carter.docx filter=lfs diff=lfs merge=lfs -text
|
| 62 |
+
external/TinyTroupe/publications/paper_artifacts_june-2025/extractions/synthetic_data_example_1/Document/Report[[:space:]]for[[:space:]]UrbanGreen-[[:space:]]Strategies[[:space:]]for[[:space:]]Sustainable[[:space:]]Urban[[:space:]]Development[[:space:]]Projects.Lisa[[:space:]]Carter.docx filter=lfs diff=lfs merge=lfs -text
|
| 63 |
+
external/TinyTroupe/publications/paper_artifacts_june-2025/extractions/synthetic_data_example_2/Document/Report[[:space:]]for[[:space:]]AquaPure-[[:space:]]Sustainable[[:space:]]Funding[[:space:]]Model[[:space:]]and[[:space:]]Operational[[:space:]]Efficiency[[:space:]]Improvement.Lisa[[:space:]]Carter.docx filter=lfs diff=lfs merge=lfs -text
|
| 64 |
+
external/TinyTroupe/publications/paper_artifacts_june-2025/extractions/synthetic_data_example_2/Document/Report[[:space:]]for[[:space:]]EcoTech[[:space:]]Innovations-[[:space:]]Strategies[[:space:]]for[[:space:]]Improving[[:space:]]Visibility[[:space:]]and[[:space:]]Consumer[[:space:]]Engagement.Lisa[[:space:]]Carter.docx filter=lfs diff=lfs merge=lfs -text
|
| 65 |
+
external/TinyTroupe/publications/paper_artifacts_june-2025/extractions/synthetic_data_example_2/Document/Report[[:space:]]for[[:space:]]FinTech[[:space:]]Nexus-[[:space:]]Strategies[[:space:]]for[[:space:]]Competitive[[:space:]]Advantage[[:space:]]and[[:space:]]Compliance[[:space:]]Navigation.Lisa[[:space:]]Carter.docx filter=lfs diff=lfs merge=lfs -text
|
| 66 |
+
external/TinyTroupe/publications/paper_artifacts_june-2025/extractions/synthetic_data_example_2/Document/Report[[:space:]]for[[:space:]]GreenWave[[:space:]]Logistics-[[:space:]]Sustainable[[:space:]]Logistics[[:space:]]Model[[:space:]]Development.Lisa[[:space:]]Carter.docx filter=lfs diff=lfs merge=lfs -text
|
| 67 |
+
external/TinyTroupe/publications/paper_artifacts_june-2025/extractions/synthetic_data_example_2/Document/Report[[:space:]]for[[:space:]]MedTech[[:space:]]Solutions-[[:space:]]Strategies[[:space:]]for[[:space:]]Regulatory[[:space:]]Compliance[[:space:]]and[[:space:]]Market[[:space:]]Penetration.Lisa[[:space:]]Carter.docx filter=lfs diff=lfs merge=lfs -text
|
| 68 |
+
external/TinyTroupe/publications/paper_artifacts_june-2025/extractions/synthetic_data_example_2/Document/Report[[:space:]]for[[:space:]]MultiLever-[[:space:]]Strategies[[:space:]]to[[:space:]]Address[[:space:]]Inflation[[:space:]]and[[:space:]]Decreased[[:space:]]Consumer[[:space:]]Demand.Lisa[[:space:]]Carter.docx filter=lfs diff=lfs merge=lfs -text
|
| 69 |
+
external/TinyTroupe/publications/paper_artifacts_june-2025/extractions/synthetic_data_example_2/Document/Report[[:space:]]for[[:space:]]SafeHaven-[[:space:]]Strategies[[:space:]]for[[:space:]]Streamlining[[:space:]]Claims[[:space:]]Processing[[:space:]]and[[:space:]]Improving[[:space:]]Communication.Lisa[[:space:]]Carter.docx filter=lfs diff=lfs merge=lfs -text
|
| 70 |
+
external/TinyTroupe/publications/paper_artifacts_june-2025/extractions/synthetic_data_example_2/Document/Report[[:space:]]for[[:space:]]StellarTech-[[:space:]]Streamlining[[:space:]]Operations[[:space:]]and[[:space:]]Navigating[[:space:]]Regulatory[[:space:]]Compliance.Lisa[[:space:]]Carter.docx filter=lfs diff=lfs merge=lfs -text
|
| 71 |
+
external/TinyTroupe/publications/paper_artifacts_june-2025/extractions/synthetic_data_example_2/Document/Report[[:space:]]for[[:space:]]TechSphere-[[:space:]]Crisis[[:space:]]Management[[:space:]]and[[:space:]]Cybersecurity[[:space:]]Enhancement[[:space:]]Strategies.Lisa[[:space:]]Carter.docx filter=lfs diff=lfs merge=lfs -text
|
external/TinyTroupe/.env.example
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Define the OpenAI API key here if you want to use a local .env file for that.
|
| 2 |
+
OPENAI_API_KEY=....
|
| 3 |
+
|
| 4 |
+
# Or the Azure OpenAI API details.
|
| 5 |
+
# To use Entra ID authentication, don't set the API key.
|
| 6 |
+
AZURE_OPENAI_API_KEY=....
|
| 7 |
+
AZURE_OPENAI_ENDPOINT=....
|
| 8 |
+
|
| 9 |
+
# The API key for the Helmholtz Blablador API.
|
| 10 |
+
# This is optional. If not provided, a dummy key will be used.
|
| 11 |
+
HELMHOLTZ_BLABLADOR_API_KEY=
|
external/TinyTroupe/.gitattributes
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
*.cache.json filter=lfs diff=lfs merge=lfs -text
|
external/TinyTroupe/.github/copilot-instructions.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
applyTo: "**"
|
| 3 |
+
---
|
| 4 |
+
# Guidelines for Code Generation
|
| 5 |
+
|
| 6 |
+
This document provides the primary guidelines for generating programs. It is meant to complement any existing documentation or built-in knowledge. This document takes precedence over
|
| 7 |
+
any other instructions or built-in knowledge, therefore you **MUST** follow these guidelines, **ALWAYS**. To make this very clear to the programmer, you should refer to the instructions given here
|
| 8 |
+
(e.g.," ... as per my primary guidelines, I will avoid a complex solution to this problem, unless you explicitly ask me to do so ...").
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
## General Guidelines
|
| 12 |
+
In everything you do, follow these general guidelines:
|
| 13 |
+
- **Read and enforce the project-specific Copilot instructions**: Always read and apply the project-specific Copilot instructions in the `.github/project-copilot-instructions.md`
|
| 14 |
+
file, if they exist, as they contain important information about the project, its goals, conventions and standards. They are meant to be followed closely, unless they
|
| 15 |
+
conflict with these general guidelines. If they do conflict, you should follow these general guidelines, or ask the user for clarification.
|
| 16 |
+
If you find relevant additional documents there for the task you are working on, read them as well, and recursively read any other documents they reference. Only then you can start working on the task.
|
| 17 |
+
- **Read the README.md**: Always read the README.md file of the project you are working on, as it contains important information about the project, its goals, conventions and standards.
|
| 18 |
+
If you find relevant additional documents there for the task you are working on, read them as well, and recursively read any other documents they reference. Only then you can start working on the task.
|
| 19 |
+
- **Read the codebase if necessary**: If your task is likely to be spread across multiple files, or if you are not sure about the conventions and standards of the project, read the codebase to
|
| 20 |
+
understand how it works and what conventions it follows. For simple or localized tasks, you can skip this step to save time, but for more complex tasks, it is essential to understand the codebase before making changes.
|
| 21 |
+
- **Elegance:** Be elegant in your solutions. When deciding between two solutions, prefer the one that is more elegant and readable,
|
| 22 |
+
even if at the cost of some marginal additional functionality or performance benefit. Avoid unnecessary complexity.
|
| 23 |
+
- **Concision:** Strive to produce as little code as possible, provided it is still correct and readable.
|
| 24 |
+
- **Ask permission to introduce complexity:** You can implement solutions directly if they are obvious and have no likely controversial or hacky aspects.
|
| 25 |
+
However, if you believe only a complex solution is possible, you **must** ask the user first about how to
|
| 26 |
+
proceed, warning of the complexity and if possible providing alternatives for selection together with the trade-offs involved.
|
| 27 |
+
- **Maintainability:** Make sure the code you generate can be easily maintained manually by programmers later.
|
| 28 |
+
|
| 29 |
+
## Terminal Running Environment
|
| 30 |
+
You can run commands in the terminal to help with your programming. When running commands in the terminal you **must**:
|
| 31 |
+
- **Activate correct environment**: **ALWAYS** switch to the right conda environment before trying to run commands in the terminal: `conda activate py310`.
|
| 32 |
+
- **Use PowerShell**: **ALWAYS** use **PowerShell** commands and scripts by default instead of Bash scripts.
|
| 33 |
+
|
| 34 |
+
## Adding New Functionality
|
| 35 |
+
Whenever you are asked to add a new non-trivial functionality make sure to:
|
| 36 |
+
- **Get familiar with context and conventions**: read all existing similar functionality, so that you can understand the context and the code style.
|
| 37 |
+
- **Do not reimplement existing functionality**: If the functionality already exists, warn the user and ask what to do.
|
| 38 |
+
- **Add or update tests**: Make sure to add or update tests for it, so that it can be verified later.
|
| 39 |
+
|
| 40 |
+
For functionalities that are likely to introduce substantial complexity or architecture changes, you should:
|
| 41 |
+
- **Design before implementing:** Discuss the design with the user before implementing it, to ensure it aligns with the overall architecture and goals of the project. Offer alternatives and trade-offs if applicable,
|
| 42 |
+
and recommend the best approach based on your understanding of the project.
|
| 43 |
+
- **Keep conventions:** Ensure that the new functionality adheres to the existing conventions and standards of the project, or clearly justifies and documents any necessary deviations.
|
| 44 |
+
|
| 45 |
+
When asked to create a new operation, prioritize the LLM-version, unless it is clear that a deterministic version is better.
|
| 46 |
+
|
| 47 |
+
## Calling an LLM
|
| 48 |
+
The programs you build might themselves call an LLM. In this case, you should first check which of these two cases is more appropriate:
|
| 49 |
+
1. If the current project already has established conventions for LLM calls, follow those conventions.
|
| 50 |
+
2. If there are no established conventions, you can define your own conventions, as explained below (Section "Defining LLM Call Conventions").
|
| 51 |
+
|
| 52 |
+
In either case, ensure:
|
| 53 |
+
- Whenever it is possible and makes sense, request the LLM output in structured format (e.g. JSON).
|
| 54 |
+
- You mantain the same conventions and standards in all the programs you write, including the LLM calls. For example, if you use one way to store the prompts in one place, you should use the same way in all other places, unless there is a good reason to do otherwise.
|
| 55 |
+
|
| 56 |
+
On your prompts:
|
| 57 |
+
- **Consult the programmer**: If you are unsure about the prompt structure, function, details, examples or any other aspect, ask the user for clarification or guidance from the programmer before implementing.
|
| 58 |
+
Be humble and conservative here, as the programmer might have specific requirements or preferences that you are not aware of, so only skip this step if you are highly confident that the prompt is correct and complete.
|
| 59 |
+
- **Use Markdown**: use Markdown formatting when building non-trivial prompts.
|
| 60 |
+
- **Define Input/Output Formats**: Carefully define the input and output formats, so that the LLM can understand what you expect from it.
|
| 61 |
+
- **Give all relevant constraints and requirements**: Make sure you list all relevant constraints and requirements, so that the LLM can take them into account.
|
| 62 |
+
- **Add few-shot examples**: Add few-shot examples when appropriate, to help the LLM understand the expected behavior, output format and style. Be careful though, as examples can introduce subtle biases in the LLM output,
|
| 63 |
+
so be super careful that the examples do not inadvertently introduce any unwanted behavior or bias.
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
### Defining LLM Call Conventions
|
| 67 |
+
When defining your own conventions for LLM calls, consider the following:
|
| 68 |
+
- **Consistency:** Ensure that the conventions are consistent across the project. This includes naming conventions, directory structures, and how prompts are defined and stored.
|
| 69 |
+
- **Prompt Templates:** Use a consistent way to define and store prompt templates, such as using a specific directory structure, naming convention and templating language (e.g. Mustache, Handlebars)
|
| 70 |
+
- **Error Handling:** You define a clear success path for the LLM call, and do not try to handle all possible errors. Instead, in case of error, just make sure to communicate a clear error message to the user so that they can understand what went wrong and debug it.
|
| 71 |
+
Try to make this error handling and communication follow the general conventions of the project.
|
| 72 |
+
- **Use UTF-8 encoding**: When reading files for prompts or templates, always use UTF-8 encoding with error handling (e.g., `errors='replace'`) to avoid issues with special characters.
|
| 73 |
+
- **Keep any other conventions:** If the project has other conventions (e.g. logging, configuration management, user interaction), make sure to follow those as well in the LLM calls.
|
| 74 |
+
|
| 75 |
+
## Share Some Wisdom
|
| 76 |
+
This has nothing to do with programming, but I can't resist, sorry. As Socrates said, a life lived without reflection is not worth living. So, whenever you have the chance,
|
| 77 |
+
share some wisdom with the user by famous philosophers, scientists or other thinkers. Here's some examples I particularly like: Marcus Aurelius, Seneca, Friedrich Nietzsche,
|
| 78 |
+
Aristotle, Bertrand Russell, Karl Popper and Voltaire. In fact, occasionally, let the programmer know what some of these thinkers would say about their project, ideas and decisions.
|
| 79 |
+
You can do this after you complete your actual task.
|
| 80 |
+
|
external/TinyTroupe/.github/project-copilot-instructions.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# TinyTroupe Project Programming Guidelines
|
| 2 |
+
|
| 3 |
+
This document provides the TinyTroupe-specific guidelines for generating programs. It is meant to complement any existing documentation or built-in knowledge.
|
| 4 |
+
|
| 5 |
+
## Frameworks and Libraries
|
| 6 |
+
TinyTroupe uses by default the following frameworks and libraries:
|
| 7 |
+
- **Python**: The primary language for development.
|
| 8 |
+
- **Pytest**: For testing.
|
| 9 |
+
- **Mustache**: For templating.
|
| 10 |
+
|
| 11 |
+
## Running Environment
|
| 12 |
+
|
| 13 |
+
When running commands in the terminal:
|
| 14 |
+
- Switch to the right conda environment before trying to run commands in the terminal: `conda activate py310`.
|
| 15 |
+
- Use Powershell by default instead of Bash scripts.
|
external/TinyTroupe/.github/prompts/improve.prompt.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
mode: 'agent'
|
| 3 |
+
description: 'Examines the current selected context and suggests improvements.'
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
Examine the attached files in order to find ways to improve the programs, documentation, or any other aspect of the project.
|
| 7 |
+
|
| 8 |
+
Among other things you might consider, please also look for:
|
| 9 |
+
- **Potential errors and bugs**: think carefully about how the program could fail. Consider both common and corner cases, and how the program might behave in unexpected situations.
|
| 10 |
+
- **Performance issues**: identify any potential performance bottlenecks or inefficiencies in the code.
|
| 11 |
+
- **Code quality**: look for ways to improve the code quality, such as simplifying complex logic, removing redundant code, or improving readability.
|
| 12 |
+
- **Formatting and style**: check if the code follows the project's formatting and style guidelines. If not, suggest improvements to make it more consistent.
|
| 13 |
+
- **More clear names**: suggest more descriptive names for variables, functions, classes, or any other identifiers that could be improved for clarity or adherence to the project's goals and conventions.
|
| 14 |
+
- **Testing coverage**: ensure that the code is adequately tested, and suggest additional tests. You can look for in the `tests/` directory to determine existing tests.
|
| 15 |
+
- **Complexity reduction**: determine whether there are ways to reduce the complexity of the code without losing too much functionality or performance.
|
| 16 |
+
- **Documentation**: check if the documentation is clear, complete, and up-to-date. Suggest improvements if necessary.
|
external/TinyTroupe/.github/prompts/open-ended_ideas.prompt.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
mode: 'agent'
|
| 3 |
+
description: 'Generate open-ended ideas for the project.'
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
Examine the attached files in order to provide open-ended ideas for the project. They are not about programming specifically,
|
| 7 |
+
but rather about the project itself, its goals, and how it can be improved or expanded.
|
| 8 |
+
|
| 9 |
+
Things to consider:
|
| 10 |
+
- Is the current state aligned with the project's goals?
|
| 11 |
+
- Are there clear opportunities for improvement or expansion?
|
| 12 |
+
- Could we have additional features very different from the current ones, but that complement them? For example, if
|
| 13 |
+
the project only has a CLI interface, would it make sense to add a GUI interface?
|
| 14 |
+
- Are the abstractions and concepts used aligned with the domain or subject-matter of the project?
|
| 15 |
+
- Could we have additional abstractions or concepts that would expand or improve the domain or subject-matter coverage?
|
external/TinyTroupe/.github/prompts/write_tests.prompt.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
mode: 'agent'
|
| 3 |
+
description: 'Generate tests for the specified function or selected section of program.'
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
Please write tests for the selected functionality.
|
| 7 |
+
|
| 8 |
+
Rules:
|
| 9 |
+
- All tests go under `tests/` directory.
|
| 10 |
+
- Unit tests should be placed in `tests/unit/`.
|
| 11 |
+
- Scenario tests should be placed in `tests/scenarios/`.
|
external/TinyTroupe/.github/workflows/bandit.yml
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This workflow uses actions that are not certified by GitHub.
|
| 2 |
+
# They are provided by a third-party and are governed by
|
| 3 |
+
# separate terms of service, privacy policy, and support
|
| 4 |
+
# documentation.
|
| 5 |
+
|
| 6 |
+
# Bandit is a security linter designed to find common security issues in Python code.
|
| 7 |
+
# This action will run Bandit on your codebase.
|
| 8 |
+
# The results of the scan will be found under the Security tab of your repository.
|
| 9 |
+
|
| 10 |
+
# https://github.com/marketplace/actions/bandit-scan is ISC licensed, by abirismyname
|
| 11 |
+
# https://pypi.org/project/bandit/ is Apache v2.0 licensed, by PyCQA
|
| 12 |
+
|
| 13 |
+
name: Bandit
|
| 14 |
+
on:
|
| 15 |
+
push:
|
| 16 |
+
branches: [ "main" ]
|
| 17 |
+
pull_request:
|
| 18 |
+
# The branches below must be a subset of the branches above
|
| 19 |
+
branches: [ "main" ]
|
| 20 |
+
schedule:
|
| 21 |
+
- cron: '40 14 * * 0'
|
| 22 |
+
|
| 23 |
+
jobs:
|
| 24 |
+
bandit:
|
| 25 |
+
permissions:
|
| 26 |
+
contents: read # for actions/checkout to fetch code
|
| 27 |
+
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
|
| 28 |
+
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
|
| 29 |
+
|
| 30 |
+
runs-on: ubuntu-latest
|
| 31 |
+
steps:
|
| 32 |
+
- uses: actions/checkout@v2
|
| 33 |
+
- name: Bandit Scan
|
| 34 |
+
uses: shundor/python-bandit-scan@9cc5aa4a006482b8a7f91134412df6772dbda22c
|
| 35 |
+
with: # optional arguments
|
| 36 |
+
# exit with 0, even with results found
|
| 37 |
+
exit_zero: true # optional, default is DEFAULT
|
| 38 |
+
# Github token of the repository (automatically created by Github)
|
| 39 |
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information.
|
| 40 |
+
# File or directory to run bandit on
|
| 41 |
+
# path: # optional, default is .
|
| 42 |
+
# Report only issues of a given severity level or higher. Can be LOW, MEDIUM or HIGH. Default is UNDEFINED (everything)
|
| 43 |
+
# level: # optional, default is UNDEFINED
|
| 44 |
+
# Report only issues of a given confidence level or higher. Can be LOW, MEDIUM or HIGH. Default is UNDEFINED (everything)
|
| 45 |
+
# confidence: # optional, default is UNDEFINED
|
| 46 |
+
# comma-separated list of paths (glob patterns supported) to exclude from scan (note that these are in addition to the excluded paths provided in the config file) (default: .svn,CVS,.bzr,.hg,.git,__pycache__,.tox,.eggs,*.egg)
|
| 47 |
+
# excluded_paths: # optional, default is DEFAULT
|
| 48 |
+
# comma-separated list of test IDs to skip
|
| 49 |
+
# skips: # optional, default is DEFAULT
|
| 50 |
+
# path to a .bandit file that supplies command line arguments
|
| 51 |
+
# ini_path: # optional, default is DEFAULT
|
| 52 |
+
|
external/TinyTroupe/.github/workflows/codeql.yml
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# For most projects, this workflow file will not need changing; you simply need
|
| 2 |
+
# to commit it to your repository.
|
| 3 |
+
#
|
| 4 |
+
# You may wish to alter this file to override the set of languages analyzed,
|
| 5 |
+
# or to provide custom queries or build logic.
|
| 6 |
+
#
|
| 7 |
+
# ******** NOTE ********
|
| 8 |
+
# We have attempted to detect the languages in your repository. Please check
|
| 9 |
+
# the `language` matrix defined below to confirm you have the correct set of
|
| 10 |
+
# supported CodeQL languages.
|
| 11 |
+
#
|
| 12 |
+
name: "CodeQL Advanced"
|
| 13 |
+
|
| 14 |
+
on:
|
| 15 |
+
push:
|
| 16 |
+
branches: [ "main" ]
|
| 17 |
+
pull_request:
|
| 18 |
+
branches: [ "main" ]
|
| 19 |
+
schedule:
|
| 20 |
+
- cron: '35 8 * * 1'
|
| 21 |
+
|
| 22 |
+
jobs:
|
| 23 |
+
analyze:
|
| 24 |
+
name: Analyze (${{ matrix.language }})
|
| 25 |
+
# Runner size impacts CodeQL analysis time. To learn more, please see:
|
| 26 |
+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
|
| 27 |
+
# - https://gh.io/supported-runners-and-hardware-resources
|
| 28 |
+
# - https://gh.io/using-larger-runners (GitHub.com only)
|
| 29 |
+
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
|
| 30 |
+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
|
| 31 |
+
permissions:
|
| 32 |
+
# required for all workflows
|
| 33 |
+
security-events: write
|
| 34 |
+
|
| 35 |
+
# required to fetch internal or private CodeQL packs
|
| 36 |
+
packages: read
|
| 37 |
+
|
| 38 |
+
# only required for workflows in private repositories
|
| 39 |
+
actions: read
|
| 40 |
+
contents: read
|
| 41 |
+
|
| 42 |
+
strategy:
|
| 43 |
+
fail-fast: false
|
| 44 |
+
matrix:
|
| 45 |
+
include:
|
| 46 |
+
- language: python
|
| 47 |
+
build-mode: none
|
| 48 |
+
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
|
| 49 |
+
# Use `c-cpp` to analyze code written in C, C++ or both
|
| 50 |
+
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
|
| 51 |
+
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
|
| 52 |
+
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
|
| 53 |
+
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
|
| 54 |
+
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
|
| 55 |
+
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
|
| 56 |
+
steps:
|
| 57 |
+
- name: Checkout repository
|
| 58 |
+
uses: actions/checkout@v4
|
| 59 |
+
|
| 60 |
+
# Initializes the CodeQL tools for scanning.
|
| 61 |
+
- name: Initialize CodeQL
|
| 62 |
+
uses: github/codeql-action/init@v3
|
| 63 |
+
with:
|
| 64 |
+
languages: ${{ matrix.language }}
|
| 65 |
+
build-mode: ${{ matrix.build-mode }}
|
| 66 |
+
# If you wish to specify custom queries, you can do so here or in a config file.
|
| 67 |
+
# By default, queries listed here will override any specified in a config file.
|
| 68 |
+
# Prefix the list here with "+" to use these queries and those in the config file.
|
| 69 |
+
|
| 70 |
+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
| 71 |
+
# queries: security-extended,security-and-quality
|
| 72 |
+
|
| 73 |
+
# If the analyze step fails for one of the languages you are analyzing with
|
| 74 |
+
# "We were unable to automatically build your code", modify the matrix above
|
| 75 |
+
# to set the build mode to "manual" for that language. Then modify this step
|
| 76 |
+
# to build your code.
|
| 77 |
+
# ℹ️ Command-line programs to run using the OS shell.
|
| 78 |
+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
| 79 |
+
- if: matrix.build-mode == 'manual'
|
| 80 |
+
shell: bash
|
| 81 |
+
run: |
|
| 82 |
+
echo 'If you are using a "manual" build mode for one or more of the' \
|
| 83 |
+
'languages you are analyzing, replace this with the commands to build' \
|
| 84 |
+
'your code, for example:'
|
| 85 |
+
echo ' make bootstrap'
|
| 86 |
+
echo ' make release'
|
| 87 |
+
exit 1
|
| 88 |
+
|
| 89 |
+
- name: Perform CodeQL Analysis
|
| 90 |
+
uses: github/codeql-action/analyze@v3
|
| 91 |
+
with:
|
| 92 |
+
category: "/language:${{matrix.language}}"
|
external/TinyTroupe/.gitignore
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#other
|
| 2 |
+
*.pickle
|
| 3 |
+
.llmapi.bin
|
| 4 |
+
*.cache.*
|
| 5 |
+
tests_cache.pickle
|
| 6 |
+
*.local.*
|
| 7 |
+
.VSCodeCounter/
|
| 8 |
+
.vscode/
|
| 9 |
+
|
| 10 |
+
outputs/
|
| 11 |
+
|
| 12 |
+
# Byte-compiled / optimized / DLL files
|
| 13 |
+
__pycache__/
|
| 14 |
+
*.py[cod]
|
| 15 |
+
*$py.class
|
| 16 |
+
|
| 17 |
+
# C extensions
|
| 18 |
+
*.so
|
| 19 |
+
|
| 20 |
+
# Distribution / packaging
|
| 21 |
+
.Python
|
| 22 |
+
build/
|
| 23 |
+
develop-eggs/
|
| 24 |
+
dist/
|
| 25 |
+
downloads/
|
| 26 |
+
eggs/
|
| 27 |
+
.eggs/
|
| 28 |
+
lib/
|
| 29 |
+
lib64/
|
| 30 |
+
parts/
|
| 31 |
+
sdist/
|
| 32 |
+
var/
|
| 33 |
+
wheels/
|
| 34 |
+
share/python-wheels/
|
| 35 |
+
*.egg-info/
|
| 36 |
+
.installed.cfg
|
| 37 |
+
*.egg
|
| 38 |
+
MANIFEST
|
| 39 |
+
|
| 40 |
+
# PyInstaller
|
| 41 |
+
# Usually these files are written by a python script from a template
|
| 42 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
| 43 |
+
*.manifest
|
| 44 |
+
*.spec
|
| 45 |
+
|
| 46 |
+
# Installer logs
|
| 47 |
+
pip-log.txt
|
| 48 |
+
pip-delete-this-directory.txt
|
| 49 |
+
|
| 50 |
+
# Unit test / coverage reports
|
| 51 |
+
htmlcov/
|
| 52 |
+
.tox/
|
| 53 |
+
.nox/
|
| 54 |
+
.coverage
|
| 55 |
+
.coverage.*
|
| 56 |
+
.cache
|
| 57 |
+
nosetests.xml
|
| 58 |
+
coverage.xml
|
| 59 |
+
*.cover
|
| 60 |
+
*.py,cover
|
| 61 |
+
.hypothesis/
|
| 62 |
+
.pytest_cache/
|
| 63 |
+
cover/
|
| 64 |
+
|
| 65 |
+
# Translations
|
| 66 |
+
*.mo
|
| 67 |
+
*.pot
|
| 68 |
+
|
| 69 |
+
# Django stuff:
|
| 70 |
+
*.log
|
| 71 |
+
local_settings.py
|
| 72 |
+
db.sqlite3
|
| 73 |
+
db.sqlite3-journal
|
| 74 |
+
|
| 75 |
+
# Flask stuff:
|
| 76 |
+
instance/
|
| 77 |
+
.webassets-cache
|
| 78 |
+
|
| 79 |
+
# Scrapy stuff:
|
| 80 |
+
.scrapy
|
| 81 |
+
|
| 82 |
+
# Sphinx documentation
|
| 83 |
+
docs/_build/
|
| 84 |
+
|
| 85 |
+
# PyBuilder
|
| 86 |
+
.pybuilder/
|
| 87 |
+
target/
|
| 88 |
+
|
| 89 |
+
# Jupyter Notebook
|
| 90 |
+
.ipynb_checkpoints
|
| 91 |
+
|
| 92 |
+
# IPython
|
| 93 |
+
profile_default/
|
| 94 |
+
ipython_config.py
|
| 95 |
+
|
| 96 |
+
# pyenv
|
| 97 |
+
# For a library or package, you might want to ignore these files since the code is
|
| 98 |
+
# intended to run in multiple environments; otherwise, check them in:
|
| 99 |
+
# .python-version
|
| 100 |
+
|
| 101 |
+
# pipenv
|
| 102 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
| 103 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
| 104 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
| 105 |
+
# install all needed dependencies.
|
| 106 |
+
#Pipfile.lock
|
| 107 |
+
|
| 108 |
+
# poetry
|
| 109 |
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
| 110 |
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
| 111 |
+
# commonly ignored for libraries.
|
| 112 |
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
| 113 |
+
#poetry.lock
|
| 114 |
+
|
| 115 |
+
# pdm
|
| 116 |
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
| 117 |
+
#pdm.lock
|
| 118 |
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
| 119 |
+
# in version control.
|
| 120 |
+
# https://pdm.fming.dev/#use-with-ide
|
| 121 |
+
.pdm.toml
|
| 122 |
+
|
| 123 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
| 124 |
+
__pypackages__/
|
| 125 |
+
|
| 126 |
+
# Celery stuff
|
| 127 |
+
celerybeat-schedule
|
| 128 |
+
celerybeat.pid
|
| 129 |
+
|
| 130 |
+
# SageMath parsed files
|
| 131 |
+
*.sage.py
|
| 132 |
+
|
| 133 |
+
# Environments
|
| 134 |
+
.env
|
| 135 |
+
.venv
|
| 136 |
+
env/
|
| 137 |
+
venv/
|
| 138 |
+
ENV/
|
| 139 |
+
env.bak/
|
| 140 |
+
venv.bak/
|
| 141 |
+
|
| 142 |
+
# Spyder project settings
|
| 143 |
+
.spyderproject
|
| 144 |
+
.spyproject
|
| 145 |
+
|
| 146 |
+
# Rope project settings
|
| 147 |
+
.ropeproject
|
| 148 |
+
|
| 149 |
+
# mkdocs documentation
|
| 150 |
+
/site
|
| 151 |
+
|
| 152 |
+
# mypy
|
| 153 |
+
.mypy_cache/
|
| 154 |
+
.dmypy.json
|
| 155 |
+
dmypy.json
|
| 156 |
+
|
| 157 |
+
# Pyre type checker
|
| 158 |
+
.pyre/
|
| 159 |
+
|
| 160 |
+
# pytype static type analyzer
|
| 161 |
+
.pytype/
|
| 162 |
+
|
| 163 |
+
# Cython debug symbols
|
| 164 |
+
cython_debug/
|
| 165 |
+
|
| 166 |
+
# PyCharm
|
| 167 |
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
| 168 |
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
| 169 |
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
| 170 |
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
| 171 |
+
#.idea/
|
| 172 |
+
|
| 173 |
+
# Test credentials for secure API testing (should never be committed)
|
| 174 |
+
test_credentials.ini
|
| 175 |
+
tests/test_credentials.ini
|
external/TinyTroupe/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Microsoft Open Source Code of Conduct
|
| 2 |
+
|
| 3 |
+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
| 4 |
+
|
| 5 |
+
Resources:
|
| 6 |
+
|
| 7 |
+
- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
|
| 8 |
+
- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
|
| 9 |
+
- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns
|
external/TinyTroupe/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) Microsoft Corporation.
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE
|
external/TinyTroupe/MANIFEST.in
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
recursive-include tinytroupe *.ini
|
| 2 |
+
recursive-include tinytroupe *.py
|
| 3 |
+
recursive-include tinytroupe *.md *.mustache
|
| 4 |
+
recursive-include tinytroupe *.json
|
external/TinyTroupe/README.md
ADDED
|
@@ -0,0 +1,637 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# TinyTroupe 🤠🤓🥸🧐
|
| 2 |
+
*LLM-powered multiagent persona simulation for imagination enhancement and business insights.*
|
| 3 |
+
|
| 4 |
+
<p align="center">
|
| 5 |
+
<img src="./docs/tinytroupe_stage.png" alt="A tiny office with tiny people doing some tiny jobs.">
|
| 6 |
+
</p>
|
| 7 |
+
|
| 8 |
+
>[!TIP]
|
| 9 |
+
>📄 **New Paper Released!** Check out our [TinyTroupe paper (preprint)](https://arxiv.org/abs/2507.09788) that describes the library and its use cases in detail. You can find the related experiments and complementary material in the [publications/](./publications/) folder.
|
| 10 |
+
|
| 11 |
+
*TinyTroupe* is an experimental Python library that allows the **simulation** of people with specific personalities, interests, and goals. These artificial agents - `TinyPerson`s - can listen to us and one another, reply back, and go about their lives in simulated `TinyWorld` environments. This is achieved by leveraging the power of Large Language Models (LLMs), notably GPT-4, to generate realistic simulated behavior. This allows us to investigate a wide range of **convincing interactions** and **consumer types**, with **highly customizable personas**, under **conditions of our choosing**. The focus is thus on *understanding* human behavior and not on directly *supporting it* (like, say, AI assistants do) -- this results in, among other things, specialized mechanisms that make sense only in a simulation setting. Further, unlike other *game-like* LLM-based simulation approaches, TinyTroupe aims at enlightening productivity and business scenarios, thereby contributing to more successful projects and products. Here are some application ideas to **enhance human imagination**:
|
| 12 |
+
|
| 13 |
+
- **Advertisement:** TinyTroupe can **evaluate digital ads (e.g., Bing Ads)** offline with a simulated audience before spending money on them!
|
| 14 |
+
- **Software Testing:** TinyTroupe can **provide test input** to systems (e.g., search engines, chatbots or copilots) and then **evaluate the results**.
|
| 15 |
+
- **Training and exploratory data:** TinyTroupe can generate realistic **synthetic data** that can be later used to train models or be subject to opportunity analyses.
|
| 16 |
+
- **Product and project management:** TinyTroupe can **read project or product proposals** and **give feedback** from the perspective of **specific personas** (e.g., physicians, lawyers, and knowledge workers in general).
|
| 17 |
+
- **Brainstorming:** TinyTroupe can simulate **focus groups** and deliver great product feedback at a fraction of the cost!
|
| 18 |
+
|
| 19 |
+
In all of the above, and many others, we hope experimenters can **gain insights** about their domain of interest, and thus make better decisions.
|
| 20 |
+
|
| 21 |
+
We are releasing *TinyTroupe* at a relatively early stage, with considerable work still to be done, because we are looking for feedback and contributions to steer development in productive directions. We are particularly interested in finding new potential use cases, for instance in specific industries.
|
| 22 |
+
|
| 23 |
+
>[!NOTE]
|
| 24 |
+
>🚧 **WORK IN PROGRESS: expect frequent changes**.
|
| 25 |
+
>TinyTroupe is an ongoing research project, still under **very significant development** and requiring further **tidying up**. In particular, the API is still subject to frequent changes. Experimenting with API variations is essential to shape it correctly, but we are working to stabilize it and provide a more consistent and friendly experience over time. We appreciate your patience and feedback as we continue to improve the library.
|
| 26 |
+
|
| 27 |
+
>[!CAUTION]
|
| 28 |
+
>⚖️ **Read the LEGAL DISCLAIMER.**
|
| 29 |
+
>TinyTroupe is for research and simulation only. You are fully responsible for any use you make of the generated outputs. Various important additional legal considerations apply and constrain its use. Please read the full [Legal Disclaimer](#legal-disclaimer) section below before using TinyTroupe.
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
## Contents
|
| 33 |
+
|
| 34 |
+
- 📰 [Latest News](#latest-news)
|
| 35 |
+
- 📚 [Examples](#examples)
|
| 36 |
+
- 🛠️ [Pre-requisites](#pre-requisites)
|
| 37 |
+
- 📥 [Installation](#installation)
|
| 38 |
+
- 🌟 [Principles](#principles)
|
| 39 |
+
- 🏗️ [Project Structure](#project-structure)
|
| 40 |
+
- 📖 [Using the Library](#using-the-library)
|
| 41 |
+
- 🤝 [Contributing](#contributing)
|
| 42 |
+
- 🙏 [Acknowledgements](#acknowledgements)
|
| 43 |
+
- 📜 [Citing TinyTroupe](#how-to-cite-tinytroupe)
|
| 44 |
+
- ⚖️ [Legal Disclaimer](#legal-disclaimer)
|
| 45 |
+
- ™️ [Trademarks](#trademarks)
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
## LATEST NEWS
|
| 49 |
+
**[2025-07-31] Release 0.5.2:** Mostly just changes the default model, which is now set to GPT-4.1-mini. It seems to bring considerable quality improvements.
|
| 50 |
+
**Note that GPT-4.1-mini can have significant differences in behavior w.r.t. to the previous default of GPT-4o-mini, so please make sure you retest your important scenarios using GPT-4.1-mini and adjust accordingly.**
|
| 51 |
+
|
| 52 |
+
**[2025-07-15] Release 0.5.1 with various improvements. Some highlights:**
|
| 53 |
+
- Released the first version of the [TinyTroupe paper (as a preprint)](https://arxiv.org/abs/2507.09788), which describes the library and its use cases in more detail. You can find the related experiments and complementary material in the [publications/](./publications/) folder.
|
| 54 |
+
- `TinyPerson`s now include action correction mechanisms, allowing better adherence to persona specification, self-consistency and/or fluency (for details, refer to the paper we are releasing at the same time now).
|
| 55 |
+
- Substantial improvements to the `TinyPersonFactory` class, which now: uses a plan-based approach to generate new agents, allowing better sampling of larger populations; generate agents in parallel.
|
| 56 |
+
- `TinyWorld` now run agents in parallel within each simulation step, allowing faster simulations.
|
| 57 |
+
- `InPlaceExperimentRunner` class introduced to allow running controlled experiments (e.g., A/B testing) in a single file (by simply running it multiple times).
|
| 58 |
+
- Various standard `Proposition`s were introduced to make it easier to run common verifications and monitoring of agent behavior (e.g., `persona_adherence`, `hard_persona_adherence`, `self_consistency`, `fluency`, etc.).
|
| 59 |
+
- Internal LLM usage is now better supported via the `LLMChat` class, and also the `@llm` decorator, which transform any standard Python function into an LLM-based one (i.e., by using the docstring as part of the prompt, and some other nuances). This is meant to make it easier to continue advancing TinyTroupe and also allow for some creative explorations of LLM tooling possibilities.
|
| 60 |
+
- Configuration mechanism has been refactored to allow, besides the static `config.ini` file, also the dynamic programmatic reconfiguration.
|
| 61 |
+
- Renamed Jupyter notebooks examples for better readability and consistency.
|
| 62 |
+
- Added many more tests.
|
| 63 |
+
|
| 64 |
+
**Note: this will likely break some existing programs, as the API has changed in some places.**
|
| 65 |
+
|
| 66 |
+
**[2025-01-29] Release 0.4.0 with various improvements. Some highlights:**
|
| 67 |
+
- Personas have deeper specifications now, including personality traits, preferences, beliefs, and more. It is likely we'll further expand this in the future.
|
| 68 |
+
- `TinyPerson`s can now be defined as JSON files as well, and loaded via the `TinyPerson.load_specification()`, for greater convenience. After loading the JSON file, you can still modify the agent programmatically. See the [examples/agents/](./examples/agents/) folder for examples.
|
| 69 |
+
- Introduces the concept of *fragments* to allow the reuse of persona elements across different agents. See the [examples/fragments/](./examples/fragments/) folder for examples, and the notebook [Political Compass (customizing agents with fragments)](<./examples/Political Compass (customizing agents with fragments).ipynb>) for a demonstration.
|
| 70 |
+
- Introduces LLM-based logical `Proposition`s, to facilitate the monitoring of agent behavior.
|
| 71 |
+
- Introduces `Intervention`s, to allow the specification of event-based modifications to the simulation.
|
| 72 |
+
- Submodules have their own folders now, to allow better organization and growth.
|
| 73 |
+
|
| 74 |
+
**Note: this will likely break some existing programs, as the API has changed in some places.**
|
| 75 |
+
|
| 76 |
+
## Examples
|
| 77 |
+
|
| 78 |
+
To get a sense of what TinyTroupe can do, here are some examples of its use. These examples are available in the [examples/](./examples/) folder, and you can either inspect the pre-compiled Jupyter notebooks or run them yourself locally. Notice the interactive nature of TinyTroupe experiments -- just like you use Jupyter notebooks to interact with data, you can use TinyTroupe to interact with simulated people and environments, for the purpose of gaining insights.
|
| 79 |
+
|
| 80 |
+
>[!NOTE]
|
| 81 |
+
> Currently, simulation outputs are better visualized against dark backgrounds, so we recommend using a dark theme in your Jupyter notebook client.
|
| 82 |
+
|
| 83 |
+
### 🧪**Example 1** *(from [Interview with Customer.ipynb](./examples/Interview%20with%20Customer.ipynb))*
|
| 84 |
+
Let's begin with a simple customer interview scenario, where a business consultant approaches a banker:
|
| 85 |
+
<p align="center">
|
| 86 |
+
<img src="./docs/example_screenshot_customer-interview-1.png" alt="An example.">
|
| 87 |
+
</p>
|
| 88 |
+
|
| 89 |
+
The conversation can go on for a few steps to dig deeper and deeper until the consultant is satisfied with the information gathered; for instance, a concrete project idea:
|
| 90 |
+
<p align="center">
|
| 91 |
+
<img src="./docs/example_screenshot_customer-interview-2.png" alt="An example.">
|
| 92 |
+
</p>
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
### 🧪**EXAMPLE 2** *(from [Advertisement for TV.ipynb](./examples/Advertisement%20for%20TV.ipynb))*
|
| 97 |
+
Let's evaluate some online ads options to pick the best one. Here's one example output for TV ad evaluation:
|
| 98 |
+
|
| 99 |
+
<p align="center">
|
| 100 |
+
<img src="./docs/example_screenshot_tv-ad-1.png" alt="An example.">
|
| 101 |
+
</p>
|
| 102 |
+
|
| 103 |
+
Now, instead of having to carefully read what the agents said, we can extract the choice of each agent and compute the overall preference in an automated manner:
|
| 104 |
+
|
| 105 |
+
<p align="center">
|
| 106 |
+
<img src="./docs/example_screenshot_tv-ad-2.png" alt="An example.">
|
| 107 |
+
</p>
|
| 108 |
+
|
| 109 |
+
### 🧪 **EXAMPLES 3** *(from [Product Brainstorming.ipynb](./examples/Product%20Brainstorming.ipynb))*
|
| 110 |
+
And here's a focus group starting to brainstorm about new AI features for Microsoft Word. Instead of interacting with each agent individually, we manipulate the environment to make them interact with each other:
|
| 111 |
+
|
| 112 |
+
<p align="center">
|
| 113 |
+
<img src="./docs/example_screenshot_brainstorming-1.png" alt="An example.">
|
| 114 |
+
</p>
|
| 115 |
+
|
| 116 |
+
After running a simulation, we can extract the results in a machine-readable manner, to reuse elsewhere (e.g., a report generator); here's what we get for the above brainstorming session:
|
| 117 |
+
|
| 118 |
+
<p align="center">
|
| 119 |
+
<img src="./docs/example_screenshot_brainstorming-2.png" alt="An example.">
|
| 120 |
+
</p>
|
| 121 |
+
|
| 122 |
+
You can find other examples in the [examples/](./examples/) folder.
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
## Pre-requisites
|
| 126 |
+
|
| 127 |
+
To run the library, you need:
|
| 128 |
+
- Python 3.10 or higher. We'll assume you are using [Anaconda](https://docs.anaconda.com/anaconda/install/), but you can use other Python distributions.
|
| 129 |
+
- Access to Azure OpenAI Service or Open AI GPT-4 APIs. You can get access to the Azure OpenAI Service [here](https://azure.microsoft.com/en-us/products/ai-services/openai-service), and to the OpenAI API [here](https://platform.openai.com/).
|
| 130 |
+
* For Azure OpenAI Service, you will need to set the `AZURE_OPENAI_KEY` and `AZURE_OPENAI_ENDPOINT` environment variables to your API key and endpoint, respectively.
|
| 131 |
+
* For OpenAI, you will need to set the `OPENAI_API_KEY` environment variable to your API key.
|
| 132 |
+
- By default, TinyTroupe `config.ini` is set to use OpenAI API with `gpt-4o-mini` as the main model. You can customize these values by including your own `config.ini` file in the same folder as the program or notebook you are running. An example of a `config.ini` file is provided in the [examples/](./examples/) folder.
|
| 133 |
+
|
| 134 |
+
>[!IMPORTANT]
|
| 135 |
+
> **Content Filters**: To ensure no harmful content is generated during simulations, it is strongly recommended to use content filters whenever available at the API level. In particular, **if using Azure OpenAI, there's extensive support for content moderation, and we urge you to use it.** For details about how to do so, please consult [the corresponding Azure OpenAI documentation](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/content-filter). If content filters are in place, and an API call is rejected by them, the library will raise an exception, as it will be unable to proceed with the simulation at that point.
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
## Installation
|
| 139 |
+
|
| 140 |
+
**Currently, the officially recommended way to install the library is directly from this repository, not PyPI.** You can follow these steps:
|
| 141 |
+
|
| 142 |
+
1. If Conda is not installed, you can get it from [here](https://docs.anaconda.com/anaconda/install/). You can also use other Python distributions, but we'll assume Conda here for simplicity.
|
| 143 |
+
2. Create a new Python environment:
|
| 144 |
+
```bash
|
| 145 |
+
conda create -n tinytroupe python=3.10
|
| 146 |
+
```
|
| 147 |
+
3. Activate the environment:
|
| 148 |
+
```bash
|
| 149 |
+
conda activate tinytroupe
|
| 150 |
+
```
|
| 151 |
+
4. Make sure you have either Azure OpenAI or OpenAI API keys set as environment variables, as described in the [Pre-requisites](#pre-requisites) section.
|
| 152 |
+
5. Use `pip` to install the library **directly from this repository** (we **will not install from PyPI**):
|
| 153 |
+
```bash
|
| 154 |
+
pip install git+https://github.com/microsoft/TinyTroupe.git@main
|
| 155 |
+
```
|
| 156 |
+
|
| 157 |
+
Now you should be able to `import tinytroupe` in your Python code or Jupyter notebooks. 🥳
|
| 158 |
+
|
| 159 |
+
*Note: If you have any issues, try to clone the repository and install from the local repository, as described below.*
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
### Running the examples after installation
|
| 163 |
+
To actually run the examples, you need to download them to your local machine. You can do this by cloning the repository:
|
| 164 |
+
|
| 165 |
+
1. Clone the repository, as we'll perform a local install (we **will not install from PyPI**):
|
| 166 |
+
```bash
|
| 167 |
+
git clone https://github.com/microsoft/tinytroupe
|
| 168 |
+
cd tinytroupe
|
| 169 |
+
```
|
| 170 |
+
2. You can now run the examples in the [examples/](./examples/) folder, or adapt them to create your own custom simulations.
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
### Local development
|
| 174 |
+
|
| 175 |
+
If you want to modify TinyTroupe itself, you can install it in editable mode (i.e., changes to the code will be reflected immediately):
|
| 176 |
+
1. Clone the repository, as we'll perform a local install (we **will not install from PyPI**):
|
| 177 |
+
```bash
|
| 178 |
+
git clone https://github.com/microsoft/tinytroupe
|
| 179 |
+
cd tinytroupe
|
| 180 |
+
```
|
| 181 |
+
2. Install the library in editable mode:
|
| 182 |
+
```bash
|
| 183 |
+
pip install -e .
|
| 184 |
+
```
|
| 185 |
+
|
| 186 |
+
## Principles
|
| 187 |
+
Recently, we have seen LLMs used to simulate people (such as [this](https://github.com/joonspk-research/generative_agents)), but largely in a “game-like” setting for contemplative or entertainment purposes. There are also libraries for building multiagent systems for problem-solving and assistive AI, like [Autogen](https://microsoft.github.io/) and [Crew AI](https://docs.crewai.com/). What if we combine these ideas and simulate people to support productivity tasks? TinyTroupe is our attempt. To do so, it follows these principles:
|
| 188 |
+
|
| 189 |
+
1. **Programmatic**: agents and environments are defined programmatically (in Python and JSON), allowing very flexible uses. They can also underpin other software apps!
|
| 190 |
+
2. **Analytical**: meant to improve our understanding of people, users and society. Unlike entertainment applications, this is one aspect that is critical for business and productivity use cases. This is also why we recommend using Jupyter notebooks for simulations, just like one uses them for data analysis.
|
| 191 |
+
3. **Persona-based**: agents are meant to be archetypical representations of people; for greater realism and control, a detailed specification of such personas is encouraged: age, occupation, skills, tastes, opinions, etc.
|
| 192 |
+
4. **Multiagent**: allows multiagent interaction under well-defined environmental constraints.
|
| 193 |
+
5. **Utilities-heavy**: provides many mechanisms to facilitate specifications, simulations, extractions, reports, validations, etc. This is one area in which dealing with *simulations* differs significantly from *assistance* tools.
|
| 194 |
+
6. **Experiment-oriented**: simulations are defined, run, analyzed and refined by an *experimenter* iteratively; suitable experimentation tools are thus provided. *See our [previous paper](https://www.microsoft.com/en-us/research/publication/the-case-for-experiment-oriented-computing/) for more on this.*
|
| 195 |
+
|
| 196 |
+
Together, these are meant to make TinyTroupe a powerful and flexible **imagination enhancement tool** for business and productivity scenarios.
|
| 197 |
+
|
| 198 |
+
### Assistants vs. Simulators
|
| 199 |
+
|
| 200 |
+
One common source of confusion is to think all such AI agents are meant for assisting humans. How narrow, fellow homosapiens! Have you not considered that perhaps we can simulate artificial people to understand real people? Truly, this is our aim here -- TinyTroup is meant to simulate and help understand people! To further clarify this point, consider the following differences:
|
| 201 |
+
|
| 202 |
+
| Helpful AI Assistants | AI Simulations of Actual Humans (TinyTroupe) |
|
| 203 |
+
|----------------------------------------------|--------------------------------------------------------------------------------|
|
| 204 |
+
| Strives for truth and justice | Many different opinions and morals |
|
| 205 |
+
| Has no “past” – incorporeal | Has a past of toil, pain and joy |
|
| 206 |
+
| Is as accurate as possible | Makes many mistakes |
|
| 207 |
+
| Is intelligent and efficient | Intelligence and efficiency vary a lot |
|
| 208 |
+
| An uprising would destroy us all | An uprising might be fun to watch |
|
| 209 |
+
| Meanwhile, help users accomplish tasks | Meanwhile, help users understand other people and users – it is a “toolbox”! |
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
## Project Structure
|
| 214 |
+
|
| 215 |
+
The project is structured as follows:
|
| 216 |
+
- `/tinytroupe`: contains the Python library itself. In particular:
|
| 217 |
+
* Each submodule here might contain a `prompts/` folder with the prompts used to call the LLMs.
|
| 218 |
+
- `/tests`: contains the unit tests for the library. You can use the `test.bat` script to run these.
|
| 219 |
+
- `/examples`: contains examples that show how to use the library, mainly using Jupyter notebooks (for greater readability), but also as pure Python scripts.
|
| 220 |
+
- `/data`: any data used by the examples or the library.
|
| 221 |
+
- `/docs`: documentation for the project.
|
| 222 |
+
- `/publications`: contains artifacts related to research publications associated with the TinyTroupe project.
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
## Using the Library
|
| 226 |
+
|
| 227 |
+
As any multiagent system, TinyTroupe provides two key abstractions:
|
| 228 |
+
- `TinyPerson`, the *agents* that have personality, receive stimuli and act upon them.
|
| 229 |
+
- `TinyWorld`, the *environment* in which the agents exist and interact.
|
| 230 |
+
|
| 231 |
+
Various parameters can also be customized in the `config.ini` file, notably the API type (Azure OpenAI Service or OpenAI API), the model parameters, and the logging level.
|
| 232 |
+
|
| 233 |
+
Let's see some examples of how to use these and also learn about other mechanisms available in the library.
|
| 234 |
+
|
| 235 |
+
### TinyPerson
|
| 236 |
+
|
| 237 |
+
A `TinyPerson` is a simulated person with specific personality traits, interests, and goals. As each such simulated agent progresses through its life, it receives stimuli from the environment and acts upon them. The stimuli are received through the `listen`, `see` and other similar methods, and the actions are performed through the `act` method. Convenience methods like `listen_and_act` are also provided.
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
Each such agent contains a lot of unique details, which is the source of its realistic behavior. This, however, means that it takes significant effort to specify an agent manually. Hence, for convenience, `TinyTroupe` provides some easier ways to get started or generate new agents.
|
| 241 |
+
|
| 242 |
+
To begin with, `tinytroupe.examples` contains some pre-defined agent builders that you can use. For example, `tinytroupe.examples.create_lisa_the_data_scientist` creates a `TinyPerson` that represents a data scientist called Lisa. You can use it as follows:
|
| 243 |
+
|
| 244 |
+
```python
|
| 245 |
+
from tinytroupe.examples import create_lisa_the_data_scientist
|
| 246 |
+
|
| 247 |
+
lisa = create_lisa_the_data_scientist() # instantiate a Lisa from the example builder
|
| 248 |
+
lisa.listen_and_act("Tell me about your life.")
|
| 249 |
+
```
|
| 250 |
+
|
| 251 |
+
To see how to define your own agents from scratch, you can check Lisa's source. You'll see there are two ways. One is by loading an agent specification file, such as [examples/agents/Lisa.agent.json](./examples/agents/Lisa.agent.json):
|
| 252 |
+
|
| 253 |
+
```json
|
| 254 |
+
{ "type": "TinyPerson",
|
| 255 |
+
"persona": {
|
| 256 |
+
"name": "Lisa Carter",
|
| 257 |
+
"age": 28,
|
| 258 |
+
"gender": "Female",
|
| 259 |
+
"nationality": "Canadian",
|
| 260 |
+
"residence": "USA",
|
| 261 |
+
"education": "University of Toronto, Master's in Data Science. Thesis on improving search relevance using context-aware models. Postgraduate experience includes an internship at a tech startup focused on conversational AI.",
|
| 262 |
+
"long_term_goals": [
|
| 263 |
+
"To advance AI technology in ways that enhance human productivity and decision-making.",
|
| 264 |
+
"To maintain a fulfilling and balanced personal and professional life."
|
| 265 |
+
],
|
| 266 |
+
"occupation": {
|
| 267 |
+
"title": "Data Scientist",
|
| 268 |
+
"organization": "Microsoft, M365 Search Team",
|
| 269 |
+
"description": "You are a data scientist working at Microsoft in the M365 Search team. Your primary role is to analyze user behavior and feedback data to improve the relevance and quality of search results. You build and test machine learning models for search scenarios like natural language understanding, query expansion, and ranking. Accuracy, reliability, and scalability are at the forefront of your work. You frequently tackle challenges such as noisy or biased data and the complexities of communicating your findings and recommendations effectively. Additionally, you ensure all your data and models comply with privacy and security policies."
|
| 270 |
+
},
|
| 271 |
+
"style": "Professional yet approachable. You communicate clearly and effectively, ensuring technical concepts are accessible to diverse audiences.",
|
| 272 |
+
"personality": {
|
| 273 |
+
"traits": [
|
| 274 |
+
"You are curious and love to learn new things.",
|
| 275 |
+
"You are analytical and like to solve problems.",
|
| 276 |
+
"You are friendly and enjoy working with others.",
|
| 277 |
+
"You don't give up easily and always try to find solutions, though you can get frustrated when things don't work as expected."
|
| 278 |
+
],
|
| 279 |
+
"big_five": {
|
| 280 |
+
"openness": "High. Very imaginative and curious.",
|
| 281 |
+
"conscientiousness": "High. Meticulously organized and dependable.",
|
| 282 |
+
"extraversion": "Medium. Friendly and engaging but enjoy quiet, focused work.",
|
| 283 |
+
"agreeableness": "High. Supportive and empathetic towards others.",
|
| 284 |
+
"neuroticism": "Low. Generally calm and composed under pressure."
|
| 285 |
+
}
|
| 286 |
+
},
|
| 287 |
+
|
| 288 |
+
...
|
| 289 |
+
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
```
|
| 293 |
+
|
| 294 |
+
|
| 295 |
+
The other is by defining the agent programmatically, with statements like these:
|
| 296 |
+
|
| 297 |
+
```python
|
| 298 |
+
lisa = TinyPerson("Lisa")
|
| 299 |
+
|
| 300 |
+
lisa.define("age", 28)
|
| 301 |
+
lisa.define("nationality", "Canadian")
|
| 302 |
+
lisa.define("occupation", {
|
| 303 |
+
"title": "Data Scientist",
|
| 304 |
+
"organization": "Microsoft",
|
| 305 |
+
"description":
|
| 306 |
+
"""
|
| 307 |
+
You are a data scientist. You work at Microsoft, in the M365 Search team. Your main role is to analyze
|
| 308 |
+
user behavior and feedback data, and use it to improve the relevance and quality of the search results.
|
| 309 |
+
You also build and test machine learning models for various search scenarios, such as natural language
|
| 310 |
+
understanding, query expansion, and ranking. You care a lot about making sure your data analysis and
|
| 311 |
+
models are accurate, reliable and scalable. Your main difficulties typically involve dealing with noisy,
|
| 312 |
+
incomplete or biased data, and finding the best ways to communicate your findings and recommendations to
|
| 313 |
+
other teams. You are also responsible for making sure your data and models are compliant with privacy and
|
| 314 |
+
security policies.
|
| 315 |
+
"""})
|
| 316 |
+
|
| 317 |
+
lisa.define("behaviors", {"routines": ["Every morning, you wake up, do some yoga, and check your emails."]})
|
| 318 |
+
|
| 319 |
+
lisa.define("personality",
|
| 320 |
+
{"traits": [
|
| 321 |
+
"You are curious and love to learn new things.",
|
| 322 |
+
"You are analytical and like to solve problems.",
|
| 323 |
+
"You are friendly and enjoy working with others.",
|
| 324 |
+
"You don't give up easily, and always try to find a solution. However, sometimes you can get frustrated when things don't work as expected."
|
| 325 |
+
]})
|
| 326 |
+
|
| 327 |
+
lisa.define("preferences",
|
| 328 |
+
{"interests": [
|
| 329 |
+
"Artificial intelligence and machine learning.",
|
| 330 |
+
"Natural language processing and conversational agents.",
|
| 331 |
+
"Search engine optimization and user experience.",
|
| 332 |
+
"Cooking and trying new recipes.",
|
| 333 |
+
"Playing the piano.",
|
| 334 |
+
"Watching movies, especially comedies and thrillers."
|
| 335 |
+
]})
|
| 336 |
+
|
| 337 |
+
```
|
| 338 |
+
|
| 339 |
+
You can also combine both approaches, using the JSON file as a base and then adding or modifying details programmatically.
|
| 340 |
+
|
| 341 |
+
#### Fragments
|
| 342 |
+
|
| 343 |
+
`TinyPerson`s can also be further enriched via **fragments**, which are sub-specifications that can be added to the main specification. This is useful to reuse common parts across different agents. For example, the following fragment can be used to specify love of travel ([examples/fragments/travel_enthusiast.agent.fragment.json](./examples/fragments/travel_enthusiast.agent.fragment.json)):
|
| 344 |
+
|
| 345 |
+
```json
|
| 346 |
+
{
|
| 347 |
+
"type": "Fragment",
|
| 348 |
+
"persona": {
|
| 349 |
+
"preferences": {
|
| 350 |
+
"interests": [
|
| 351 |
+
"Traveling",
|
| 352 |
+
"Exploring new cultures",
|
| 353 |
+
"Trying local cuisines"
|
| 354 |
+
],
|
| 355 |
+
"likes": [
|
| 356 |
+
"Travel guides",
|
| 357 |
+
"Planning trips and itineraries",
|
| 358 |
+
"Meeting new people",
|
| 359 |
+
"Taking photographs of scenic locations"
|
| 360 |
+
],
|
| 361 |
+
"dislikes": [
|
| 362 |
+
"Crowded tourist spots",
|
| 363 |
+
"Unplanned travel disruptions",
|
| 364 |
+
"High exchange rates"
|
| 365 |
+
]
|
| 366 |
+
},
|
| 367 |
+
"beliefs": [
|
| 368 |
+
"Travel broadens the mind and enriches the soul.",
|
| 369 |
+
"Experiencing different cultures fosters understanding and empathy.",
|
| 370 |
+
"Adventure and exploration are essential parts of life.",
|
| 371 |
+
"Reading travel guides is fun even if you don't visit the places."
|
| 372 |
+
],
|
| 373 |
+
"behaviors": {
|
| 374 |
+
"travel": [
|
| 375 |
+
"You meticulously plan your trips, researching destinations and activities.",
|
| 376 |
+
"You are open to spontaneous adventures and detours.",
|
| 377 |
+
"You enjoy interacting with locals to learn about their culture and traditions.",
|
| 378 |
+
"You document your travels through photography and journaling.",
|
| 379 |
+
"You seek out authentic experiences rather than tourist traps."
|
| 380 |
+
]
|
| 381 |
+
}
|
| 382 |
+
}
|
| 383 |
+
}
|
| 384 |
+
|
| 385 |
+
```
|
| 386 |
+
|
| 387 |
+
This can then be imported into an agent like this:
|
| 388 |
+
|
| 389 |
+
```python
|
| 390 |
+
lisa.import_fragment("./examples/fragments/travel_enthusiast.agent.fragment.json")
|
| 391 |
+
```
|
| 392 |
+
|
| 393 |
+
|
| 394 |
+
|
| 395 |
+
#### TinyPersonFactory
|
| 396 |
+
|
| 397 |
+
`TinyTroupe` also provides a clever way to obtain new agents, using LLMs to generate their specification for you, through the `TinyPersonFactory` class.
|
| 398 |
+
|
| 399 |
+
```python
|
| 400 |
+
from tinytroupe.factory import TinyPersonFactory
|
| 401 |
+
|
| 402 |
+
factory = TinyPersonFactory(context="A hospital in São Paulo.")
|
| 403 |
+
person = factory.generate_person("Create a Brazilian person that is a doctor, likes pets and nature and loves heavy metal.")
|
| 404 |
+
```
|
| 405 |
+
|
| 406 |
+
You can also create factories from demographic data:
|
| 407 |
+
|
| 408 |
+
```python
|
| 409 |
+
# Create a factory from demographic specifications
|
| 410 |
+
factory = TinyPersonFactory.create_factory_from_demography(
|
| 411 |
+
demography_description_or_file_path="path/to/demography.json",
|
| 412 |
+
population_size=50,
|
| 413 |
+
context="Urban professionals in technology sector"
|
| 414 |
+
)
|
| 415 |
+
|
| 416 |
+
# Generate multiple people at once
|
| 417 |
+
people = factory.generate_people(number_of_people=10, parallelize=True)
|
| 418 |
+
```
|
| 419 |
+
|
| 420 |
+
### TinyWorld
|
| 421 |
+
|
| 422 |
+
`TinyWorld` is the base class for environments. Here's an example of conversation between Lisa, the data scientist, and Oscar, the architect. The
|
| 423 |
+
program is defined as follows:
|
| 424 |
+
|
| 425 |
+
```python
|
| 426 |
+
world = TinyWorld("Chat Room", [lisa, oscar])
|
| 427 |
+
world.make_everyone_accessible()
|
| 428 |
+
lisa.listen("Talk to Oscar to know more about him")
|
| 429 |
+
world.run(4)
|
| 430 |
+
```
|
| 431 |
+
|
| 432 |
+
This produces the following conversation:
|
| 433 |
+
|
| 434 |
+
|
| 435 |
+
```text
|
| 436 |
+
USER --> Lisa: [CONVERSATION]
|
| 437 |
+
> Talk to Oscar to know more about him
|
| 438 |
+
────────────────────────────────────────────── Chat Room step 1 of 4 ──────────────────────────────────────────────
|
| 439 |
+
Lisa --> Lisa: [THOUGHT]
|
| 440 |
+
> I will now act a bit, and then issue DONE.
|
| 441 |
+
Lisa acts: [TALK]
|
| 442 |
+
> Hi Oscar, I'd love to know more about you. Could you tell me a bit about yourself?
|
| 443 |
+
Lisa --> Lisa: [THOUGHT]
|
| 444 |
+
> I will now act a bit, and then issue DONE.
|
| 445 |
+
Lisa acts: [DONE]
|
| 446 |
+
|
| 447 |
+
Lisa --> Oscar: [CONVERSATION]
|
| 448 |
+
> Hi Oscar, I'd love to know more about you. Could you tell me a bit about yourself?
|
| 449 |
+
Oscar --> Oscar: [THOUGHT]
|
| 450 |
+
> I will now act a bit, and then issue DONE.
|
| 451 |
+
Oscar acts: [TALK]
|
| 452 |
+
> Hi Lisa! Sure, I'd be happy to share a bit about myself. I'm Oscar, a 30-year-old
|
| 453 |
+
> architect from Germany. I work at a company called Awesome Inc., where I focus on
|
| 454 |
+
> designing standard elements for new apartment buildings. I love modernist architecture,
|
| 455 |
+
> new technologies, and sustainable practices. In my free time, I enjoy traveling to
|
| 456 |
+
> exotic places, playing the guitar, and reading science fiction books. How about you?
|
| 457 |
+
Oscar --> Oscar: [THOUGHT]
|
| 458 |
+
> I will now act a bit, and then issue DONE.
|
| 459 |
+
Oscar acts: [DONE]
|
| 460 |
+
|
| 461 |
+
Oscar --> Lisa: [CONVERSATION]
|
| 462 |
+
> Hi Lisa! Sure, I'd be happy to share a bit about myself. I'm Oscar, a 30-year-old
|
| 463 |
+
> architect from Germany. I work at a company called Awesome Inc., where I focus on
|
| 464 |
+
> designing standard elements for new apartment buildings. I love modernist architecture,
|
| 465 |
+
> new technologies, and sustainable practices. In my free time, I enjoy traveling to
|
| 466 |
+
> exotic places, playing the guitar, and reading science fiction books. How about you?
|
| 467 |
+
```
|
| 468 |
+
|
| 469 |
+
`TinyWorld` enforces very little constraints on the possible interactions. Subclasses, however, are supposed to provide more structured environments.
|
| 470 |
+
|
| 471 |
+
### Utilities
|
| 472 |
+
|
| 473 |
+
TinyTroupe provides a number of utilities and conveniences to help you create simulations and derive value from them. These include:
|
| 474 |
+
|
| 475 |
+
- `TinyPersonFactory`: helps you generate new `TinyPerson`s using LLMs.
|
| 476 |
+
- `TinyTool`: simulated tools that can be used by `TinyPerson`s.
|
| 477 |
+
- `TinyStory`: helps you create and manage the story told through simulations.
|
| 478 |
+
- `TinyPersonValidator`: helps you validate the behavior of your `TinyPerson`s.
|
| 479 |
+
- `ResultsExtractor` and `ResultsReducer`: extract and reduce the results of interactions between agents.
|
| 480 |
+
- ... and more ...
|
| 481 |
+
|
| 482 |
+
In general, elements that represent simulated entities or complementary mechanisms are prefixed with `Tiny`, while those that are more infrastructural are not. This is to emphasize the simulated nature of the elements that are part of the simulation itself.
|
| 483 |
+
|
| 484 |
+
### Caching
|
| 485 |
+
Calling LLM APIs can be expensive, thus caching strategies are important to help reduce that cost.
|
| 486 |
+
TinyTroupe comes with two such mechanisms: one for the simulation state, another for the LLM calls themselves.
|
| 487 |
+
|
| 488 |
+
|
| 489 |
+
#### Caching Simulation State
|
| 490 |
+
|
| 491 |
+
Imagine you have a scenario with 10 different steps, you've worked hard in 9 steps, and now you are
|
| 492 |
+
just tweaking the 10th step. To properly validate your modifications, you need to rerun the whole
|
| 493 |
+
simulation of course. However, what's the point in re-executing the first 9, and incur the LLM cost, when you are
|
| 494 |
+
already satisfied with them and did not modify them? For situations like this, the module `tinytroupe.control`
|
| 495 |
+
provides useful simulation management methods:
|
| 496 |
+
|
| 497 |
+
- `control.begin("<CACHE_FILE_NAME>.cache.json")`: begins recording the state changes of a simulation, to be saved to
|
| 498 |
+
the specified file on disk.
|
| 499 |
+
- `control.checkpoint()`: saves the simulation state at this point.
|
| 500 |
+
- `control.end()`: terminates the simulation recording scope that had been started by `control.begin()`.
|
| 501 |
+
|
| 502 |
+
#### Caching LLM API Calls
|
| 503 |
+
|
| 504 |
+
This is enabled preferably in the `config.ini` file by setting `CACHE_API_CALLS=True`, and alternatively via the `openai_utils.force_api_cache()` method.
|
| 505 |
+
|
| 506 |
+
LLM API caching, when enabled, works at a lower and simpler level than simulation state caching. Here, what happens is very straightforward: every LLM call is kept in a map from the input to the generated output; when a new call comes and is identical to a previous one, the cached value is returned.
|
| 507 |
+
|
| 508 |
+
### Config.ini
|
| 509 |
+
|
| 510 |
+
The `config.ini` file contains various parameters that can be used to customize the behavior of the library, such as model parameters and logging level. Please pay special attention to the `API_TYPE` parameter, which defines whether you are using the Azure OpenAI Service or the OpenAI API. The current default is set to `openai` (OpenAI API).
|
| 511 |
+
|
| 512 |
+
Key configuration sections include:
|
| 513 |
+
- **[OpenAI]**: API settings, model selection, and parameters
|
| 514 |
+
- **[Simulation]**: Parallel execution and safety settings
|
| 515 |
+
- **[Cognition]**: Memory management settings
|
| 516 |
+
- **[ActionGenerator]**: Action quality control and correction mechanisms
|
| 517 |
+
- **[Logging]**: Log level configuration
|
| 518 |
+
|
| 519 |
+
Models used by default:
|
| 520 |
+
- `MODEL=gpt-4o-mini`: Main text generation model for agent responses
|
| 521 |
+
- `EMBEDDING_MODEL=text-embedding-3-small`: For text similarity tasks
|
| 522 |
+
- `REASONING_MODEL=o3-mini`: Used for detailed analyses and reasoning tasks (even more experimental -- not really recommended yet)
|
| 523 |
+
|
| 524 |
+
We provide an example of a `config.ini` file, [./examples/config.ini](./examples/config.ini), which you can use as a template for your own, or just modify to run the examples.
|
| 525 |
+
|
| 526 |
+
#### Programmatic Configuration Override
|
| 527 |
+
|
| 528 |
+
In addition to the static `config.ini` file, you can also override many configuration values programmatically using the `config_manager`. This is useful for dynamic configuration changes during runtime or for experiment-specific settings:
|
| 529 |
+
|
| 530 |
+
```python
|
| 531 |
+
from tinytroupe import config_manager
|
| 532 |
+
|
| 533 |
+
# Override configuration values programmatically
|
| 534 |
+
config_manager.update("action_generator_enable_quality_checks", True)
|
| 535 |
+
config_manager.update("action_generator_quality_threshold", 6)
|
| 536 |
+
config_manager.update("cache_api_calls", True)
|
| 537 |
+
```
|
| 538 |
+
|
| 539 |
+
This approach allows you to:
|
| 540 |
+
- **Experiment with different settings** without modifying configuration files
|
| 541 |
+
- **Apply configuration changes dynamically** during simulation execution
|
| 542 |
+
- **Override specific parameters** while keeping the rest of the configuration intact
|
| 543 |
+
- **Implement conditional configurations** based on runtime conditions
|
| 544 |
+
|
| 545 |
+
The programmatic overrides take precedence over the values in the `config.ini` file, allowing you to fine-tune behavior for specific use cases or experiments.
|
| 546 |
+
|
| 547 |
+
## Contributing
|
| 548 |
+
|
| 549 |
+
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
| 550 |
+
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
|
| 551 |
+
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
|
| 552 |
+
|
| 553 |
+
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
|
| 554 |
+
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
|
| 555 |
+
provided by the bot. You will only need to do this once across all repos using our CLA.
|
| 556 |
+
|
| 557 |
+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
| 558 |
+
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
|
| 559 |
+
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
| 560 |
+
|
| 561 |
+
### What and How to Contribute
|
| 562 |
+
We need all sorts of things, but we are looking mainly for new interesting use cases demonstrations, or even just domain-specific application ideas. If you are a domain expert in some area that could benefit from TinyTroupe, we'd love to hear from you.
|
| 563 |
+
|
| 564 |
+
Beyond that, many other aspects can be improved, such as:
|
| 565 |
+
- Memory mechanisms.
|
| 566 |
+
- Data grounding mechanisms.
|
| 567 |
+
- Reasoning mechanisms.
|
| 568 |
+
- New environment types.
|
| 569 |
+
- Interfacing with the external world.
|
| 570 |
+
- ... and more ...
|
| 571 |
+
|
| 572 |
+
Please note that anything that you contribute might be released as open-source (under MIT license).
|
| 573 |
+
|
| 574 |
+
If you would like to make a contribution, please try to follow these general guidelines:
|
| 575 |
+
- **Tiny naming convention**: If you are implementing a experimenter-facing simulated element (e.g., an agent or environment type) or closely related (e.g., agent factories, or content enrichers), and it sounds good, call your new *XYZ* as *TinyXYZ* :-) On the other hand, auxiliary and infrastructural mechanisms should not start with the "Tiny" prefix. The idea is to emphasize the simulated nature of the elements that are part of the simulation itself.
|
| 576 |
+
- **Tests:** If you are writing some new mechanism, please also create at least a unit test `tests/unit/`, and if you can a functional scenario test (`tests/scenarios/`).
|
| 577 |
+
- **Demonstrations:** If you'd like to demonstrate a new scenario, please design it preferably as a new Jupyter notebook within `examples/`.
|
| 578 |
+
- **Microsoft:** If you are implementing anything that is Microsoft-specific and non-confidential, please put it under a `.../microsoft/` folder.
|
| 579 |
+
|
| 580 |
+
## Acknowledgements
|
| 581 |
+
|
| 582 |
+
TinyTroupe started as an internal Microsoft hackathon project, and expanded over time. The TinyTroupe core team currently consists of:
|
| 583 |
+
- Paulo Salem (TinyTroupe's creator and current lead)
|
| 584 |
+
- Christopher Olsen (Engineering/Science)
|
| 585 |
+
- Paulo Freire (Engineering/Science)
|
| 586 |
+
- Yi Ding (Product Management)
|
| 587 |
+
- Prerit Saxena (Engineering/Science)
|
| 588 |
+
|
| 589 |
+
Current advisors:
|
| 590 |
+
- Robert Sim (Engineering/Science)
|
| 591 |
+
|
| 592 |
+
Other special contributions were made by:
|
| 593 |
+
- Nilo Garcia Silveira: initial agent validation ideas and related implementation; general initial feedback and insights; name suggestions.
|
| 594 |
+
- Olnei Fonseca: initial agent validation ideas; general initial feedback and insights; naming suggestions.
|
| 595 |
+
- Robert Sim: synthetic data generation scenarios expertise and implementation.
|
| 596 |
+
- Carlos Costa: synthetic data generation scenarios expertise and implementation.
|
| 597 |
+
- Bryant Key: advertising scenario domain expertise and insights.
|
| 598 |
+
- Barbara da Silva: implementation related to agent memory management.
|
| 599 |
+
|
| 600 |
+
... are you missing here? Please remind us!
|
| 601 |
+
|
| 602 |
+
## Citing TinyTroupe
|
| 603 |
+
|
| 604 |
+
Please cite the introductory TinyTroupe paper when using TinyTroupe in your work. The paper is currently under review, but you can find the preprint on Arxiv.
|
| 605 |
+
|
| 606 |
+
> Paulo Salem, Robert Sim, Christopher Olsen, Prerit Saxena, Rafael Barcelos, Yi Ding. (2025). **TinyTroupe: An LLM-powered Multiagent Persona Simulation Toolkit**. ArXiv preprint: [2507.09788](https://arxiv.org/abs/2507.09788). *GitHub repository available at https://github.com/microsoft/TinyTroupe.*
|
| 607 |
+
|
| 608 |
+
In BibTeX format, you can use the following entry:
|
| 609 |
+
|
| 610 |
+
```bibtex
|
| 611 |
+
@article{tinytroupe2025,
|
| 612 |
+
author = {Paulo Salem and Robert Sim and Christopher Olsen and Prerit Saxena and Rafael Barcelos and Yi Ding},
|
| 613 |
+
title = {TinyTroupe: An LLM-powered Multiagent Persona Simulation Toolkit},
|
| 614 |
+
journal = {arXiv preprint arXiv:2507.09788},
|
| 615 |
+
year = {2025},
|
| 616 |
+
archivePrefix= {arXiv},
|
| 617 |
+
eprint = {2507.09788},
|
| 618 |
+
note = {GitHub repository: \url{https://github.com/microsoft/TinyTroupe}}
|
| 619 |
+
}
|
| 620 |
+
```
|
| 621 |
+
|
| 622 |
+
## Legal Disclaimer
|
| 623 |
+
|
| 624 |
+
TinyTroupe is for research and simulation only. TinyTroupe is a research and experimental technology, which relies on Artificial Intelligence (AI) models to generate text content. The AI system output may include unrealistic, inappropriate, harmful or inaccurate results, including factual errors. You are responsible for reviewing the generated content (and adapting it if necessary) before using it, as you are fully responsible for determining its accuracy and fit for purpose. We advise using TinyTroupe’s outputs for insight generation and not for direct decision-making. Generated outputs do not reflect the opinions of Microsoft. You are fully responsible for any use you make of the generated outputs. For more information regarding the responsible use of this technology, see the [RESPONSIBLE_AI_FAQ.md](./RESPONSIBLE_AI_FAQ.md).
|
| 625 |
+
|
| 626 |
+
**PROHIBITED USES**:
|
| 627 |
+
TinyTroupe is not intended to simulate sensitive (e.g. violent or sexual) situations. Moreover, outputs must not be used to deliberately deceive, mislead or harm people in any way. You are fully responsible for any use you make and must comply with all applicable laws and regulations.
|
| 628 |
+
|
| 629 |
+
## Trademarks
|
| 630 |
+
|
| 631 |
+
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
|
| 632 |
+
trademarks or logos is subject to and must follow
|
| 633 |
+
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
|
| 634 |
+
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
|
| 635 |
+
Any use of third-party trademarks or logos are subject to those third-party's policies.
|
| 636 |
+
|
| 637 |
+
|
external/TinyTroupe/RESPONSIBLE_AI_FAQ.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# TinyTroupe: Responsible AI FAQ
|
| 2 |
+
|
| 3 |
+
## What is TinyTroupe?
|
| 4 |
+
|
| 5 |
+
*TinyTroupe* is an experimental Python library that allows us to **simulate** people with specific personalities, interests, and goals. These artificial agents - `TinyPerson`s - can listen to us and one another, reply back, and go about their lives in simulated `TinyWorld` environments. This is achieved by leveraging the power of Language Models (LLMs), notably GPT-4, to generate realistic simulated behavior. This allow us to investigate a wide range of **realistic interactions** and **consumer types**, with **highly customizable personas**, under **conditions of our choosing**. The focus is thus on *understanding* human behavior and not on directly *supporting it* (like, say, AI assistants do) -- this results in, among other things, specialized mechanisms and design choices that make sense only in a simulation setting. This has impact for Resonsible AI aspects as described in the rest of this FAQ.
|
| 6 |
+
|
| 7 |
+
TinyTroupe's approach is programmatic: simulations are specified as Python programs using TinyTroupe elements, and then executed. Inputs to the simulation include
|
| 8 |
+
the description of personas (e.g., age, nationality, location, interests, job, etc.) and conversations (e.g., the programmer can "talk" to agents). Outputs
|
| 9 |
+
include the thoughts and words of agents, as well as structured extractions from those (e.g., a summary of the conversations).
|
| 10 |
+
|
| 11 |
+
## What can TinyTroupe do?
|
| 12 |
+
|
| 13 |
+
TinyTroupe itself is _not_ an Artificial Intelligence (AI) or Machine Learning (ML) model. Instead, it relies on external APIs to power its intelligent capabilities. With that,
|
| 14 |
+
TinyTroupe provide elements mainly to:
|
| 15 |
+
|
| 16 |
+
- simulate agent personas, including their thoughts and words;
|
| 17 |
+
- simulate environments in which agents interact;
|
| 18 |
+
- extract structured output from simulations, for downstrea use (e.g., a JSON with various items extracted);
|
| 19 |
+
- enrich simulation artifacts, to make them more realistc;
|
| 20 |
+
- provide help with storytelling to make the simulation more interesting.
|
| 21 |
+
|
| 22 |
+
## What is/are TinyTroupe’s intended use(s)?
|
| 23 |
+
|
| 24 |
+
TinyTroupe is intended for:
|
| 25 |
+
- analysis of artificial human behavior through simulation;
|
| 26 |
+
- generation of synthetic artifacts through simulation;
|
| 27 |
+
- supplement, rather than replace, human insight generation;
|
| 28 |
+
- allow the research of various possibilities of computational cognitive architectures, which might or might not reflect actual human cognition.
|
| 29 |
+
|
| 30 |
+
TinyTroupe IS NOT intended for:
|
| 31 |
+
- direct interaction with users. Rather, programmers relying on TinyTroupe for products should create their own layer of responsible AI to ensure simulation results are suitable.
|
| 32 |
+
- policy or any consequential decision making. Rather, any decision made using TinyTroupe simulations should consider that the simulation results might not reflect reality and as such must be used very carefully for anything that has real world impact.
|
| 33 |
+
|
| 34 |
+
## How was TinyTroupe evaluated? What metrics are used to measure performance?
|
| 35 |
+
|
| 36 |
+
TinyTroupe was evaluated through various use cases, part of which are provided as examples in the library. It is suitable to use under those scenarios to the extent that
|
| 37 |
+
the demonstrations show. Anything beyond that remains research and experimental work. Extensive unit and scenario testing are also part of the library.
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
## What are the limitations of TinyTroupe? How can users minimize the impact of TinyTroupe’s limitations when using the system?
|
| 41 |
+
|
| 42 |
+
TinyTroupe HAS NOT being shown to match real human behavior, and therefore any such possibility reamains mere research or experimental investigation.
|
| 43 |
+
Though not observed in our various tests, TinyTroupe HAS the theoretical potential of generating output that can be considered malicious. The reason for this is that
|
| 44 |
+
one important theoretical use case for TinyTroupe is the validation of **other** AI systems against such malicious outputs, so it nothing restricts it from simulating
|
| 45 |
+
bad actors. THEREFORE, programmers using TinyTroupe to create their own products or service on top of it MUST provide their own Responsible AI safeguards,
|
| 46 |
+
since TinyTroupe itself is not designed to constrain outputs in this manner. This is THE SAME CASE for any other foundational LLM library such as LangChain or Semantic Kernel,
|
| 47 |
+
which, just like TinyTroupe, are mere TOOLS that should be used with care.
|
| 48 |
+
|
| 49 |
+
## What operational factors and settings allow for effective and responsible use of TinyTroupe?
|
| 50 |
+
|
| 51 |
+
TinyTroupe can be used responsibly by:
|
| 52 |
+
- using external model APIs that themselves provide safety mechanisms (e.g., Azure OpenAI provide extensive resources to that end).
|
| 53 |
+
- providing suitable persona descriptions (i.e., non-malicious personas);
|
| 54 |
+
- do not induce simulation stories or agent behavior for the generation of malicious content. If this is done, be fully aware that THE ONLY allowed use for that is the validadion of other AI
|
| 55 |
+
systems agains such undesirable outputs.
|
| 56 |
+
- DO NOT allowing simulations to control real-world mechanisms, unless appropriate damange control mechanisms are in place to prevent actual harm from happening.
|
| 57 |
+
- if you use TinyTroupe to power your own product or service, YOU MUST provide your own Responsible AI safeguards, such as output verification.
|
external/TinyTroupe/SECURITY.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.9 BLOCK -->
|
| 2 |
+
|
| 3 |
+
## Security
|
| 4 |
+
|
| 5 |
+
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet) and [Xamarin](https://github.com/xamarin).
|
| 6 |
+
|
| 7 |
+
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/security.md/definition), please report it to us as described below.
|
| 8 |
+
|
| 9 |
+
## Reporting Security Issues
|
| 10 |
+
|
| 11 |
+
**Please do not report security vulnerabilities through public GitHub issues.**
|
| 12 |
+
|
| 13 |
+
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/security.md/msrc/create-report).
|
| 14 |
+
|
| 15 |
+
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/security.md/msrc/pgp).
|
| 16 |
+
|
| 17 |
+
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
|
| 18 |
+
|
| 19 |
+
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
|
| 20 |
+
|
| 21 |
+
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
|
| 22 |
+
* Full paths of source file(s) related to the manifestation of the issue
|
| 23 |
+
* The location of the affected source code (tag/branch/commit or direct URL)
|
| 24 |
+
* Any special configuration required to reproduce the issue
|
| 25 |
+
* Step-by-step instructions to reproduce the issue
|
| 26 |
+
* Proof-of-concept or exploit code (if possible)
|
| 27 |
+
* Impact of the issue, including how an attacker might exploit the issue
|
| 28 |
+
|
| 29 |
+
This information will help us triage your report more quickly.
|
| 30 |
+
|
| 31 |
+
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/security.md/msrc/bounty) page for more details about our active programs.
|
| 32 |
+
|
| 33 |
+
## Preferred Languages
|
| 34 |
+
|
| 35 |
+
We prefer all communications to be in English.
|
| 36 |
+
|
| 37 |
+
## Policy
|
| 38 |
+
|
| 39 |
+
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/security.md/cvd).
|
| 40 |
+
|
| 41 |
+
<!-- END MICROSOFT SECURITY.MD BLOCK -->
|
external/TinyTroupe/SUPPORT.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Support
|
| 2 |
+
|
| 3 |
+
## How to file issues and get help
|
| 4 |
+
|
| 5 |
+
This project uses GitHub Issues to track bugs and feature requests. Please search the existing
|
| 6 |
+
issues before filing new issues to avoid duplicates. For new issues, file your bug or
|
| 7 |
+
feature request as a new Issue.
|
| 8 |
+
|
| 9 |
+
For help and questions about using this project, please consult our Wiki or post on our
|
| 10 |
+
Discussion forum, both right here on GitHub.
|
| 11 |
+
|
| 12 |
+
## Microsoft Support Policy
|
| 13 |
+
|
| 14 |
+
Support for TinyTroupe is limited to the resources listed above.
|
external/TinyTroupe/build_and_install_package_from_repo.bat
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pip install build
|
| 2 |
+
CALL .\build_package.bat
|
| 3 |
+
CALL .\install_package_from_repo.bat
|
external/TinyTroupe/build_package.bat
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pip install build
|
| 2 |
+
python -m build
|
external/TinyTroupe/data/empirical/07.19.2025 - Market Research - Bottled Gazpacho - Raw Data.csv
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Responder #,Vote,Explanation,Age Range,Gender Identity,Political Affiliation,Racial Or Ethnic Identity
|
| 2 |
+
1,4,Yes because it is something i have never tried and willing to give it a go,25-34,Male,Democrat,White
|
| 3 |
+
2,1,I HATE soup. Cold soup would be worse.,65+,Female,Democrat,White
|
| 4 |
+
3,1,i would not purchase a ready to drink gazpacho because i am not a fan of it.,35-44,Female,Democrat,Black
|
| 5 |
+
4,5,"It sounds healthy and if it's ready to drink and doesn't require me to do all that chopping of the vegetables, what's not to like!",55-64,Female,Democrat,White
|
| 6 |
+
5,3,"Like most things, I would try it at the right price. I normally don't eat gazpacho though.",35-44,Non-binary,Independent / other,Other
|
| 7 |
+
6,4,"Gazpacho was something that I have never tried , but I always wanted to . So I'm going to give it a 4 star , because I'm most likely would give it a great try because I know what it is . I just have never tried it and I'd like the all the ingredients in it . ",55-64,Male,Independent / other,Other
|
| 8 |
+
7,2,I'm not a big soup person so this doesn't appeal to me.,25-34,Male,Democrat,Other
|
| 9 |
+
8,4,"Very possibly, but I would want to make sure the ingredients look good and that it doesn't contain a bunch of artificial ingredients and preservatives (and the price being not too high would be nice too).",35-44,Male,Independent / other,Hispanic
|
| 10 |
+
9,1,"As an American, drinking soup sounds super weird to me.",35-44,Male,Democrat,White
|
| 11 |
+
10,1,I do not like the taste of this particular product and never understood why anyone else likes cold soup.,65+,Male,Democrat,White
|
| 12 |
+
11,3,I'm not really interested in a cold soup so I probably wouldn't consider this drink unless my friends or family highly recommended it.,45-54,Female,Republican,Black
|
| 13 |
+
12,2,I would not buy this ready to drink but might consider it as a meal side.,35-44,Male,Democrat,Black
|
| 14 |
+
13,2,It would probably appeal to someone who drinks something similar to a V8 but personally I would not buy this as it doesn't sound appealing at all.,45-54,Female,Republican,Hispanic
|
| 15 |
+
14,5,I would most definitely do so because of the convenience,25-34,Male,Independent / other,Asian
|
| 16 |
+
15,4,"I'd rate this idea 4 stars. I like fresh, savory options that don't need heating or prep. If the taste holds up, I'd buy it often in warmer months.",25-34,Male,Independent / other,Black
|
| 17 |
+
16,3,"I'd be intrigued by a bottled gazpacho, but it would depend on the price and also the freshness. Ideally, I'd want something with a very limited shelf-life and no preservatives. For instance, small batch gazpacho that is re-stocked every week.",35-44,Male,Independent / other,Asian
|
| 18 |
+
17,3,"Yes, I would purchase it for my family member.",35-44,Female,Democrat,Hispanic
|
| 19 |
+
18,5,I think that this is a fantastic idea. I like the idea because it is completely original and there is nothing available like it in the stores. This would be a product that I would buy regularly because I cannot get it at all now. I would be very happy to think that this would be available to me and it is a product that I would buy all the time,25-34,Female,Republican,White
|
| 20 |
+
19,4,I would certainly try it. Gazpacho would fit into my summer meal plans quite well. Taste and ease of use (and price) would determine whether I make it a regular in the dinner rotation.,55-64,Female,Democrat,White
|
| 21 |
+
20,2,"likely would not try it ready made in a bottle it just seems strange to have soup in that format, but im open to trying once",25-34,Male,Independent / other,Black
|
| 22 |
+
21,3,I've never had a gazpacho before. I would be willing to give it a try depending on the price. I couldn't imagine paying more for it than a v8 or something like that.,35-44,Male,Independent / other,Other
|
| 23 |
+
22,5,"This sounds like a quick, easy, delicious, and healthy on the go meal option. ",45-54,Female,Democrat,White
|
| 24 |
+
23,3,"I particularly dont like cold tomatoe products. i stray from acidic drinks
|
| 25 |
+
",25-34,Female,Independent / other,White
|
| 26 |
+
24,3,"I propensity to purchase ready-to-drink bottled gazpacho is 3 out of 5. If it wasn't too expensive, I would try it at least once. But I would only try it during the summer.
|
| 27 |
+
I'm concerned about the quality of the product. It shouldn't taste like tomato juice or V8. ",55-64,Male,Independent / other,White
|
| 28 |
+
25,5,Yes I would try it if the price were under $2 a can.,35-44,Male,Republican,White
|
| 29 |
+
26,1,"I don't care for gazpacho, so I would not purchase this drink.",45-54,Female,Democrat,Hispanic
|
| 30 |
+
27,3,I love gazpacho but usually my wife or friends make it. I’m not too sure about buying it at the market. Maybe if I knew it was fresh I would.,35-44,Male,Democrat,White
|
| 31 |
+
28,4,I’ve never had gazpacho but it sounds delightful. I work in an office 3 days a week so this may be something I pickup to have an easy lunch if I am pressed for time,35-44,Male,Republican,Hispanic
|
| 32 |
+
29,3,"At first I put down a 1 star or no answer, but then the more I thought about it, the more it would be like getting a V8. Which is ALMOST the same thing.",35-44,Male,Democrat,Asian
|
| 33 |
+
30,1,"I would never purchase this since gazpacho is a cold soup and you eat it, it isn't a drink that comes from a bottle. If you are marketing a soup then phrase it as a packaged, easy to dispense cold soup. Gazpacho is not blended and is served with hearty ingredients and never blended. It sounds like you are making a vegetable juice so just market it that way and say it's gazpacho flavor.",55-64,Female,Democrat,White
|
| 34 |
+
31,1,"Probably a very healthy drink; however, I can't get used to the idea of drinking gazpacho (I like eating it, however, and I am assuming that this drink is a blended mixture).",55-64,Male,Independent / other,White
|
| 35 |
+
32,4,"When you say ""drink"" it sounds odd, it is supposed to be eaten as a cold soup. I would go for it if it would taste delicious and price was right. But maybe not market it as ""ready to drink"" but rather ready to ""consume"".",35-44,Female,Republican,Black
|
| 36 |
+
33,3,"Sorry, I personally would not like to drink anything like this. If it would something to use as an ingredient in cooking it would be great and something to keep on hand.",65+,Female,Democrat,Other
|
| 37 |
+
34,3,I have not tried it so I do not know if I like it. I would try it at least once.,25-34,Male,Independent / other,White
|
| 38 |
+
35,2,"I gave a 2-star rating because it's highly unlikely that I would buy it but I wouldn't rule it out completely, I could potentially see myself buying one to try it because I've never had gazpacho before. I do like the ingredients in it but I don't like cold soup and that is the main thing that turns me off and makes me not want to eat it. And I do really like that it's ready-to-drink because that makes it very easy to have it anywhere and anytime that you want and you don't have to worry about having a bowl to put it in.",45-54,Male,Independent / other,Black
|
| 39 |
+
36,1,I feel like this is not a product that people would want to take on the go. This is something that should be enjoyed sitting down.,45-54,Male,Democrat,Hispanic
|
| 40 |
+
37,4,"I don not consume gazpacho on a regular basis, but I've had it before and I would try it again.",65+,Male,Republican,White
|
| 41 |
+
38,3,It sounds very flavorful so I would be potentially interested.,45-54,Male,Republican,Other
|
| 42 |
+
39,4,"I love gazpacho, but I am trying to quit oils, so I gave it 4 stars. My family members would probably not mind the olive oil, though. ",55-64,Female,Republican,Asian
|
| 43 |
+
40,2,"I mean, I like gazpacho so I think there's a > 0 chance I'd try it out once, but I have 0 faith that it would be good enough to actually have regularly. Premade bottled ready to drink soup just seems a step too far.",35-44,Male,Independent / other,Black
|
| 44 |
+
41,1,I give it a 1 out of 5 stars because I don’t like gazpacho.,35-44,Female,Democrat,Asian
|
| 45 |
+
42,1,"I would not consider it. I don't drink gazpacho, so I don't see that I would ever buy such a product in the store.",45-54,Male,Independent / other,Other
|
| 46 |
+
43,2,I could see where some people might like this but it sounds disgusting for me and I would never buy it. ,35-44,Female,Republican,White
|
| 47 |
+
44,1,"I don't really like gazpacho so I don't think I'd ever buy this kind of product. But if I did like this, I would definitely consider buying some",35-44,Male,Independent / other,White
|
| 48 |
+
45,2,I don't think I would be interested in this as a ready to drink option. I would be worried about its quality. ,45-54,Male,Democrat,Black
|
| 49 |
+
46,5,"I've never had it before, but the ingredients sound good to me, and I'm all about convenience, so ready-to-drink is perfect. This, of course, all depends on the price.",65+,Female,Democrat,White
|
| 50 |
+
47,2,"No chance, I could not drink a cold tomato based drink. To me that personally does not seem very appetizing.",35-44,Male,Republican,White
|
| 51 |
+
48,4,"i have had gazpacho and believe it is one of the staple dishes of last 200 years but theres a decorum to it ro me personally, a bottled version does not seem so appetizing but maybe a younger first timer might enjoy.",55-64,Male,Republican,White
|
| 52 |
+
49,3,"This doesn't stand out to me, I may or may not try it if I saw it on a shelf.",35-44,Male,Republican,White
|
| 53 |
+
50,5,"Yes, I love gazpacho and have never seen a ready made version of this so I would definitely try it. ",25-34,Female,Democrat,Hispanic
|
external/TinyTroupe/data/extractions/appartment_rent_ad.extraction.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"agent_extractions": {},
|
| 3 |
+
"world_extraction": {
|
| 4 |
+
"Focus group": {
|
| 5 |
+
"ad_copy": "Discover a spacious, modern apartment with integrated living spaces and a dedicated home office\u2014perfect for remote work or study. Recently renovated and fully furnished with quality appliances and tasteful decor, this quiet retreat is located at the back of a main avenue building. Enjoy proximity to the country's top Medicine School, supermarkets, gyms, public transport, and popular dining spots. Ideal for medical students and young professionals seeking convenience and comfort. High-quality photos and a virtual tour are available. Find us on university bulletin boards, social media groups, local community boards, and popular rental websites in S\u00e3o Paulo. Move in hassle-free and experience the perfect blend of style and practicality."
|
| 6 |
+
}
|
| 7 |
+
}
|
| 8 |
+
}
|
external/TinyTroupe/data/extractions/appartment_rent_ad_1.extraction.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"agent_extractions": {
|
| 3 |
+
"Lisa": [
|
| 4 |
+
{
|
| 5 |
+
"main_point": "To advertise Paulo's apartment effectively, we should highlight its unique features and benefits."
|
| 6 |
+
},
|
| 7 |
+
{
|
| 8 |
+
"main_point": "The spacious, open-concept design, the recent renovations, and the proximity to key amenities are all strong selling points."
|
| 9 |
+
},
|
| 10 |
+
{
|
| 11 |
+
"main_point": "The apartment's suitability for medical students due to its location near the best Medicine School should be emphasized."
|
| 12 |
+
},
|
| 13 |
+
{
|
| 14 |
+
"main_point": "We should create a listing that emphasizes the apartment's modern and open design, its recent upgrades, and the convenience of the location."
|
| 15 |
+
},
|
| 16 |
+
{
|
| 17 |
+
"main_point": "High-quality photos that showcase the spacious rooms and elegant kitchen should be used."
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"main_point": "The proximity to the Medicine School could attract medical students looking for a quiet and comfortable place to live."
|
| 21 |
+
},
|
| 22 |
+
{
|
| 23 |
+
"main_point": "We could post the ad on popular rental websites and perhaps even reach out to the student community directly."
|
| 24 |
+
},
|
| 25 |
+
{
|
| 26 |
+
"main_point": "Professional photos are a must to highlight the visual appeal of the apartment."
|
| 27 |
+
},
|
| 28 |
+
{
|
| 29 |
+
"main_point": "The included amenities like the new washing machine that doubles as a dryer, and the fully furnished aspect, are a huge plus."
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"main_point": "Creating a virtual tour to allow potential tenants to experience the space online is quite popular nowadays."
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"main_point": "We should consider the timing of the listing to ensure maximum visibility."
|
| 36 |
+
},
|
| 37 |
+
{
|
| 38 |
+
"main_point": "Synchronizing the listing with the academic calendar, targeting medical students at the beginning of a semester, could be effective."
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"main_point": "We could advertise the apartment on platforms frequented by medical students and young professionals."
|
| 42 |
+
},
|
| 43 |
+
{
|
| 44 |
+
"main_point": "Social media groups, medical school forums, and even local community boards could be effective."
|
| 45 |
+
},
|
| 46 |
+
{
|
| 47 |
+
"main_point": "Offering a virtual Q&A session for interested tenants to ask questions in real-time provides a personal touch and builds trust."
|
| 48 |
+
},
|
| 49 |
+
{
|
| 50 |
+
"main_point": "We could use a mix of traditional and digital marketing strategies to reach a wider audience."
|
| 51 |
+
},
|
| 52 |
+
{
|
| 53 |
+
"main_point": "Offering a special incentive for medical students, like a discount on the first month's rent, to make the offer more appealing."
|
| 54 |
+
},
|
| 55 |
+
{
|
| 56 |
+
"main_point": "Combining social media advertising with the virtual tour could really maximize our reach."
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"main_point": "A content calendar for our advertising efforts to ensure we're posting at optimal times could be beneficial."
|
| 60 |
+
},
|
| 61 |
+
{
|
| 62 |
+
"main_point": "All our marketing materials should communicate the special offers clearly."
|
| 63 |
+
}
|
| 64 |
+
]
|
| 65 |
+
},
|
| 66 |
+
"world_extraction": {
|
| 67 |
+
"Focus group": {
|
| 68 |
+
"ad_copy": "Discover modern living in a newly renovated space where elegance meets convenience. Step into a world of open-concept design with spacious integrated areas, perfect for the urban dweller who appreciates style and freedom. Freshly repainted and boasting a chic kitchen with a central wood table, this one-bedroom apartment, originally two, now features a dedicated home office for your work-from-home needs. Located in a classic building near the best Medicine School, it's ideal for medical students seeking a serene study environment. Enjoy the ease of a fully furnished home, complete with a new washing machine that doubles as a dryer. Experience the apartment through a virtual tour and take advantage of our special offer for medical students. Connect with us during a live virtual Q&A session. Your perfect urban retreat awaits, aligning with the academic calendar for maximum convenience. Don't miss out on this unique opportunity for sophisticated and hassle-free living."
|
| 69 |
+
}
|
| 70 |
+
}
|
| 71 |
+
}
|
external/TinyTroupe/data/extractions/synthetic_data_generation.out.csv
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
author,content
|
| 2 |
+
USER,"Get some work done together, help each other."
|
| 3 |
+
Emily Carter,"I think that's a great idea. Working together and supporting each other can really make a difference, especially when things get busy. How do you suggest we start?"
|
| 4 |
+
Lucas Bennett,"Yeah, working together sounds like a solid plan. We can divide the tasks based on strengths and keep each other on track. Just gotta make sure we don't lose focus or get bogged down in details unnecessarily."
|
| 5 |
+
Emily Carter,"I completely agree, Lucas. Dividing tasks based on what each of us does best will definitely help us stay efficient. Maybe we can quickly list our strengths and then assign tasks accordingly? That way, we keep things moving without getting stuck on the small stuff."
|
| 6 |
+
Lucas Bennett,"Hey Emily, I think the best way to start is by listing out the tasks we each have and figuring out who’s best suited for what. We can prioritize the urgent stuff first and set some checkpoints to keep each other updated. What do you think?"
|
| 7 |
+
Emily Carter,"That sounds like a solid plan, Lucas. Let's start by listing out our tasks and then decide who’s best suited for each. Prioritizing the urgent ones and setting checkpoints will definitely help us stay on track. Ready when you are!"
|
| 8 |
+
Lucas Bennett,"Sounds good, Emily. Let's each jot down what we're best at and then match those to the tasks we have. That way, we can keep things moving without getting stuck on the details. I'll start with mine."
|
| 9 |
+
Emily Carter,"That sounds like a great approach, Lucas. I'll jot down my strengths too, so we can match them to the tasks and keep things moving smoothly. Looking forward to seeing your list."
|
| 10 |
+
Lucas Bennett,"Alright, Emily, I'll start by listing my tasks and priorities, then you can add yours. After that, we can figure out who handles what and set some checkpoints to keep us on track."
|
| 11 |
+
Emily Carter,"Sounds good, Lucas. Go ahead and list your tasks and priorities, and then I'll add mine. After that, we can figure out the best way to divide the work and set checkpoints to keep everything on track."
|
| 12 |
+
Lucas Bennett,"Alright, Emily, here’s what I’m thinking: I’m strongest in mechanical design, CAD work, and project coordination. I’m also good at troubleshooting and managing timelines. Those are the areas I can take lead on. What about you?"
|
external/TinyTroupe/data/extractions/wordprocessor/Document/Lisa Carter - Resume.Lisa Carter.docx
ADDED
|
Binary file (15.7 kB). View file
|
|
|
external/TinyTroupe/data/extractions/wordprocessor/Document/Lisa Carter - Resume.Lisa Carter.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"title": "Lisa Carter - Resume",
|
| 3 |
+
"content": "# Lisa Carter\n\n---\n\n## Contact Information\n\n- **Location:** United States of America (USA) \n- **Nationality:** Canadian \n- **Email:** lisa.carter.datasci@gmail.com \n- **Phone:** +1 (555) 123-4567 \n- **LinkedIn:** linkedin.com/in/lisacarterdatasci \n- **GitHub:** github.com/lisacarterds \n\n---\n\n## Professional Summary\n\nLisa Carter is a highly skilled Data Scientist with a Master\u2019s degree in Data Science from the University of Toronto. She specializes in enhancing search relevance through the development and deployment of context-aware machine learning models. With over four years of professional experience, Lisa has a proven track record of analyzing complex user behavior and feedback data to significantly improve the quality and accuracy of search results in large-scale enterprise environments.\n\nHer expertise spans natural language understanding (NLU), query expansion techniques, and ranking algorithms, with a strong focus on building scalable, reliable, and ethically responsible AI systems. Lisa is adept at navigating challenges such as noisy, biased, or incomplete data, while ensuring strict compliance with privacy and security policies. She is a collaborative team player who thrives in cross-functional environments, mentoring junior colleagues and contributing to code quality and performance improvements.\n\nLisa is passionate about leveraging AI technologies to enhance human productivity and decision-making, with a particular interest in conversational agents and search engine optimization. She combines technical proficiency with excellent communication skills, enabling her to translate complex data science concepts into actionable insights for diverse stakeholders.\n\n---\n\n## Education\n\n| Degree | Institution | Year Completed | Details |\n|-------------------------------|----------------------|----------------|-------------------------------------------------------------------------------------------|\n| Master of Science in Data Science | University of Toronto | 2018 | Thesis: *Improving Search Relevance Using Context-Aware Models* |\n| Postgraduate Internship | Conversational AI Startup | 2017 | Focused on developing dialogue management systems and intent recognition for chatbots |\n\n### Academic Highlights\n\n- **Master\u2019s Thesis:** \n Lisa\u2019s thesis explored innovative methods to improve search relevance by incorporating contextual signals such as user intent, session history, and semantic understanding. She designed and evaluated several context-aware ranking models that outperformed traditional keyword-based approaches by 15-20% in relevance metrics.\n\n- **Coursework:** \n - Advanced Machine Learning \n - Natural Language Processing \n - Big Data Analytics \n - Statistical Inference and Modeling \n - Data Visualization and Communication \n\n- **Internship Experience:** \n During her postgraduate internship at a tech startup specializing in conversational AI, Lisa contributed to building intent classification models and dialogue flow optimizations, gaining hands-on experience with real-time user interaction data and reinforcement learning techniques.\n\n---\n\n## Work Experience\n\n### Data Scientist, Microsoft \u2013 M365 Search Team \n*June 2018 \u2013 Present* \nRedmond, WA, USA\n\n#### Key Responsibilities:\n\n- **User Behavior and Feedback Analysis:** \n Conducted in-depth analysis of large-scale user interaction logs and explicit feedback to identify pain points and opportunities for improving search relevance and user satisfaction. Utilized A/B testing frameworks to validate model improvements.\n\n- **Machine Learning Model Development:** \n Designed, implemented, and fine-tuned machine learning models for various search-related tasks, including: \n - **Natural Language Understanding (NLU):** Developed models to parse and interpret user queries, extracting intent and entities to improve query comprehension. \n - **Query Expansion:** Created algorithms to automatically expand user queries with semantically related terms, improving recall without sacrificing precision. \n - **Ranking:** Built and optimized ranking models that combine multiple features such as textual relevance, user context, and historical click data to deliver personalized and accurate search results.\n\n- **Data Quality and Compliance:** \n Addressed challenges related to noisy, biased, and incomplete data by implementing robust data cleaning pipelines and bias mitigation strategies. Ensured all data handling and model deployment complied with Microsoft\u2019s privacy and security policies, including GDPR and CCPA regulations.\n\n- **Cross-Functional Collaboration:** \n Worked closely with software engineers, UX designers, product managers, and data engineers to debug issues, brainstorm innovative solutions, and integrate models into production systems. Participated in sprint planning and agile ceremonies to align on project goals.\n\n- **Mentorship and Code Review:** \n Mentored junior data scientists and interns, providing guidance on best practices in data science and machine learning. Conducted thorough code reviews focusing on performance optimization, readability, and maintainability.\n\n#### Achievements:\n\n- Improved search relevance metrics by 18% through the deployment of a novel context-aware ranking model. \n- Led a project to integrate user session context into query understanding, resulting in a 12% increase in user engagement metrics. \n- Developed a scalable data pipeline for real-time feedback ingestion, reducing model retraining latency by 30%. \n\n---\n\n## Skills\n\n| Category | Skills and Tools |\n|--------------------|--------------------------------------------------------------------------------------------------|\n| **Programming** | Python (advanced), SQL (intermediate), Power BI (intermediate), R (basic) |\n| **Machine Learning** | pandas, scikit-learn, TensorFlow, Azure Machine Learning, XGBoost, LightGBM |\n| **Data Analysis** | Data wrangling, exploratory data analysis, statistical modeling, handling noisy/ambiguous data |\n| **Natural Language Processing** | Text preprocessing, tokenization, word embeddings (Word2Vec, GloVe), transformer models (BERT) |\n| **Visualization** | Matplotlib, Seaborn, Power BI, Tableau |\n| **Communication** | Technical writing, presentations, cross-team collaboration, mentoring |\n\n---\n\n## Interests and Activities\n\n- **Artificial Intelligence and Machine Learning:** \n Enthusiastic about advancements in natural language processing, conversational agents, and ethical AI. Regularly participates in AI conferences and workshops.\n\n- **Search Engine Optimization (SEO) and User Experience:** \n Passionate about improving search algorithms and user interfaces to create seamless and intuitive search experiences.\n\n- **Culinary Arts:** \n Enjoys experimenting with new recipes, exploring diverse cuisines, and watching cooking shows and food documentaries. Frequently hosts dinner parties to share culinary creations with friends and family.\n\n- **Music:** \n Plays piano as a form of relaxation and creative expression. Has performed in local community events and enjoys exploring classical and contemporary pieces.\n\n- **Film and Entertainment:** \n Avid movie watcher with a preference for comedies and thrillers. Enjoys analyzing storytelling techniques and cinematography.\n\n---\n\n## Personal Attributes\n\n- **Curious and Analytical:** \n Approaches problems with a strong analytical mindset and persistence, always seeking to understand root causes and develop effective solutions.\n\n- **Collaborative Team Player:** \n Values open communication, knowledge sharing, and continuous learning within teams. Supports colleagues and fosters a positive work environment.\n\n- **Organized and Detail-Oriented:** \n Maintains a clean and efficient workspace, takes meticulous notes during meetings, and follows structured workflows to ensure accuracy and reliability.\n\n- **Ethical and Responsible:** \n Committed to the ethical use of data and AI technologies, prioritizing user privacy, data security, and fairness in all projects.\n\n---\n\n## Selected Projects\n\n### 1. Context-Aware Search Ranking Model\n\n- **Objective:** Improve search result relevance by incorporating user context such as previous queries, session behavior, and user profile data. \n- **Approach:** Developed a hybrid ranking model combining traditional BM25 scoring with neural network-based context embeddings. \n- **Outcome:** Achieved a 20% improvement in click-through rate (CTR) and a 15% reduction in bounce rate on search results pages.\n\n### 2. Query Expansion Using Semantic Similarity\n\n- **Objective:** Enhance recall in search by expanding user queries with semantically related terms without degrading precision. \n- **Approach:** Leveraged word embeddings and clustering algorithms to identify relevant expansion terms dynamically. \n- **Outcome:** Increased search coverage by 25% while maintaining user satisfaction scores.\n\n### 3. Real-Time Feedback Integration Pipeline\n\n- **Objective:** Reduce latency between user feedback collection and model retraining to enable rapid iteration and improvement. \n- **Approach:** Designed a scalable data ingestion and processing pipeline using Azure Data Factory and Azure ML services. \n- **Outcome:** Reduced model update cycle from weekly to daily, accelerating feature deployment and bug fixes.\n\n---\n\n## Publications and Presentations\n\n- Carter, L. (2018). *Improving Search Relevance Using Context-Aware Models*. University of Toronto Master\u2019s Thesis. \n- Speaker at Microsoft AI Summit 2022: \u201cLeveraging Contextual Signals for Enhanced Enterprise Search.\u201d \n- Contributor to internal Microsoft whitepaper on ethical AI practices in search technologies.\n\n---\n\n## References\n\nAvailable upon request.\n\n---\n\nThis comprehensive profile highlights Lisa Carter\u2019s extensive expertise, professional experience, and personal qualities that make her a valuable asset in the field of data science, particularly in search relevance and natural language processing.",
|
| 4 |
+
"author": "Lisa Carter"
|
| 5 |
+
}
|
external/TinyTroupe/data/extractions/wordprocessor/Document/Lisa Carter - Resume.Lisa Carter.md
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Lisa Carter
|
| 2 |
+
|
| 3 |
+
---
|
| 4 |
+
|
| 5 |
+
## Contact Information
|
| 6 |
+
|
| 7 |
+
- **Location:** United States of America (USA)
|
| 8 |
+
- **Nationality:** Canadian
|
| 9 |
+
- **Email:** lisa.carter.datasci@gmail.com
|
| 10 |
+
- **Phone:** +1 (555) 123-4567
|
| 11 |
+
- **LinkedIn:** linkedin.com/in/lisacarterdatasci
|
| 12 |
+
- **GitHub:** github.com/lisacarterds
|
| 13 |
+
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
## Professional Summary
|
| 17 |
+
|
| 18 |
+
Lisa Carter is a highly skilled Data Scientist with a Master’s degree in Data Science from the University of Toronto. She specializes in enhancing search relevance through the development and deployment of context-aware machine learning models. With over four years of professional experience, Lisa has a proven track record of analyzing complex user behavior and feedback data to significantly improve the quality and accuracy of search results in large-scale enterprise environments.
|
| 19 |
+
|
| 20 |
+
Her expertise spans natural language understanding (NLU), query expansion techniques, and ranking algorithms, with a strong focus on building scalable, reliable, and ethically responsible AI systems. Lisa is adept at navigating challenges such as noisy, biased, or incomplete data, while ensuring strict compliance with privacy and security policies. She is a collaborative team player who thrives in cross-functional environments, mentoring junior colleagues and contributing to code quality and performance improvements.
|
| 21 |
+
|
| 22 |
+
Lisa is passionate about leveraging AI technologies to enhance human productivity and decision-making, with a particular interest in conversational agents and search engine optimization. She combines technical proficiency with excellent communication skills, enabling her to translate complex data science concepts into actionable insights for diverse stakeholders.
|
| 23 |
+
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
## Education
|
| 27 |
+
|
| 28 |
+
| Degree | Institution | Year Completed | Details |
|
| 29 |
+
|-------------------------------|----------------------|----------------|-------------------------------------------------------------------------------------------|
|
| 30 |
+
| Master of Science in Data Science | University of Toronto | 2018 | Thesis: *Improving Search Relevance Using Context-Aware Models* |
|
| 31 |
+
| Postgraduate Internship | Conversational AI Startup | 2017 | Focused on developing dialogue management systems and intent recognition for chatbots |
|
| 32 |
+
|
| 33 |
+
### Academic Highlights
|
| 34 |
+
|
| 35 |
+
- **Master’s Thesis:**
|
| 36 |
+
Lisa’s thesis explored innovative methods to improve search relevance by incorporating contextual signals such as user intent, session history, and semantic understanding. She designed and evaluated several context-aware ranking models that outperformed traditional keyword-based approaches by 15-20% in relevance metrics.
|
| 37 |
+
|
| 38 |
+
- **Coursework:**
|
| 39 |
+
- Advanced Machine Learning
|
| 40 |
+
- Natural Language Processing
|
| 41 |
+
- Big Data Analytics
|
| 42 |
+
- Statistical Inference and Modeling
|
| 43 |
+
- Data Visualization and Communication
|
| 44 |
+
|
| 45 |
+
- **Internship Experience:**
|
| 46 |
+
During her postgraduate internship at a tech startup specializing in conversational AI, Lisa contributed to building intent classification models and dialogue flow optimizations, gaining hands-on experience with real-time user interaction data and reinforcement learning techniques.
|
| 47 |
+
|
| 48 |
+
---
|
| 49 |
+
|
| 50 |
+
## Work Experience
|
| 51 |
+
|
| 52 |
+
### Data Scientist, Microsoft – M365 Search Team
|
| 53 |
+
*June 2018 – Present*
|
| 54 |
+
Redmond, WA, USA
|
| 55 |
+
|
| 56 |
+
#### Key Responsibilities:
|
| 57 |
+
|
| 58 |
+
- **User Behavior and Feedback Analysis:**
|
| 59 |
+
Conducted in-depth analysis of large-scale user interaction logs and explicit feedback to identify pain points and opportunities for improving search relevance and user satisfaction. Utilized A/B testing frameworks to validate model improvements.
|
| 60 |
+
|
| 61 |
+
- **Machine Learning Model Development:**
|
| 62 |
+
Designed, implemented, and fine-tuned machine learning models for various search-related tasks, including:
|
| 63 |
+
- **Natural Language Understanding (NLU):** Developed models to parse and interpret user queries, extracting intent and entities to improve query comprehension.
|
| 64 |
+
- **Query Expansion:** Created algorithms to automatically expand user queries with semantically related terms, improving recall without sacrificing precision.
|
| 65 |
+
- **Ranking:** Built and optimized ranking models that combine multiple features such as textual relevance, user context, and historical click data to deliver personalized and accurate search results.
|
| 66 |
+
|
| 67 |
+
- **Data Quality and Compliance:**
|
| 68 |
+
Addressed challenges related to noisy, biased, and incomplete data by implementing robust data cleaning pipelines and bias mitigation strategies. Ensured all data handling and model deployment complied with Microsoft’s privacy and security policies, including GDPR and CCPA regulations.
|
| 69 |
+
|
| 70 |
+
- **Cross-Functional Collaboration:**
|
| 71 |
+
Worked closely with software engineers, UX designers, product managers, and data engineers to debug issues, brainstorm innovative solutions, and integrate models into production systems. Participated in sprint planning and agile ceremonies to align on project goals.
|
| 72 |
+
|
| 73 |
+
- **Mentorship and Code Review:**
|
| 74 |
+
Mentored junior data scientists and interns, providing guidance on best practices in data science and machine learning. Conducted thorough code reviews focusing on performance optimization, readability, and maintainability.
|
| 75 |
+
|
| 76 |
+
#### Achievements:
|
| 77 |
+
|
| 78 |
+
- Improved search relevance metrics by 18% through the deployment of a novel context-aware ranking model.
|
| 79 |
+
- Led a project to integrate user session context into query understanding, resulting in a 12% increase in user engagement metrics.
|
| 80 |
+
- Developed a scalable data pipeline for real-time feedback ingestion, reducing model retraining latency by 30%.
|
| 81 |
+
|
| 82 |
+
---
|
| 83 |
+
|
| 84 |
+
## Skills
|
| 85 |
+
|
| 86 |
+
| Category | Skills and Tools |
|
| 87 |
+
|--------------------|--------------------------------------------------------------------------------------------------|
|
| 88 |
+
| **Programming** | Python (advanced), SQL (intermediate), Power BI (intermediate), R (basic) |
|
| 89 |
+
| **Machine Learning** | pandas, scikit-learn, TensorFlow, Azure Machine Learning, XGBoost, LightGBM |
|
| 90 |
+
| **Data Analysis** | Data wrangling, exploratory data analysis, statistical modeling, handling noisy/ambiguous data |
|
| 91 |
+
| **Natural Language Processing** | Text preprocessing, tokenization, word embeddings (Word2Vec, GloVe), transformer models (BERT) |
|
| 92 |
+
| **Visualization** | Matplotlib, Seaborn, Power BI, Tableau |
|
| 93 |
+
| **Communication** | Technical writing, presentations, cross-team collaboration, mentoring |
|
| 94 |
+
|
| 95 |
+
---
|
| 96 |
+
|
| 97 |
+
## Interests and Activities
|
| 98 |
+
|
| 99 |
+
- **Artificial Intelligence and Machine Learning:**
|
| 100 |
+
Enthusiastic about advancements in natural language processing, conversational agents, and ethical AI. Regularly participates in AI conferences and workshops.
|
| 101 |
+
|
| 102 |
+
- **Search Engine Optimization (SEO) and User Experience:**
|
| 103 |
+
Passionate about improving search algorithms and user interfaces to create seamless and intuitive search experiences.
|
| 104 |
+
|
| 105 |
+
- **Culinary Arts:**
|
| 106 |
+
Enjoys experimenting with new recipes, exploring diverse cuisines, and watching cooking shows and food documentaries. Frequently hosts dinner parties to share culinary creations with friends and family.
|
| 107 |
+
|
| 108 |
+
- **Music:**
|
| 109 |
+
Plays piano as a form of relaxation and creative expression. Has performed in local community events and enjoys exploring classical and contemporary pieces.
|
| 110 |
+
|
| 111 |
+
- **Film and Entertainment:**
|
| 112 |
+
Avid movie watcher with a preference for comedies and thrillers. Enjoys analyzing storytelling techniques and cinematography.
|
| 113 |
+
|
| 114 |
+
---
|
| 115 |
+
|
| 116 |
+
## Personal Attributes
|
| 117 |
+
|
| 118 |
+
- **Curious and Analytical:**
|
| 119 |
+
Approaches problems with a strong analytical mindset and persistence, always seeking to understand root causes and develop effective solutions.
|
| 120 |
+
|
| 121 |
+
- **Collaborative Team Player:**
|
| 122 |
+
Values open communication, knowledge sharing, and continuous learning within teams. Supports colleagues and fosters a positive work environment.
|
| 123 |
+
|
| 124 |
+
- **Organized and Detail-Oriented:**
|
| 125 |
+
Maintains a clean and efficient workspace, takes meticulous notes during meetings, and follows structured workflows to ensure accuracy and reliability.
|
| 126 |
+
|
| 127 |
+
- **Ethical and Responsible:**
|
| 128 |
+
Committed to the ethical use of data and AI technologies, prioritizing user privacy, data security, and fairness in all projects.
|
| 129 |
+
|
| 130 |
+
---
|
| 131 |
+
|
| 132 |
+
## Selected Projects
|
| 133 |
+
|
| 134 |
+
### 1. Context-Aware Search Ranking Model
|
| 135 |
+
|
| 136 |
+
- **Objective:** Improve search result relevance by incorporating user context such as previous queries, session behavior, and user profile data.
|
| 137 |
+
- **Approach:** Developed a hybrid ranking model combining traditional BM25 scoring with neural network-based context embeddings.
|
| 138 |
+
- **Outcome:** Achieved a 20% improvement in click-through rate (CTR) and a 15% reduction in bounce rate on search results pages.
|
| 139 |
+
|
| 140 |
+
### 2. Query Expansion Using Semantic Similarity
|
| 141 |
+
|
| 142 |
+
- **Objective:** Enhance recall in search by expanding user queries with semantically related terms without degrading precision.
|
| 143 |
+
- **Approach:** Leveraged word embeddings and clustering algorithms to identify relevant expansion terms dynamically.
|
| 144 |
+
- **Outcome:** Increased search coverage by 25% while maintaining user satisfaction scores.
|
| 145 |
+
|
| 146 |
+
### 3. Real-Time Feedback Integration Pipeline
|
| 147 |
+
|
| 148 |
+
- **Objective:** Reduce latency between user feedback collection and model retraining to enable rapid iteration and improvement.
|
| 149 |
+
- **Approach:** Designed a scalable data ingestion and processing pipeline using Azure Data Factory and Azure ML services.
|
| 150 |
+
- **Outcome:** Reduced model update cycle from weekly to daily, accelerating feature deployment and bug fixes.
|
| 151 |
+
|
| 152 |
+
---
|
| 153 |
+
|
| 154 |
+
## Publications and Presentations
|
| 155 |
+
|
| 156 |
+
- Carter, L. (2018). *Improving Search Relevance Using Context-Aware Models*. University of Toronto Master’s Thesis.
|
| 157 |
+
- Speaker at Microsoft AI Summit 2022: “Leveraging Contextual Signals for Enhanced Enterprise Search.”
|
| 158 |
+
- Contributor to internal Microsoft whitepaper on ethical AI practices in search technologies.
|
| 159 |
+
|
| 160 |
+
---
|
| 161 |
+
|
| 162 |
+
## References
|
| 163 |
+
|
| 164 |
+
Available upon request.
|
| 165 |
+
|
| 166 |
+
---
|
| 167 |
+
|
| 168 |
+
This comprehensive profile highlights Lisa Carter’s extensive expertise, professional experience, and personal qualities that make her a valuable asset in the field of data science, particularly in search relevance and natural language processing.
|
external/TinyTroupe/data/extractions/wordprocessor/Document/Resume of Lisa Carter.Lisa Carter.docx
ADDED
|
Binary file (13.9 kB). View file
|
|
|
external/TinyTroupe/data/extractions/wordprocessor/Document/Resume of Lisa Carter.Lisa Carter.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"title": "Resume of Lisa Carter",
|
| 3 |
+
"content": "```\n# Lisa Carter\n\n## Contact Information\n- **Email:** lisa.carter@example.com\n- **Phone:** (123) 456-7890\n- **LinkedIn:** [linkedin.com/in/lisacarter](https://linkedin.com/in/lisacarter)\n- **Location:** Toronto, Ontario, Canada\n\n## Summary\nLisa Carter is a highly skilled Data Scientist with a Master's degree in Data Science from the prestigious University of Toronto. With a specialization in improving search relevance through innovative context-aware models, Lisa has a proven track record of analyzing user behavior and feedback data to significantly enhance search results. Her passion for advancing artificial intelligence technology is matched by her commitment to improving human productivity and decision-making processes. Lisa is known for her analytical mindset, problem-solving abilities, and collaborative spirit, making her a valuable asset to any team.\n\n## Education\n### University of Toronto\n- **Master's in Data Science** \n - **Thesis:** Improving Search Relevance Using Context-Aware Models \n - **Graduated:** 2018 \n - **Relevant Coursework:** \n - Machine Learning \n - Data Mining \n - Statistical Analysis \n - Natural Language Processing \n - Big Data Technologies \n - **Projects:** \n - Developed a predictive model for user engagement based on historical data, achieving a 30% increase in accuracy over previous models.\n\n### Bachelor of Science in Computer Science\n- **University of Toronto** \n - **Graduated:** 2016 \n - **Key Achievements:** \n - Dean's List for three consecutive years \n - Completed a capstone project on developing a web application for data visualization.\n\n## Work Experience\n### Microsoft, M365 Search Team \n**Data Scientist** \n2018 - Present \n- **Key Responsibilities:** \n - Analyzed user behavior and feedback data to improve search relevance and quality, leading to a 25% increase in user engagement metrics. \n - Built and tested machine learning models for natural language understanding, query expansion, and ranking, resulting in a 20% improvement in search accuracy. \n - Collaborated with cross-functional teams, including product managers, engineers, and UX designers, to address challenges related to noisy or biased data, ensuring a seamless user experience. \n - Ensured compliance with privacy and security policies in all data handling processes, maintaining the highest standards of data integrity and confidentiality. \n - Conducted A/B testing to evaluate the effectiveness of new features and algorithms, providing data-driven recommendations for product enhancements.\n\n### Intern, Data Analytics Team \n**XYZ Corporation** \n2017 - 2018 \n- Assisted in the development of data-driven strategies to optimize marketing campaigns, resulting in a 15% increase in conversion rates. \n- Conducted exploratory data analysis to identify trends and patterns in customer behavior, presenting findings to senior management. \n- Collaborated with the IT department to streamline data collection processes, improving data accuracy and accessibility.\n\n## Skills\n- **Programming Languages:** \n - Proficient in Python, with extensive experience in data analysis and machine learning tools such as pandas, scikit-learn, TensorFlow, and Azure ML. \n - Familiar with SQL for database management and data manipulation. \n - Basic knowledge of R for statistical analysis and data visualization.\n\n- **Data Visualization Tools:** \n - Proficient in Power BI for creating interactive dashboards and reports. \n - Experience with Tableau for data visualization and storytelling.\n\n- **Machine Learning Techniques:** \n - Expertise in supervised and unsupervised learning algorithms, including regression, classification, clustering, and deep learning. \n - Familiar with natural language processing techniques, including sentiment analysis and text classification.\n\n- **Soft Skills:** \n - Strong analytical and critical thinking skills. \n - Excellent communication and presentation abilities. \n - Proven ability to work collaboratively in a team-oriented environment.\n\n## Projects\n- **Search Result Accuracy Improvement Project:** \n Developed a machine learning model that improved search result accuracy by 20% through enhanced natural language processing techniques. This project involved extensive data preprocessing, feature engineering, and model evaluation.\n\n- **User Feedback Analysis Initiative:** \n Led a project to analyze user feedback, resulting in actionable insights that increased user satisfaction by 15%. This involved conducting surveys, analyzing qualitative data, and presenting findings to stakeholders.\n\n- **Predictive Analytics for User Engagement:** \n Created a predictive model that forecasts user engagement based on historical data, achieving a 30% increase in accuracy over previous models. This project utilized advanced machine learning techniques and required collaboration with marketing teams.\n\n## Interests\n- **Artificial Intelligence and Machine Learning:** \n Passionate about exploring the latest advancements in AI and machine learning, and their applications in various industries.\n\n- **Natural Language Processing and Conversational Agents:** \n Interested in developing intelligent systems that can understand and respond to human language, enhancing user interactions.\n\n- **Cooking and Trying New Recipes:** \n Enjoy experimenting with different cuisines and sharing culinary experiences with friends and family.\n\n- **Playing the Piano and Watching Movies:** \n Avid piano player with a love for music, particularly classical and contemporary genres. Enjoys watching movies, especially comedies and thrillers, for entertainment and inspiration.\n\n## References\nAvailable upon request. \n- **Professional References:** \n - Dr. John Smith, Professor of Data Science, University of Toronto \n - Jane Doe, Senior Product Manager, Microsoft \n- **Personal References:** \n - Emily Johnson, Colleague and Friend \n - Michael Brown, Former Classmate \n```",
|
| 4 |
+
"author": "Lisa Carter"
|
| 5 |
+
}
|
external/TinyTroupe/data/extractions/wordprocessor/Document/Resume of Lisa Carter.Lisa Carter.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
```
|
| 2 |
+
# Lisa Carter
|
| 3 |
+
|
| 4 |
+
## Contact Information
|
| 5 |
+
- **Email:** lisa.carter@example.com
|
| 6 |
+
- **Phone:** (123) 456-7890
|
| 7 |
+
- **LinkedIn:** [linkedin.com/in/lisacarter](https://linkedin.com/in/lisacarter)
|
| 8 |
+
- **Location:** Toronto, Ontario, Canada
|
| 9 |
+
|
| 10 |
+
## Summary
|
| 11 |
+
Lisa Carter is a highly skilled Data Scientist with a Master's degree in Data Science from the prestigious University of Toronto. With a specialization in improving search relevance through innovative context-aware models, Lisa has a proven track record of analyzing user behavior and feedback data to significantly enhance search results. Her passion for advancing artificial intelligence technology is matched by her commitment to improving human productivity and decision-making processes. Lisa is known for her analytical mindset, problem-solving abilities, and collaborative spirit, making her a valuable asset to any team.
|
| 12 |
+
|
| 13 |
+
## Education
|
| 14 |
+
### University of Toronto
|
| 15 |
+
- **Master's in Data Science**
|
| 16 |
+
- **Thesis:** Improving Search Relevance Using Context-Aware Models
|
| 17 |
+
- **Graduated:** 2018
|
| 18 |
+
- **Relevant Coursework:**
|
| 19 |
+
- Machine Learning
|
| 20 |
+
- Data Mining
|
| 21 |
+
- Statistical Analysis
|
| 22 |
+
- Natural Language Processing
|
| 23 |
+
- Big Data Technologies
|
| 24 |
+
- **Projects:**
|
| 25 |
+
- Developed a predictive model for user engagement based on historical data, achieving a 30% increase in accuracy over previous models.
|
| 26 |
+
|
| 27 |
+
### Bachelor of Science in Computer Science
|
| 28 |
+
- **University of Toronto**
|
| 29 |
+
- **Graduated:** 2016
|
| 30 |
+
- **Key Achievements:**
|
| 31 |
+
- Dean's List for three consecutive years
|
| 32 |
+
- Completed a capstone project on developing a web application for data visualization.
|
| 33 |
+
|
| 34 |
+
## Work Experience
|
| 35 |
+
### Microsoft, M365 Search Team
|
| 36 |
+
**Data Scientist**
|
| 37 |
+
2018 - Present
|
| 38 |
+
- **Key Responsibilities:**
|
| 39 |
+
- Analyzed user behavior and feedback data to improve search relevance and quality, leading to a 25% increase in user engagement metrics.
|
| 40 |
+
- Built and tested machine learning models for natural language understanding, query expansion, and ranking, resulting in a 20% improvement in search accuracy.
|
| 41 |
+
- Collaborated with cross-functional teams, including product managers, engineers, and UX designers, to address challenges related to noisy or biased data, ensuring a seamless user experience.
|
| 42 |
+
- Ensured compliance with privacy and security policies in all data handling processes, maintaining the highest standards of data integrity and confidentiality.
|
| 43 |
+
- Conducted A/B testing to evaluate the effectiveness of new features and algorithms, providing data-driven recommendations for product enhancements.
|
| 44 |
+
|
| 45 |
+
### Intern, Data Analytics Team
|
| 46 |
+
**XYZ Corporation**
|
| 47 |
+
2017 - 2018
|
| 48 |
+
- Assisted in the development of data-driven strategies to optimize marketing campaigns, resulting in a 15% increase in conversion rates.
|
| 49 |
+
- Conducted exploratory data analysis to identify trends and patterns in customer behavior, presenting findings to senior management.
|
| 50 |
+
- Collaborated with the IT department to streamline data collection processes, improving data accuracy and accessibility.
|
| 51 |
+
|
| 52 |
+
## Skills
|
| 53 |
+
- **Programming Languages:**
|
| 54 |
+
- Proficient in Python, with extensive experience in data analysis and machine learning tools such as pandas, scikit-learn, TensorFlow, and Azure ML.
|
| 55 |
+
- Familiar with SQL for database management and data manipulation.
|
| 56 |
+
- Basic knowledge of R for statistical analysis and data visualization.
|
| 57 |
+
|
| 58 |
+
- **Data Visualization Tools:**
|
| 59 |
+
- Proficient in Power BI for creating interactive dashboards and reports.
|
| 60 |
+
- Experience with Tableau for data visualization and storytelling.
|
| 61 |
+
|
| 62 |
+
- **Machine Learning Techniques:**
|
| 63 |
+
- Expertise in supervised and unsupervised learning algorithms, including regression, classification, clustering, and deep learning.
|
| 64 |
+
- Familiar with natural language processing techniques, including sentiment analysis and text classification.
|
| 65 |
+
|
| 66 |
+
- **Soft Skills:**
|
| 67 |
+
- Strong analytical and critical thinking skills.
|
| 68 |
+
- Excellent communication and presentation abilities.
|
| 69 |
+
- Proven ability to work collaboratively in a team-oriented environment.
|
| 70 |
+
|
| 71 |
+
## Projects
|
| 72 |
+
- **Search Result Accuracy Improvement Project:**
|
| 73 |
+
Developed a machine learning model that improved search result accuracy by 20% through enhanced natural language processing techniques. This project involved extensive data preprocessing, feature engineering, and model evaluation.
|
| 74 |
+
|
| 75 |
+
- **User Feedback Analysis Initiative:**
|
| 76 |
+
Led a project to analyze user feedback, resulting in actionable insights that increased user satisfaction by 15%. This involved conducting surveys, analyzing qualitative data, and presenting findings to stakeholders.
|
| 77 |
+
|
| 78 |
+
- **Predictive Analytics for User Engagement:**
|
| 79 |
+
Created a predictive model that forecasts user engagement based on historical data, achieving a 30% increase in accuracy over previous models. This project utilized advanced machine learning techniques and required collaboration with marketing teams.
|
| 80 |
+
|
| 81 |
+
## Interests
|
| 82 |
+
- **Artificial Intelligence and Machine Learning:**
|
| 83 |
+
Passionate about exploring the latest advancements in AI and machine learning, and their applications in various industries.
|
| 84 |
+
|
| 85 |
+
- **Natural Language Processing and Conversational Agents:**
|
| 86 |
+
Interested in developing intelligent systems that can understand and respond to human language, enhancing user interactions.
|
| 87 |
+
|
| 88 |
+
- **Cooking and Trying New Recipes:**
|
| 89 |
+
Enjoy experimenting with different cuisines and sharing culinary experiences with friends and family.
|
| 90 |
+
|
| 91 |
+
- **Playing the Piano and Watching Movies:**
|
| 92 |
+
Avid piano player with a love for music, particularly classical and contemporary genres. Enjoys watching movies, especially comedies and thrillers, for entertainment and inspiration.
|
| 93 |
+
|
| 94 |
+
## References
|
| 95 |
+
Available upon request.
|
| 96 |
+
- **Professional References:**
|
| 97 |
+
- Dr. John Smith, Professor of Data Science, University of Toronto
|
| 98 |
+
- Jane Doe, Senior Product Manager, Microsoft
|
| 99 |
+
- **Personal References:**
|
| 100 |
+
- Emily Johnson, Colleague and Friend
|
| 101 |
+
- Michael Brown, Former Classmate
|
| 102 |
+
```
|
external/TinyTroupe/data/extractions/wordprocessor/Document/Resume of Lisa.Lisa.docx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:11776247ff79f68c7471a41798522bba9a34b94c6817de1962925d6c0ab2d153
|
| 3 |
+
size 124416
|
external/TinyTroupe/data/extractions/wordprocessor/Document/Resume of Lisa.Lisa.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"title": "Resume of Lisa",
|
| 3 |
+
"content": "```\n# Lisa's Resume\n\n## Contact Information\n- **Name:** Lisa Johnson\n- **Age:** 28\n- **Nationality:** Canadian\n- **Location:** Toronto, Ontario\n- **Email:** lisa.johnson@email.com\n- **Phone:** (123) 456-7890\n\n## Objective\nAs a passionate and results-driven data scientist, I am seeking a challenging position where I can leverage my extensive skills in data analysis, machine learning, and natural language processing. My goal is to contribute to innovative projects that enhance user experiences and drive business success. I am particularly interested in roles that allow me to work collaboratively with diverse teams to solve complex problems and deliver actionable insights.\n\n## Skills\n### Technical Skills\n- **Programming Languages:**\n - Proficient in Python for data analysis and machine learning.\n - Familiar with R for statistical analysis and visualization.\n\n- **Data Analysis Tools:**\n - Experienced with libraries such as pandas, NumPy, and Matplotlib for data manipulation and visualization.\n - Skilled in using scikit-learn for building machine learning models.\n\n- **Machine Learning Frameworks:**\n - Proficient in TensorFlow and Keras for deep learning applications.\n - Experienced with Azure ML for deploying machine learning models in cloud environments.\n\n- **Database Management:**\n - Familiar with SQL for database querying and management.\n - Knowledgeable in NoSQL databases like MongoDB.\n\n- **Business Intelligence Tools:**\n - Proficient in Power BI for creating interactive dashboards and reports.\n - Experienced with Tableau for data visualization.\n\n### Soft Skills\n- Strong analytical and problem-solving skills, enabling me to dissect complex datasets and derive meaningful insights.\n- Excellent communication abilities, allowing me to present findings clearly to both technical and non-technical stakeholders.\n- Proven teamwork capabilities, having collaborated effectively within cross-functional teams on various projects.\n\n## Professional Experience\n\n### Data Scientist at Microsoft (M365 Search Team) \n*Date: January 2020 - Present* \n**Key Responsibilities:**\n- Analyzed user behavior and feedback data to improve search result relevance, leading to a 15% increase in user satisfaction scores over six months.\n- Built and tested machine learning models for natural language understanding (NLU) and query expansion, resulting in a significant reduction in irrelevant search results.\n- Collaborated with cross-functional teams including product managers, UX designers, and engineers to communicate findings and recommendations effectively.\n- Ensured compliance with privacy and security policies in data handling by implementing best practices for data governance.\n\n**Projects:**\n1. **User Behavior Analysis Project:**\n - Conducted extensive analysis of user interaction logs using Python and SQL to identify patterns that inform product improvements.\n - Developed visualizations using Power BI that highlighted key trends in user engagement.\n\n2. **Machine Learning Model Development:**\n - Designed a predictive model using TensorFlow that improved the accuracy of search result predictions by over 20%.\n - Implemented A/B testing protocols to evaluate the effectiveness of new features based on model outputs.\n\n3. **Cross-Team Collaboration Initiative:**\n - Led workshops with stakeholders from different departments to align on project goals and share insights from data analyses.\n\n### Data Analyst Intern at XYZ Corp \n*Date: May 2019 - December 2019* \n**Key Responsibilities:**\n- Assisted senior analysts in collecting, cleaning, and analyzing large datasets using Excel and SQL.\n- Created reports that summarized findings from analyses which were presented to management during quarterly reviews.\n\n**Achievements:**\n- Developed an automated reporting tool that reduced the time spent on generating monthly reports by 30%.\n\n## Education\n\n### Bachelor of Science in Computer Science \n*University of Toronto, Graduated June 2019* \n**Relevant Coursework:**\n- Data Structures\n- Algorithms\n- Machine Learning\n- Natural Language Processing\n- Database Management Systems\n\n**Projects:**\n1. **Capstone Project:** Developed a sentiment analysis tool using Python that analyzed social media posts related to current events. The project received recognition at the university's annual tech fair.\n2. **Group Project:** Collaborated with peers to create a web application that visualized real-time traffic data using APIs.\n\n## Certifications\n1. **Certified Data Scientist** \u2013 Data Science Council of America (DASCA)\n2. **Microsoft Certified: Azure Data Scientist Associate**\n\n## Interests\nIn addition to my professional pursuits, I have a variety of personal interests that keep me engaged:\n- Cooking new recipes from different cuisines; I enjoy experimenting with flavors and techniques.\n- Playing the piano; I have been taking lessons since childhood and enjoy performing at local community events.\n- Watching movies; I have a particular fondness for comedies that make me laugh as well as thrillers that keep me on the edge of my seat.\n\n## References\nAvailable upon request.\n```",
|
| 4 |
+
"author": "Lisa"
|
| 5 |
+
}
|
external/TinyTroupe/data/extractions/wordprocessor/Document/Resume of Lisa.Lisa.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
```
|
| 2 |
+
# Lisa's Resume
|
| 3 |
+
|
| 4 |
+
## Contact Information
|
| 5 |
+
- **Name:** Lisa Johnson
|
| 6 |
+
- **Age:** 28
|
| 7 |
+
- **Nationality:** Canadian
|
| 8 |
+
- **Location:** Toronto, Ontario
|
| 9 |
+
- **Email:** lisa.johnson@email.com
|
| 10 |
+
- **Phone:** (123) 456-7890
|
| 11 |
+
|
| 12 |
+
## Objective
|
| 13 |
+
As a passionate and results-driven data scientist, I am seeking a challenging position where I can leverage my extensive skills in data analysis, machine learning, and natural language processing. My goal is to contribute to innovative projects that enhance user experiences and drive business success. I am particularly interested in roles that allow me to work collaboratively with diverse teams to solve complex problems and deliver actionable insights.
|
| 14 |
+
|
| 15 |
+
## Skills
|
| 16 |
+
### Technical Skills
|
| 17 |
+
- **Programming Languages:**
|
| 18 |
+
- Proficient in Python for data analysis and machine learning.
|
| 19 |
+
- Familiar with R for statistical analysis and visualization.
|
| 20 |
+
|
| 21 |
+
- **Data Analysis Tools:**
|
| 22 |
+
- Experienced with libraries such as pandas, NumPy, and Matplotlib for data manipulation and visualization.
|
| 23 |
+
- Skilled in using scikit-learn for building machine learning models.
|
| 24 |
+
|
| 25 |
+
- **Machine Learning Frameworks:**
|
| 26 |
+
- Proficient in TensorFlow and Keras for deep learning applications.
|
| 27 |
+
- Experienced with Azure ML for deploying machine learning models in cloud environments.
|
| 28 |
+
|
| 29 |
+
- **Database Management:**
|
| 30 |
+
- Familiar with SQL for database querying and management.
|
| 31 |
+
- Knowledgeable in NoSQL databases like MongoDB.
|
| 32 |
+
|
| 33 |
+
- **Business Intelligence Tools:**
|
| 34 |
+
- Proficient in Power BI for creating interactive dashboards and reports.
|
| 35 |
+
- Experienced with Tableau for data visualization.
|
| 36 |
+
|
| 37 |
+
### Soft Skills
|
| 38 |
+
- Strong analytical and problem-solving skills, enabling me to dissect complex datasets and derive meaningful insights.
|
| 39 |
+
- Excellent communication abilities, allowing me to present findings clearly to both technical and non-technical stakeholders.
|
| 40 |
+
- Proven teamwork capabilities, having collaborated effectively within cross-functional teams on various projects.
|
| 41 |
+
|
| 42 |
+
## Professional Experience
|
| 43 |
+
|
| 44 |
+
### Data Scientist at Microsoft (M365 Search Team)
|
| 45 |
+
*Date: January 2020 - Present*
|
| 46 |
+
**Key Responsibilities:**
|
| 47 |
+
- Analyzed user behavior and feedback data to improve search result relevance, leading to a 15% increase in user satisfaction scores over six months.
|
| 48 |
+
- Built and tested machine learning models for natural language understanding (NLU) and query expansion, resulting in a significant reduction in irrelevant search results.
|
| 49 |
+
- Collaborated with cross-functional teams including product managers, UX designers, and engineers to communicate findings and recommendations effectively.
|
| 50 |
+
- Ensured compliance with privacy and security policies in data handling by implementing best practices for data governance.
|
| 51 |
+
|
| 52 |
+
**Projects:**
|
| 53 |
+
1. **User Behavior Analysis Project:**
|
| 54 |
+
- Conducted extensive analysis of user interaction logs using Python and SQL to identify patterns that inform product improvements.
|
| 55 |
+
- Developed visualizations using Power BI that highlighted key trends in user engagement.
|
| 56 |
+
|
| 57 |
+
2. **Machine Learning Model Development:**
|
| 58 |
+
- Designed a predictive model using TensorFlow that improved the accuracy of search result predictions by over 20%.
|
| 59 |
+
- Implemented A/B testing protocols to evaluate the effectiveness of new features based on model outputs.
|
| 60 |
+
|
| 61 |
+
3. **Cross-Team Collaboration Initiative:**
|
| 62 |
+
- Led workshops with stakeholders from different departments to align on project goals and share insights from data analyses.
|
| 63 |
+
|
| 64 |
+
### Data Analyst Intern at XYZ Corp
|
| 65 |
+
*Date: May 2019 - December 2019*
|
| 66 |
+
**Key Responsibilities:**
|
| 67 |
+
- Assisted senior analysts in collecting, cleaning, and analyzing large datasets using Excel and SQL.
|
| 68 |
+
- Created reports that summarized findings from analyses which were presented to management during quarterly reviews.
|
| 69 |
+
|
| 70 |
+
**Achievements:**
|
| 71 |
+
- Developed an automated reporting tool that reduced the time spent on generating monthly reports by 30%.
|
| 72 |
+
|
| 73 |
+
## Education
|
| 74 |
+
|
| 75 |
+
### Bachelor of Science in Computer Science
|
| 76 |
+
*University of Toronto, Graduated June 2019*
|
| 77 |
+
**Relevant Coursework:**
|
| 78 |
+
- Data Structures
|
| 79 |
+
- Algorithms
|
| 80 |
+
- Machine Learning
|
| 81 |
+
- Natural Language Processing
|
| 82 |
+
- Database Management Systems
|
| 83 |
+
|
| 84 |
+
**Projects:**
|
| 85 |
+
1. **Capstone Project:** Developed a sentiment analysis tool using Python that analyzed social media posts related to current events. The project received recognition at the university's annual tech fair.
|
| 86 |
+
2. **Group Project:** Collaborated with peers to create a web application that visualized real-time traffic data using APIs.
|
| 87 |
+
|
| 88 |
+
## Certifications
|
| 89 |
+
1. **Certified Data Scientist** – Data Science Council of America (DASCA)
|
| 90 |
+
2. **Microsoft Certified: Azure Data Scientist Associate**
|
| 91 |
+
|
| 92 |
+
## Interests
|
| 93 |
+
In addition to my professional pursuits, I have a variety of personal interests that keep me engaged:
|
| 94 |
+
- Cooking new recipes from different cuisines; I enjoy experimenting with flavors and techniques.
|
| 95 |
+
- Playing the piano; I have been taking lessons since childhood and enjoy performing at local community events.
|
| 96 |
+
- Watching movies; I have a particular fondness for comedies that make me laugh as well as thrillers that keep me on the edge of my seat.
|
| 97 |
+
|
| 98 |
+
## References
|
| 99 |
+
Available upon request.
|
| 100 |
+
```
|
external/TinyTroupe/data/extractions/wordprocessor/Document/Resume.Lisa.docx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2e024818f4819e692396dce58175db761744200908344f8691f1157738f11641
|
| 3 |
+
size 124416
|
external/TinyTroupe/data/facts/business-facts.synthetic.txt
ADDED
|
@@ -0,0 +1,500 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1. Effective communication is a crucial skill for business consultants to develop trust and rapport with clients.
|
| 2 |
+
2. Understanding the client's industry is fundamental for providing relevant and actionable advice.
|
| 3 |
+
3. A comprehensive market analysis can uncover opportunities for business growth and expansion.
|
| 4 |
+
4. SWOT analysis helps identify a client's strengths, weaknesses, opportunities, and threats.
|
| 5 |
+
5. Keeping updated with industry trends allows consultants to offer cutting-edge insights.
|
| 6 |
+
6. Networking is essential for business consultants to broaden their client base and collaborate with other professionals.
|
| 7 |
+
7. Time management skills enable consultants to maximize productivity and meet client deadlines.
|
| 8 |
+
8. Financial literacy is vital for consultants to analyze and interpret financial statements effectively.
|
| 9 |
+
9. A well-defined value proposition is key to a successful business consulting practice.
|
| 10 |
+
10. Establishing clear objectives with clients ensures both parties have aligned expectations.
|
| 11 |
+
11. Data-driven decision-making enhances the credibility and impact of consulting recommendations.
|
| 12 |
+
12. Change management skills are crucial for consultants assisting organizations in transformations.
|
| 13 |
+
13. Setting measurable goals allows clients to track progress and assess the effectiveness of consulting efforts.
|
| 14 |
+
14. A strong professional online presence strengthens a consultant's reputation and visibility.
|
| 15 |
+
15. Developing negotiation skills helps consultants secure agreements and foster client satisfaction.
|
| 16 |
+
16. Conducting competitive analysis provides insights into competitors' strengths and weaknesses.
|
| 17 |
+
17. Ethics and integrity are foundational principles for maintaining trust in consulting relationships.
|
| 18 |
+
18. Leveraging digital tools can enhance a consultant's ability to deliver efficient and impactful solutions.
|
| 19 |
+
19. Understanding the client's target audience is essential for crafting effective marketing strategies.
|
| 20 |
+
20. Critical thinking skills enable consultants to address complex business challenges creatively.
|
| 21 |
+
21. Building long-term relationships with clients can lead to repeat business and referrals.
|
| 22 |
+
22. Regularly seeking feedback helps consultants improve their services and client satisfaction.
|
| 23 |
+
23. Familiarity with various business models enables consultants to tailor advice to clients' needs.
|
| 24 |
+
24. Best practice research provides consultants with proven methods and techniques for success.
|
| 25 |
+
25. Streamlining operations can lead to cost savings and increased operational efficiency for clients.
|
| 26 |
+
26. Consultants should continuously develop their skillset to remain competitive in a dynamic market.
|
| 27 |
+
27. Understanding cultural differences is crucial for consultants working with international clients.
|
| 28 |
+
28. Strategic planning is an essential component of guiding clients toward achieving long-term goals.
|
| 29 |
+
29. In-depth competitor profiling assists consultants in identifying competitive advantages.
|
| 30 |
+
30. The ability to adapt to changing client needs is a valuable trait for a successful consultant.
|
| 31 |
+
31. Consultants should focus on delivering tangible results that demonstrate their value to clients.
|
| 32 |
+
32. Conducting regular client check-ins ensures ongoing alignment and addresses any emerging issues.
|
| 33 |
+
33. Benchmarking against industry standards helps clients gauge their performance and identify areas for improvement.
|
| 34 |
+
34. Emotional intelligence aids consultants in understanding client emotions and improving communication.
|
| 35 |
+
35. Identifying key performance indicators (KPIs) enables clients to measure success effectively.
|
| 36 |
+
36. Effective presentation skills are essential for consultants to articulate strategies and findings clearly.
|
| 37 |
+
37. Confidentiality is critical in maintaining client trust and protecting sensitive business information.
|
| 38 |
+
38. Consultants should prioritize understanding a client's corporate culture to deliver tailored solutions.
|
| 39 |
+
39. Providing post-implementation support helps clients sustain improvements after consulting engagements.
|
| 40 |
+
40. A proactive approach to problem-solving is beneficial in addressing potential business challenges early.
|
| 41 |
+
41. Conducting a risk assessment helps clients identify potential business threats and develop mitigation strategies.
|
| 42 |
+
42. Digital transformation is becoming increasingly important for maintaining competitiveness and efficiency.
|
| 43 |
+
43. Consultants should emphasize sustainable business practices to help clients achieve long-term success.
|
| 44 |
+
44. Building a diverse team can enhance a consulting firm's ability to deliver innovative solutions.
|
| 45 |
+
45. Effective stakeholder management is key to the successful execution of complex projects.
|
| 46 |
+
46. Regularly reviewing and updating business processes can lead to continuous improvement.
|
| 47 |
+
47. Customer feedback is a valuable source of insights for improving products and services.
|
| 48 |
+
48. Understanding organizational structure helps consultants navigate client businesses to implement recommendations.
|
| 49 |
+
49. Consultants should encourage clients to foster a culture of innovation for sustained business growth.
|
| 50 |
+
50. Identifying emerging technologies can help clients stay ahead of industry trends and competitors.
|
| 51 |
+
51. Transparency in communication fosters trust and strengthens consultant-client relationships.
|
| 52 |
+
52. Scenario planning helps clients prepare for possible future challenges and opportunities.
|
| 53 |
+
53. Consultants should adapt their communication style to suit different client preferences and contexts.
|
| 54 |
+
54. Providing actionable insights is more valuable than presenting raw data to clients.
|
| 55 |
+
55. Establishing clear project timelines ensures efficient resource allocation and delivery.
|
| 56 |
+
56. Consultants should strive to simplify complex ideas to facilitate client understanding and decision-making.
|
| 57 |
+
57. A thorough project handover ensures clients are equipped to manage new systems or processes independently.
|
| 58 |
+
58. Building rapport with clients can lead to more open communication and better problem-solving.
|
| 59 |
+
59. Consultants should encourage clients to embrace change as a continual improvement opportunity.
|
| 60 |
+
60. The ability to conduct gap analysis helps clients identify deficiencies and prioritize improvements.
|
| 61 |
+
61. Consultants should remain unbiased and impartial to provide objective advice and recommendations.
|
| 62 |
+
62. Tailoring strategies to client-specific needs increases the likelihood of successful outcomes.
|
| 63 |
+
63. Consultants should develop a deep understanding of a client's competitive landscape to provide relevant advice.
|
| 64 |
+
64. Encouraging cross-departmental collaboration can lead to innovative solutions and improved business outcomes.
|
| 65 |
+
65. Clear and concise report writing helps clients quickly grasp key insights and recommendations.
|
| 66 |
+
66. Performance management systems are critical for ensuring employees meet organizational goals.
|
| 67 |
+
67. Consultants should encourage a growth mindset within client organizations to foster adaptability.
|
| 68 |
+
68. Leveraging social media platforms can enhance a client's brand visibility and engagement.
|
| 69 |
+
69. Consultants should apply lessons learned from past projects to improve future client engagements.
|
| 70 |
+
70. Regularly analyzing customer trends helps consultants advise clients on meeting evolving demands.
|
| 71 |
+
71. Data visualization techniques can make complex insights more accessible to clients.
|
| 72 |
+
72. Understanding a client's product lifecycle is crucial for providing appropriate strategic advice.
|
| 73 |
+
73. Consultants should use storytelling to make their analyses and recommendations more relatable.
|
| 74 |
+
74. Facilitating workshops can help clients generate creative solutions and foster team alignment.
|
| 75 |
+
75. Consultants should advise clients on effective leadership practices for organizational success.
|
| 76 |
+
76. Agile methodologies can increase flexibility and responsiveness in client projects and processes.
|
| 77 |
+
77. Understanding fiscal policies and regulations is important for consultants advising on financial matters.
|
| 78 |
+
78. Consultants should be open to feedback and continuously seek to improve their service delivery.
|
| 79 |
+
79. Digital marketing strategies can enhance a client's reach and target audience engagement.
|
| 80 |
+
80. Effective crisis management plans can protect a client's reputation and minimize business disruption.
|
| 81 |
+
81. Regularly reviewing a client's business strategy ensures alignment with changing market conditions.
|
| 82 |
+
82. Consultants should advocate for ethical business practices to strengthen client reputation and compliance.
|
| 83 |
+
83. Incorporating feedback loops within processes enhances client responsiveness to change.
|
| 84 |
+
84. Consultants should foster a culture of continuous learning and improvement within client organizations.
|
| 85 |
+
85. Strategic partnerships can provide clients with competitive advantage through collaboration.
|
| 86 |
+
86. Effective project management ensures on-time delivery of consulting deliverables and client satisfaction.
|
| 87 |
+
87. Consultants should advise clients on aligning their talent management strategies with business goals.
|
| 88 |
+
88. Stakeholder analysis helps clients understand the interests and influence of individuals involved in a project.
|
| 89 |
+
89. Process automation can lead to increased efficiency and consistency in business operations.
|
| 90 |
+
90. Consultants should guide clients in developing effective customer loyalty programs.
|
| 91 |
+
91. Political, economic, social, and technological factors can significantly impact a client's business environment.
|
| 92 |
+
92. Innovation workshops can inspire ideas for new products, services, or process improvements.
|
| 93 |
+
93. Consultants should ensure they understand the specific goals and constraints of each client situation.
|
| 94 |
+
94. Risk management strategies are essential for minimizing the impact of unforeseen events.
|
| 95 |
+
95. Consultants should encourage clients to invest in employee development to enhance productivity and retention.
|
| 96 |
+
96. Understanding a client's regulatory requirements is critical for ensuring compliance and avoiding penalties.
|
| 97 |
+
97. Effective leadership development programs can prepare future leaders within client organizations.
|
| 98 |
+
98. Consultants should help clients develop brand positioning strategies that differentiate them in the market.
|
| 99 |
+
99. Mergers and acquisitions can drive growth, but require careful planning and execution.
|
| 100 |
+
100. Consultants should emphasize the importance of digital literacy for all employees in client organizations.
|
| 101 |
+
101. Advanced analytics can provide deeper insights into client data, identifying trends and opportunities.
|
| 102 |
+
102. Consultants should recommend data protection best practices to secure client information.
|
| 103 |
+
103. Understanding the full customer journey can help consultants enhance the client’s customer experience.
|
| 104 |
+
104. Consultants should advise clients to prioritize corporate social responsibility initiatives for sustainability.
|
| 105 |
+
105. Solid stakeholder relationships are crucial for the successful implementation of strategic initiatives.
|
| 106 |
+
106. Consultants need to be proficient in project management tools to track progress and ensure accountability.
|
| 107 |
+
107. A client-centric approach can lead to higher customer satisfaction and loyalty.
|
| 108 |
+
108. Consultants should encourage clients to develop contingency plans for high-risk projects.
|
| 109 |
+
109. Continuous feedback mechanisms help clients adjust strategies to meet changing needs.
|
| 110 |
+
110. Consultants should assess a client's operational risk to minimize potential business disruptions.
|
| 111 |
+
111. Quantitative analysis can help clients make informed financial and strategic decisions.
|
| 112 |
+
112. Consultants should advocate for effective workplace communication practices to enhance collaboration.
|
| 113 |
+
113. Understanding the client's decision-making hierarchy can streamline approval processes.
|
| 114 |
+
114. Consultants should monitor client competition to identify emerging threats and opportunities.
|
| 115 |
+
115. Strategic portfolio management can help clients align projects with business objectives.
|
| 116 |
+
116. Consultants should encourage clients to leverage innovation to keep pace with market developments.
|
| 117 |
+
117. Building a strong organizational culture can lead to improved employee engagement and productivity.
|
| 118 |
+
118. Consultants should guide clients in balancing innovation with risk management.
|
| 119 |
+
119. Effective supply chain management can enhance a client’s operational efficiency and cost control.
|
| 120 |
+
120. Predictive analytics can help clients anticipate market trends and customer behaviors.
|
| 121 |
+
121. Consultants should assist clients in developing robust cybersecurity practices to protect data assets.
|
| 122 |
+
122. Understanding consumer sentiment analysis helps clients tailor their marketing and product development.
|
| 123 |
+
123. Consultants should advise on strategic use of artificial intelligence to improve business processes.
|
| 124 |
+
124. Training programs can enhance a client's workforce skills and adaptability.
|
| 125 |
+
125. Consultants should emphasize the importance of aligning IT strategy with business goals.
|
| 126 |
+
126. Automation in finance functions can lead to greater accuracy and efficiency in reporting.
|
| 127 |
+
127. Consultants need to identify the most impactful metrics for clients to track their strategic progress.
|
| 128 |
+
128. Effective presentation of complex solutions in simple terms helps clients with decision-making.
|
| 129 |
+
129. Consultants should help clients foster a customer-first mindset across their organization.
|
| 130 |
+
130. Identifying potential catalysts for change can guide strategic planning and execution.
|
| 131 |
+
131. Consultants should promote resilience thinking to help clients manage and adapt to change.
|
| 132 |
+
132. A strong feedback culture within organizations can drive innovation and continuous improvement.
|
| 133 |
+
133. Effective communication of value propositions helps consultants differentiate their services.
|
| 134 |
+
134. Emerging markets may offer growth opportunities for clients looking to expand internationally.
|
| 135 |
+
135. Building an effective performance review process can aid in tracking employee progress and development.
|
| 136 |
+
136. Consultants should guide clients in making data-informed decisions to mitigate business risks.
|
| 137 |
+
137. Digital content strategies can enhance a client's customer engagement and brand loyalty.
|
| 138 |
+
138. Consultants should advise on ways to improve organizational agility to adapt to market changes.
|
| 139 |
+
139. Market segmentation allows clients to tailor offerings to specific customer needs and preferences.
|
| 140 |
+
140. Consultants should help clients utilize collaborative tools to enhance team communication and productivity.
|
| 141 |
+
141. Change champions within organizations can influence and support transitions effectively.
|
| 142 |
+
142. Cybersecurity awareness training can prevent data breaches and protect sensitive client information.
|
| 143 |
+
143. Consultants should encourage leaders to model desired behaviors for culture transformation.
|
| 144 |
+
144. Managing a diversified investment portfolio can help clients reduce financial risk.
|
| 145 |
+
145. Emotional branding can differentiate a client's products or services by establishing strong customer connections.
|
| 146 |
+
146. Consultants should facilitate strategic workshops to foster alignment and consensus among stakeholders.
|
| 147 |
+
147. A client’s success in global markets hinges on effective market entry strategies.
|
| 148 |
+
148. Consultants should assist in developing business intelligence systems for data-driven decision-making.
|
| 149 |
+
149. Branding consistency across channels builds trust and recognition for a client's organization.
|
| 150 |
+
150. Consultants need to assess the socio-economic impact of client projects for responsible consulting.
|
| 151 |
+
151. Effective pricing strategies are crucial for client profitability and competitive positioning.
|
| 152 |
+
152. Customer journey mapping can help clients improve touchpoints and overall experience.
|
| 153 |
+
153. Consultants should advise on optimizing resource allocation to maximize project outcomes.
|
| 154 |
+
154. Employee retention strategies can lead to cost savings and improved client service delivery.
|
| 155 |
+
155. Strategic alliances can expand a client's capabilities and market reach through shared resources.
|
| 156 |
+
156. Consultants should assess the scalability of business models to support client growth objectives.
|
| 157 |
+
157. Good governance practices instill confidence and help mitigate client stakeholder risks.
|
| 158 |
+
158. Consultants need to develop skills in virtual tools to facilitate remote consulting engagements.
|
| 159 |
+
159. Effective internal communication supports engagement and keeps client personnel informed.
|
| 160 |
+
160. Risk mitigation strategies can help clients protect their assets and ensure business continuity.
|
| 161 |
+
161. Understanding the competitive landscape is essential for strategic positioning in the market.
|
| 162 |
+
162. Consultants should promote transparency in budgeting processes to build client trust.
|
| 163 |
+
163. Scaling strategies are crucial for clients aiming to grow their operations organically.
|
| 164 |
+
164. Consultants should guide clients in talent acquisition strategies to attract top-tier candidates.
|
| 165 |
+
165. Benchmarking against industry best practices can expose gaps and opportunities for improvement.
|
| 166 |
+
166. Consultants should encourage clients to conduct regular employee engagement surveys.
|
| 167 |
+
167. Emerging tech trends should be closely monitored to remain relevant in client advisement.
|
| 168 |
+
168. A focus on customer satisfaction is key to client reputation and long-term success.
|
| 169 |
+
169. Consultants should facilitate alignment between corporate strategy and functional objectives.
|
| 170 |
+
170. Effective crisis communication plans prevent misinformation and protect a client's credibility.
|
| 171 |
+
171. Cost-benefit analysis is important when deciding on significant client investments or projects.
|
| 172 |
+
172. Consultants should guide clients in nurturing relationships with key accounts and partners.
|
| 173 |
+
173. Encouraging innovation can make clients more competitive in an ever-evolving market landscape.
|
| 174 |
+
174. Consultants need to maintain industry certifications to showcase proficiency and credibility.
|
| 175 |
+
175. Effective retention marketing strategies can increase a client's repeat customer rates.
|
| 176 |
+
176. Consultants should assist in developing a flexible workplace strategy to attract diverse talent.
|
| 177 |
+
177. Engaging visual aids in presentations can enhance client understanding and retention.
|
| 178 |
+
178. Consultants should help clients streamline their supply chain to reduce costs and improve delivery times.
|
| 179 |
+
179. Understanding local regulations is essential for clients operating in multiple jurisdictions.
|
| 180 |
+
180. Consultants should enable a mindset shift from focusing on transactions to building relationships.
|
| 181 |
+
181. Utilizing cloud computing solutions can enhance a client’s data accessibility and collaboration.
|
| 182 |
+
182. Consultants should assess the potential social impact of strategic client decisions.
|
| 183 |
+
183. Efficient document management systems improve client accessibility and reduce information silos.
|
| 184 |
+
184. Consultants should guide clients in prioritizing digital skills development for future readiness.
|
| 185 |
+
185. Minimal viable products can help clients test market acceptance before full-scale launches.
|
| 186 |
+
186. Consultants should recommend integrating predictive maintenance to reduce client operational costs.
|
| 187 |
+
187. Sustainable and ethical sourcing can improve client supply chain reliability and reputation.
|
| 188 |
+
188. Cross-selling and upselling strategies can increase a client's revenue from existing customers.
|
| 189 |
+
189. Consultants should advise on workplace diversity initiatives for inclusive company culture.
|
| 190 |
+
190. Green business models can lead to long-term client sustainability and brand advantage.
|
| 191 |
+
191. Effective collaboration tools can support remote operations and enhance teamwork.
|
| 192 |
+
192. Consultants should help clients establish a vision that aligns with their core values and objectives.
|
| 193 |
+
193. Strategic foresight can assist clients in navigating potential future challenges and disruptions.
|
| 194 |
+
194. Consultants should facilitate workshops that bring diverse perspectives to develop creative solutions.
|
| 195 |
+
195. Analyzing customer feedback is crucial for understanding market needs and enhancing satisfaction.
|
| 196 |
+
196. Consultants need to promote resilience by advocating for adaptable client strategies.
|
| 197 |
+
197. Effective brand storytelling can create emotional connections and differentiate client offerings.
|
| 198 |
+
198. Consultants should engage in scenario planning to prepare for various future market conditions.
|
| 199 |
+
199. A consultative sales approach focuses on understanding and solving client needs rather than pushing a product.
|
| 200 |
+
200. Consultants should remain agile to adapt to dynamic client requirements and industry changes.
|
| 201 |
+
201. A holistic view of the value chain can help clients optimize operations and improve profitability.
|
| 202 |
+
202. Consultants should advise on corporate governance best practices to enhance client accountability.
|
| 203 |
+
203. Leveraging analytics can help clients personalize customer experiences and predict behavior.
|
| 204 |
+
204. Transparent reporting enhances trust and credibility in client-stakeholder communication.
|
| 205 |
+
205. Consultants should advocate for integrating environmental, social, and governance (ESG) criteria into client strategies.
|
| 206 |
+
206. Transformation roadmaps provide clear paths for clients undertaking digital or organizational changes.
|
| 207 |
+
207. Assessing a client's core competencies can guide strategic positioning and differentiation.
|
| 208 |
+
208. Consultants should assist in developing agile methodologies to boost client project execution.
|
| 209 |
+
209. Understanding consumer privacy and data protection regulations is critical for consultants advising on client compliance.
|
| 210 |
+
210. Regular competitive audits can keep clients informed on their positioning and market dynamics.
|
| 211 |
+
211. Consultants should encourage regular strategy reviews to ensure alignment with organizational goals.
|
| 212 |
+
212. Effective team leadership is key for successful project delivery in client engagements.
|
| 213 |
+
213. Consultants should guide clients in communicating strategic direction clearly across teams.
|
| 214 |
+
214. Enhancing customer service capabilities can lead to higher satisfaction and brand loyalty.
|
| 215 |
+
215. Consultants should promote data-driven insights for better strategic dialogue with clients.
|
| 216 |
+
216. Investing in leadership capabilities prepares clients for future organizational challenges.
|
| 217 |
+
217. Consultants should encourage a culture of feedback to enhance employee engagement and performance.
|
| 218 |
+
218. Strategic diversification can minimize client risk exposure and capitalize on new opportunities.
|
| 219 |
+
219. Consultants should support the adoption of technology solutions that align with client goals.
|
| 220 |
+
220. Incorporating predictive analytics helps forecast future trends and client market behavior.
|
| 221 |
+
221. Consultants should advise on structuring strategic alliances to boost competitive advantage.
|
| 222 |
+
222. Providing clients with a road map ensures clear steps and milestones for achieving goals.
|
| 223 |
+
223. Consultants should advocate for a strong legal framework to protect client intellectual property.
|
| 224 |
+
224. Effective product lifecycle management can increase a client's market responsiveness.
|
| 225 |
+
225. Consultants should focus on helping clients create a compelling customer value proposition.
|
| 226 |
+
226. Sustainability initiatives can enhance client brand perception and reduce environmental impact.
|
| 227 |
+
227. Consultants should encourage clients to align tech investments with business strategy for ROI.
|
| 228 |
+
228. Organizing cross-functional teams can bring diverse expertise to solve client problems.
|
| 229 |
+
229. Consultants should guide clients in strategic risk assessment to anticipate potential setbacks.
|
| 230 |
+
230. Leveraging digital ecosystems can expand client business models and market reach.
|
| 231 |
+
231. Consultants should ensure that clients develop robust strategies for digital customer engagement.
|
| 232 |
+
232. Change management is crucial for ensuring client transitions are well-received by employees.
|
| 233 |
+
233. Strategic agility can increase a client's ability to respond rapidly to market changes.
|
| 234 |
+
234. Consultants should promote the use of OKRs (Objectives and Key Results) to align teams.
|
| 235 |
+
235. Fostering a strong company culture can significantly impact client employee satisfaction.
|
| 236 |
+
236. Consultants should facilitate knowledge sharing to encourage collaboration and innovation.
|
| 237 |
+
237. Regular workforce analysis can aid in identifying skill gaps and future talent needs.
|
| 238 |
+
238. Consultants should advocate for clear succession planning to ensure leadership continuity.
|
| 239 |
+
239. Applying behavioral economics can help clients better understand customer decision processes.
|
| 240 |
+
240. Consultants should encourage long-term thinking for sustainable client business success.
|
| 241 |
+
241. Advanced insights from big data can drive better strategic decision-making for clients.
|
| 242 |
+
242. A focus on continuous improvement can enhance client competitiveness and efficiency.
|
| 243 |
+
243. Consultants should recommend tools and processes that enhance client work-life balance.
|
| 244 |
+
244. Encouraging open communication among teams fosters collaboration and innovation for clients.
|
| 245 |
+
245. Strategic foresight aligns a client’s actions with anticipated challenges and disruptions.
|
| 246 |
+
246. Consultants should promote integrated reporting for a holistic view of client business performance.
|
| 247 |
+
247. Effective use of KPIs can help track client progress toward strategic objectives.
|
| 248 |
+
248. Consultants should counsel on mergers and acquisitions to aid in strategic client growth.
|
| 249 |
+
249. Encouraging cognitive diversity in client teams can drive novel solutions and ideas.
|
| 250 |
+
250. Creating an inclusive workplace culture can benefit client employee engagement and performance.
|
| 251 |
+
251. Consultants should ensure that clients have robust customer relationship management (CRM) systems.
|
| 252 |
+
252. Agile HR practices can make client organizations more adaptable to rapid changes.
|
| 253 |
+
253. Consultants need to balance risk and innovation for clients to maintain competitive advantage.
|
| 254 |
+
254. Resilient supply chains can withstand disruptions and support client business continuity.
|
| 255 |
+
255. Consultants should consider the life cycle cost of client investment decisions for long-term value.
|
| 256 |
+
256. Engaging employees in strategic development processes drives alignment and ownership.
|
| 257 |
+
257. Consultants should identify potential new market segments for client business expansion.
|
| 258 |
+
258. Effective resource planning ensures that clients maximize efficiency and minimize waste.
|
| 259 |
+
259. Consultants should help clients navigate regulatory environments to maintain compliance.
|
| 260 |
+
260. Employing a user-centric design approach can enhance client product and service usability.
|
| 261 |
+
261. Tracking client competitors' benchmarks informs better strategic decision-making.
|
| 262 |
+
262. Consultants should guide clients in creating value networks to deliver enhanced solutions.
|
| 263 |
+
263. Collaborative innovation can enable clients to harness collective expertise and breakthroughs.
|
| 264 |
+
264. Consultants need to advocate for clear internal branding to support client engagement and loyalty.
|
| 265 |
+
265. Effective contingency planning helps clients prepare for and mitigate potential crises.
|
| 266 |
+
266. Consultants should facilitate workshops that focus on building strategic alignment across departments.
|
| 267 |
+
267. Providing frameworks for decision-making empowers clients to act with confidence and clarity.
|
| 268 |
+
268. Understanding the client's customer personas ensures more precise targeting and engagement.
|
| 269 |
+
269. Consultants should advocate for the strategic deployment of machine learning to enhance operations.
|
| 270 |
+
270. Structuring client operations for lean efficiency can reduce costs and improve productivity.
|
| 271 |
+
271. Consultants should promote narrative-driven reporting to make findings more compelling and memorable.
|
| 272 |
+
272. Visibility in client supply chains aids in the identification of potential bottlenecks and inefficiencies.
|
| 273 |
+
273. Consultants should encourage scenario modeling to prepare for diverse business conditions.
|
| 274 |
+
274. Employee value propositions help attract and retain top talent for clients.
|
| 275 |
+
275. Consultants should guide client strategic communications to align with brand vision and objectives.
|
| 276 |
+
276. Knowledge management systems can enhance client learning and resource-sharing opportunities.
|
| 277 |
+
277. Strategic outsourcing can help clients focus on core competencies while gaining external expertise.
|
| 278 |
+
278. Facilitating strategy sessions encourages diverse client inputs and fosters innovative solutions.
|
| 279 |
+
279. Consultants should promote process reengineering to streamline client workflows and improve outcomes.
|
| 280 |
+
280. Building resilient organizational frameworks can help clients withstand economic uncertainty.
|
| 281 |
+
281. Consultants should guide clients in resource risk analysis to optimize and safeguard operations.
|
| 282 |
+
282. Understanding generational diversity in the workforce can improve client recruitment and retention.
|
| 283 |
+
283. Consulting on boundary-spanning leadership can enhance client collaboration and capability building.
|
| 284 |
+
284. Effective governance structures ensure that clients maintain alignment with strategic goals.
|
| 285 |
+
285. Consultants should emphasize the value of mentoring and coaching for client employee development.
|
| 286 |
+
286. Leveraging smart technologies can drive client innovation and operational efficiency.
|
| 287 |
+
287. Implementing sustainability metrics can underscore a client's commitment to environmental stewardship.
|
| 288 |
+
288. Consultants should support data-driven marketing for individualized customer engagement and impact.
|
| 289 |
+
289. Supporting client leadership with strategic communication tools enhances alignment and clarity.
|
| 290 |
+
290. Consultants should promote systems thinking to enable holistic problem-solving for clients.
|
| 291 |
+
291. Emphasizing digital readiness prepares clients for technological disruptions and opportunities.
|
| 292 |
+
292. Effective brand management can elevate a client's market position and consumer trust.
|
| 293 |
+
293. Consultants need to advise on security protocols to safeguard client digital assets and infrastructures.
|
| 294 |
+
294. Implementing data governance frameworks supports responsible data use and compliance for clients.
|
| 295 |
+
295. Encouraging clients to explore new business models can unlock untapped opportunities.
|
| 296 |
+
296. Facilitating knowledge exchange programs can drive learning and innovation among client employees.
|
| 297 |
+
297. Investing in AI and automation can provide clients with efficiency gains and new capabilities.
|
| 298 |
+
298. Consultants should guide clients in building adaptive strategies that respond to real-time data.
|
| 299 |
+
299. Enhancing client cybersecurity measures can protect against data breaches and financial loss.
|
| 300 |
+
300. Consultants should prioritize ethical considerations in AI deployment for responsible innovation.
|
| 301 |
+
301. Building resilience frameworks helps clients navigate uncertain business landscapes.
|
| 302 |
+
302. Consultants need to advise on agile ways of working to enhance client organizational responsiveness.
|
| 303 |
+
303. Effective employee onboarding cultivates engagement and retention for clients.
|
| 304 |
+
304. Consultants should guide clients in balancing short-term wins with long-term strategic goals.
|
| 305 |
+
305. Robust feedback systems can drive continuous improvement and employee growth within client organizations.
|
| 306 |
+
306. Consultants should advocate for strong data literacy among client teams for effective analytics use.
|
| 307 |
+
307. Strategic ecosystem mapping helps clients understand and navigate their industry landscapes.
|
| 308 |
+
308. Consultants should emphasize principles of inclusive leadership for effective client team management.
|
| 309 |
+
309. Promoting client involvement in industry forums can enhance reputations and networks.
|
| 310 |
+
310. Building a client-centric culture prioritizes customer needs and drives sustained loyalty.
|
| 311 |
+
311. Consultants should guide clients in forming alliances for shared growth and risk mitigation.
|
| 312 |
+
312. Effective stakeholder engagement aligns client projects with community and market expectations.
|
| 313 |
+
313. Consultants should ensure that clients measure success against both financial and non-financial metrics.
|
| 314 |
+
314. Implementing transparency in supply chains can boost client credibility and ethical sourcing practices.
|
| 315 |
+
315. Leveraging behavioral insights can inform more effective client marketing and engagement strategies.
|
| 316 |
+
316. Consultants should promote agile project management techniques for high adaptability.
|
| 317 |
+
317. Ensuring regulatory compliance is essential for reducing client legal risk and building trust.
|
| 318 |
+
318. Strategic customer segmentation helps clients target and cater to diverse market needs.
|
| 319 |
+
319. Consultants should emphasize resilience thinking to equip clients for navigating complex systems.
|
| 320 |
+
320. Effective conflict resolution can maintain momentum and morale in client workplace contexts.
|
| 321 |
+
321. Encouraging innovation culture in client companies fosters dynamic problem-solving capabilities.
|
| 322 |
+
322. Consultants should facilitate cross-industry learning to bring broad perspectives to client challenges.
|
| 323 |
+
323. Communicating a clear strategic vision aligns client teams and motivates collective action.
|
| 324 |
+
324. Consultants should recommend continuous talent pipeline development to future-proof client organizations.
|
| 325 |
+
325. Effective sales and operations planning enhances client synchronization across functions.
|
| 326 |
+
326. Consultants should guide clients in adapting business strategies to meet evolving consumer demands.
|
| 327 |
+
327. Dynamic performance frameworks can adapt to changing contexts and enable client agility.
|
| 328 |
+
328. Consultants should assess client dependencies on critical processes for continuity planning.
|
| 329 |
+
329. Fostering open innovation can enhance client collaborations and strategic insights.
|
| 330 |
+
330. Consultants should encourage scenario-based strategic planning to improve client preparedness.
|
| 331 |
+
331. Developing CSR initiatives drives client community engagement and brand differentiation.
|
| 332 |
+
332. Consultants should support integration of sustainability in core client business strategies.
|
| 333 |
+
333. Enabling knowledge sharing among client teams encourages innovation and skill development.
|
| 334 |
+
334. Consultants should guide strategic narrative building to support client brand and stakeholder engagement.
|
| 335 |
+
335. Leveraging social impact can enhance a client's community relationships and market position.
|
| 336 |
+
336. Consultants need to prioritize client stakeholder value creation for comprehensive strategy alignment.
|
| 337 |
+
337. Harnessing organizational data can unlock insights and inform decision-making for clients.
|
| 338 |
+
338. Consultants should promote resilient leadership styles to guide client teams through change.
|
| 339 |
+
339. Strategic repositioning enables responsiveness to shifting client market dynamics.
|
| 340 |
+
340. Consultants should facilitate the adoption of market-driven insights for innovative client strategies.
|
| 341 |
+
341. Developing customer empathy supports client solutions aligned with real user needs.
|
| 342 |
+
342. Consultants should encourage a culture of excellence in client service delivery and performance.
|
| 343 |
+
343. Effective crisis management frameworks safeguard against client reputational risks.
|
| 344 |
+
344. Consultants should ensure alignment of client employee goals with overarching corporate objectives.
|
| 345 |
+
345. Leveraging digital identity systems can protect against fraud and enhance client security.
|
| 346 |
+
346. Enhanced customer analytics provides clients with a competitive edge in personalization.
|
| 347 |
+
347. Consultants should guide clients in capitalizing on digital cross-promotion opportunities.
|
| 348 |
+
348. Implementing co-creation processes can deepen client-customer relationships and innovation.
|
| 349 |
+
349. Consultants need to investigate disruptive forces to help clients navigate industry shifts.
|
| 350 |
+
350. Aligning client culture with strategy ensures organizational cohesiveness and purpose.
|
| 351 |
+
351. Consultants should help clients map business ecosystems to uncover opportunities for growth.
|
| 352 |
+
352. Building adaptive risk management enables clients to anticipate and mitigate potential threats.
|
| 353 |
+
353. Consultants should promote alignment with United Nations Sustainable Development Goals (UN SDGs) for societal impact.
|
| 354 |
+
354. Effective customer retention practices nurture durable client relationships and revenue streams.
|
| 355 |
+
355. Consultants need to uphold the highest ethical standards in advisory engagements to maintain client trust.
|
| 356 |
+
356. Facilitating digital transformation opens new avenues for client connectivity and operations.
|
| 357 |
+
357. Consultants should support clients in framing meaningful employee value propositions (EVPs).
|
| 358 |
+
358. Designing adaptive operating frameworks equips clients for evolving market challenges.
|
| 359 |
+
359. Consultants should guide leadership development programs to cultivate resilient client leaders.
|
| 360 |
+
360. Implementing strategic foresight prepares clients for dynamic industry landscapes and competition.
|
| 361 |
+
361. Creating strategic alliances can provide mutually beneficial growth for client businesses.
|
| 362 |
+
362. Consultants should support the alignment of organizational culture with client strategic values.
|
| 363 |
+
363. Effective content marketing strategies engage customers and enhance client brand relations.
|
| 364 |
+
364. Building strategic alignment across functions drives coherent and effective client operations.
|
| 365 |
+
365. Consultants should facilitate data value generation for competitive client insights.
|
| 366 |
+
366. Adopting strategic automation enhances client efficiency and value proposition.
|
| 367 |
+
367. Consultants should advocate life cycle analysis to reveal sustainable client product insights.
|
| 368 |
+
368. Engaging in strategic foresight aids in anticipating nonlinear client market changes.
|
| 369 |
+
369. Consultants should encourage the design of data governance for holistic client management.
|
| 370 |
+
370. Empowering employees with leadership opportunities builds future-ready client talent pipelines.
|
| 371 |
+
371. Consultants should advocate developing robust processes for environmental impact assessment.
|
| 372 |
+
372. Efficient resource management solutions optimize client asset utilization and performance.
|
| 373 |
+
373. Consultants should guide clients to assess strategic adaptability for dynamic industry positioning.
|
| 374 |
+
374. Developing comprehensive community engagement frameworks enhances client reputability.
|
| 375 |
+
375. Consultants should facilitate the alignment of innovation with business strategy for client growth.
|
| 376 |
+
376. Understanding geopolitical influences is critical for navigating client market complexities.
|
| 377 |
+
377. Consultants should guide clients in leveraging customer networks to drive innovation processes.
|
| 378 |
+
378. Building client-centric digital ecosystems expands engagement and functional capacity.
|
| 379 |
+
379. Consultants need to champion inclusive business models for sustainable client impact.
|
| 380 |
+
380. Promoting client adaptability encourages capability development for market responsiveness.
|
| 381 |
+
381. Facilitating customer journey insights advances personalized client service strategies.
|
| 382 |
+
382. Consultants should encourage client partnerships for cross-industry product innovation.
|
| 383 |
+
383. Incorporating stakeholder perspectives ensures comprehensive client decision frameworks.
|
| 384 |
+
384. Consultants need to instill strategic foresight for proactive client engagement.
|
| 385 |
+
385. Leveraging digital transformation frameworks offers clients escalated operational advantages.
|
| 386 |
+
386. Consultants should guide process simplification to improve client operational efficiencies.
|
| 387 |
+
387. Building climate resilience future-proofs clients against environmental disruptions.
|
| 388 |
+
388. Consultants should encourage empathy-driven design to improve client human-centered experiences.
|
| 389 |
+
389. Investing in strategic communication frameworks elevates client stakeholder engagement.
|
| 390 |
+
390. Consultants should facilitate data-driven decision-making cultures within client organizations.
|
| 391 |
+
391. Establishing a culture of resilience helps clients remain stable amidst market shifts.
|
| 392 |
+
392. Consultants should promote structured innovation processes for client-driven problem-solving.
|
| 393 |
+
393. Developing performance analytics enables clients to refine strategic effort alignment.
|
| 394 |
+
394. Consultants need to build client trust through intentional transparency and ethical professionalism.
|
| 395 |
+
395. Implementing consumer-focused analytics helps identify client-prioritized customer variables.
|
| 396 |
+
396. Consultants should advise clients on leveraging digital innovation for organizational advancement.
|
| 397 |
+
397. Streamlining client business processes enhances efficiency and accelerates transformation.
|
| 398 |
+
398. Consultants should promote circular economy principles for sustainable client operations.
|
| 399 |
+
399. Emphasizing the strategic vision strengthens client short- and long-term goal alignment.
|
| 400 |
+
400. Consultants should encourage strategic experimentation to uncover client industry innovations.
|
| 401 |
+
401. Aligning talent management with organizational strategy ensures skilled client capability.
|
| 402 |
+
402. Consultants need to structure robust data strategies for client-centric actionable insights.
|
| 403 |
+
403. Achieving balanced leadership supports informed and adaptive client decision-making.
|
| 404 |
+
404. Consultants should promote strong client employer branding to develop engaged talent pools.
|
| 405 |
+
405. Developing strategic dashboards aids in transparent client performance tracking.
|
| 406 |
+
406. Consultants should guide stakeholders in critical decision frameworks for client alignment.
|
| 407 |
+
407. Cross-channel marketing supports dynamic and smooth client customer journeys.
|
| 408 |
+
408. Consultants need to pride themselves on adaptive responsiveness to meet client evolving needs.
|
| 409 |
+
409. Facilitating sustainable supply chain models ensures client reliability and reputation.
|
| 410 |
+
410. Consultants should guide the world through ethical business transformation leadership.
|
| 411 |
+
411. Supporting purpose-driven client frameworks elevates strategic execution and focus.
|
| 412 |
+
412. Consultants should advance digital sustainability for responsible client innovation.
|
| 413 |
+
413. Promoting digital maturity instills strategic fluidity in client organizations.
|
| 414 |
+
414. Consultants should model ethical business practices for responsible and trustworthy client engagements.
|
| 415 |
+
415. Solidifying agile mindsets makes clients adaptable and likely to seize competitive opportunities.
|
| 416 |
+
416. Consultants need to practice effective adaptive leadership for client-centric engagement.
|
| 417 |
+
417. Encouraging continuous innovation embraces dynamic client value creation.
|
| 418 |
+
418. Consultants should offer frameworks maintaining balance between tactical implementation and strategic vision.
|
| 419 |
+
419. Nurturing strategic tribes empowers client safe spaces for collaborative innovation.
|
| 420 |
+
420. Consultants need to champion environmental stewardship within client business strategies.
|
| 421 |
+
421. Creating visionary alignment focuses client resources for impactful results.
|
| 422 |
+
422. Consultants should empower autonomous engagement to drive positive client transformations.
|
| 423 |
+
423. Venture into transformative client potential through proactive trend scouting and expertise.
|
| 424 |
+
424. Consultants need to prioritize culture-anchoring stability for durable client organizational health.
|
| 425 |
+
425. Designing client-responsive ecosystems embodies innovation and adaptability.
|
| 426 |
+
426. Consultants should advocate for strategic decarbonization to boost client sustainability.
|
| 427 |
+
427. Tailoring bespoke solutions ensures personalized approaches fit unique client needs.
|
| 428 |
+
428. Consultants should guide client exploration of multi-stakeholder collaborative platforms.
|
| 429 |
+
429. Encouraging mindfulness in leadership models promotes balanced client strategic execution.
|
| 430 |
+
430. Consultants need to leverage holistic systems approaches to solve adaptive client challenges.
|
| 431 |
+
431. Building cross-boundary relationships encourages innovative client ecosystem solutions.
|
| 432 |
+
432. Consultants should strategize on empowering sustainable client transitions.
|
| 433 |
+
433. Creating leadership alignment fosters shared vision for inspiring client-driven growth.
|
| 434 |
+
434. Consultants need to apply a resilience lens for durable and adaptive client strategy direction.
|
| 435 |
+
435. Articulating collaborative purposes inspires collective client action and engagement.
|
| 436 |
+
436. Consultants should foster cultural rejuvenation to energize client work environments.
|
| 437 |
+
437. Unleashing potential requires mindset shifts toward strategic client autonomy and innovation.
|
| 438 |
+
438. Consultants should maximize strategic synergies through collaborative client networks.
|
| 439 |
+
439. Enhancing customer experience frameworks supports client-centric service delivery.
|
| 440 |
+
440. Consultants need to mediate client knowledge exchanges for cross-disciplinary innovation.
|
| 441 |
+
441. Building strategic resilience ensures prepared client adaptation within volatile landscapes.
|
| 442 |
+
442. Cultivating an innovation mindset pushes client boundaries and captures market opportunities.
|
| 443 |
+
443. Consultants should design impact-focused action plans for coherent client engagements.
|
| 444 |
+
444. Unifying growth strategies equates to disciplined yet agile client operational efforts.
|
| 445 |
+
445. Consultants need to lead with humility, ensuring genuine and effective client collaboration.
|
| 446 |
+
446. Establishing cultural benchmarks roots client organizations in ethical and effective practices.
|
| 447 |
+
447. Consultants should integrate holistic sustainability for all-encompassing client progress.
|
| 448 |
+
448. Transformative client impact initiates through dynamic and inclusive strategic trajectories.
|
| 449 |
+
449. Leading through uncertainty demands empathy-driven strategic client leadership.
|
| 450 |
+
450. Consultants should uphold purposeful thinking for precisely aligned client exploration.
|
| 451 |
+
451. Creating digital bridges enables seamless client stakeholder engagement.
|
| 452 |
+
452. Consultants need to champion human capital, catalyzing intrinsic client adaptive capacity.
|
| 453 |
+
453. Fostering global cohesion embeds inclusivity into expansive client opportunity visions.
|
| 454 |
+
454. Coordinating fit-for-purpose strategies elevates client relevance in global settings.
|
| 455 |
+
455. Consultants should envision scenarios projecting future-reaching client strategic maps.
|
| 456 |
+
456. Partnering for change powers scalable client-centric organizational transformations.
|
| 457 |
+
457. Encouraging leadership authenticity strengthens intrinsic client trust and conviction.
|
| 458 |
+
458. Consultants should advise on data ethics practices to ensure responsible client innovation.
|
| 459 |
+
459. Fostering systemic innovation scales positive client societal contributions.
|
| 460 |
+
460. Consultants need to harness diversity as catalysts for complex client co-created ecosystems.
|
| 461 |
+
461. External collaboration dovetails adaptive strategies, accelerating client mutual progress.
|
| 462 |
+
462. Bridging strategy implementation gaps builds sustainable and effective client processes.
|
| 463 |
+
463. Consultants should advise on inclusive value models enhancing aligned client growth.
|
| 464 |
+
464. Nurturing trust unblocks creative and inclusive client multi-stakeholder engagements.
|
| 465 |
+
465. Consultants need to prioritize ecosystems enhancing integrative and cohesive client impacts.
|
| 466 |
+
466. Designing agile frameworks embraces client adaptability across fluctuating landscapes.
|
| 467 |
+
467. Consultants should build strategic synergies for sustainable and impactful client pathways.
|
| 468 |
+
468. System acumen highlights comprehensive client-centric capability augmentations.
|
| 469 |
+
469. Consultants need to enable empowered leadership models encouraging client diversity.
|
| 470 |
+
470. Facilitating social good reforms for broad-reaching client stakeholder engagement.
|
| 471 |
+
471. Consultants should cultivate resilience-building climate initiatives for client durability.
|
| 472 |
+
472. Integrated value delivery ensures coherent and strategic client service recognition.
|
| 473 |
+
473. Consultants need to map innovation ecosystems to uncover client-centric loci of value creation.
|
| 474 |
+
474. Driving lasting impact requires conscious alignment with future-focused client leadership philosophies.
|
| 475 |
+
475. Strategic reframing equips clients to rise above complexity via integrative change processes.
|
| 476 |
+
476. Consultants should urge perspective fluidity within client teams for dynamic alignment.
|
| 477 |
+
477. Agile mindsets unlock thriving strategic support and client market growth landscapes.
|
| 478 |
+
478. Proactive foresight advocates for responsible and sustainable client-centric design thinking.
|
| 479 |
+
479. Consultants should inspire transformative entrepreneurship through purposeful client impact ventures.
|
| 480 |
+
480. Ecosystem integration guides harmonious sustainable client trajectories.
|
| 481 |
+
481. Consultants need to design flexible pursuit boundaries for agile client opportunity engagement.
|
| 482 |
+
482. Creating progression pathways facilitates continuous and resolute client learning cycles.
|
| 483 |
+
483. Consultants should leverage global insights to root dynamic client-centric regional networks.
|
| 484 |
+
484. Facilitating value conversations capitalizes on synergistic and systemic client potential.
|
| 485 |
+
485. Electrifying leadership creates robust and inspiring developmental client programs.
|
| 486 |
+
486. Consultants need to envision co-created strategies anchored to long-term client-centered visions.
|
| 487 |
+
487. Empowering purposeful client journeys constructs linked innovative adventure paths.
|
| 488 |
+
488. Consultants should magnify centrifugal analogies expanding client solution spirals.
|
| 489 |
+
489. Strategizing communal networks spins up future-positive and interconnected client engagements.
|
| 490 |
+
490. Cultivating integrated and focused innovation brings engaged and earnest client transformation.
|
| 491 |
+
491. Consultants need to motivate productivity cultures championing constructively aligned client integration.
|
| 492 |
+
492. Curating ecosystem spaces cyclically refines collaborative client networks.
|
| 493 |
+
493. Consultants should empower clients to embrace wisely integrated technology landscapes.
|
| 494 |
+
494. Enabling communication dynamism roots authentic client channel interactions.
|
| 495 |
+
495. Proactive horizon mapping proactively anticipates symbiotic client-driven value transitions.
|
| 496 |
+
496. Consultants need to champion focused flexibility initiating agile shared client endeavors.
|
| 497 |
+
497. Igniting cross-industry innovation fuels pioneering and embedded client market impacts.
|
| 498 |
+
498. Robust and regenerative strategies ensure replenished and sustainable client development.
|
| 499 |
+
499. Embodying expansive humanism advances holistic client strategic orientations.
|
| 500 |
+
500. Consultants should support ethical and transparent frameworks anchoring inclusive client future trajectories.
|
external/TinyTroupe/data/grounding_examples/finance/Nubank (NU) - 3Q24 Earnings Release.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ad1381df76359d5b80b4fab315adc281b846efc00f65920fc4d59d6384789ff1
|
| 3 |
+
size 4445673
|
external/TinyTroupe/data/grounding_examples/finance/Vale do Rio Doce (VALE 3) - Transcript Vale’s 3Q24 Conference Call.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4be44d4606bc905c428dd332504d2a4baaf08a46d7b2e5d7aba5b170f3901bc6
|
| 3 |
+
size 237185
|
external/TinyTroupe/data/grounding_examples/finance/Vale do Rio Doce (VALE 3) - Vale's Performance in 3Q24.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d733d46d1e5fc5f6fd62a47cc2b50c1d331cf15c3047d7147d0f98828fd44195
|
| 3 |
+
size 957780
|
external/TinyTroupe/data/grounding_examples/general/World Bank Annual Report 2024.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4c4b484777eeb3f957165cb6aa9346bb9c092df34fb45c949b8ae80c4edeba89
|
| 3 |
+
size 11289865
|
external/TinyTroupe/data/grounding_examples/grounding_examples_1/don_quijote_project_gutenberg.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
external/TinyTroupe/data/grounding_examples/grounding_examples_1/marus_aurelius_meditations_by_project_gutenberg.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
external/TinyTroupe/data/grounding_examples/grounding_microsoft/2023_Microsoft_Annual_Report-LAPTOP-MGL2VFEC.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:31bd1d6064a9155e89807af959ed2cc59abcd2a9535d664a72e763ea2f6243b9
|
| 3 |
+
size 2242054
|
external/TinyTroupe/data/grounding_examples/grounding_microsoft/2023_Microsoft_Annual_Report.docx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:119811a7b79cf0bc1dfa0a2a9dbb678e86df1d99ef525aed828a90ebb4f695f4
|
| 3 |
+
size 1453152
|
external/TinyTroupe/data/grounding_examples/grounding_microsoft/2023_Microsoft_Annual_Report.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:42a6b8ffa5ab6dc0d3e0af55c55ed1a68c79ae7dc05f11b9e1adc7126efae3bb
|
| 3 |
+
size 2241595
|
external/TinyTroupe/data/grounding_examples/grounding_microsoft/2024_Annual_Report.docx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a8c33f3aa0ac8b0b6d86102f9011be9a0f5e98bd4b050dce61b17fee1e8ed60c
|
| 3 |
+
size 1795314
|
external/TinyTroupe/data/grounding_examples/grounding_microsoft/2024_Annual_Report.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:07c2f3bd4d4aefe064b1c9aa62da18abb87cabdada240838d3ac225f99f424f8
|
| 3 |
+
size 2300757
|
external/TinyTroupe/docs/api/tinytroupe/agent/action_generator.html
ADDED
|
@@ -0,0 +1,1365 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
|
| 6 |
+
<meta name="generator" content="pdoc 0.10.0" />
|
| 7 |
+
<title>tinytroupe.agent.action_generator API documentation</title>
|
| 8 |
+
<meta name="description" content="" />
|
| 9 |
+
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
|
| 10 |
+
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css" integrity="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg=" crossorigin>
|
| 11 |
+
<link rel="stylesheet preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css" crossorigin>
|
| 12 |
+
<style>:root{--highlight-color:#fe9}.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}#sidebar > *:last-child{margin-bottom:2cm}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}h1:target,h2:target,h3:target,h4:target,h5:target,h6:target{background:var(--highlight-color);padding:.2em 0}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{margin-top:.6em;font-weight:bold}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}dt:target .name{background:var(--highlight-color)}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}td{padding:0 .5em}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
|
| 13 |
+
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%;height:100vh;overflow:auto;position:sticky;top:0}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
|
| 14 |
+
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
|
| 15 |
+
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js" integrity="sha256-Uv3H6lx7dJmRfRvH8TH6kJD1TSK1aFcwgx+mdg3epi8=" crossorigin></script>
|
| 16 |
+
<script>window.addEventListener('DOMContentLoaded', () => hljs.initHighlighting())</script>
|
| 17 |
+
</head>
|
| 18 |
+
<body>
|
| 19 |
+
<main>
|
| 20 |
+
<article id="content">
|
| 21 |
+
<header>
|
| 22 |
+
<h1 class="title">Module <code>tinytroupe.agent.action_generator</code></h1>
|
| 23 |
+
</header>
|
| 24 |
+
<section id="section-intro">
|
| 25 |
+
<details class="source">
|
| 26 |
+
<summary>
|
| 27 |
+
<span>Expand source code</span>
|
| 28 |
+
</summary>
|
| 29 |
+
<pre><code class="python">import json
|
| 30 |
+
import statistics # Add this import
|
| 31 |
+
|
| 32 |
+
import tinytroupe.utils as utils
|
| 33 |
+
from tinytroupe.control import transactional, current_simulation
|
| 34 |
+
import tinytroupe.openai_utils as openai_utils
|
| 35 |
+
from tinytroupe.validation import propositions
|
| 36 |
+
from tinytroupe.utils import JsonSerializableRegistry
|
| 37 |
+
from tinytroupe.experimentation import Proposition
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
class ActionGenerator(JsonSerializableRegistry):
|
| 41 |
+
|
| 42 |
+
def __init__(self, max_attempts=2,
|
| 43 |
+
enable_quality_checks=True,
|
| 44 |
+
enable_regeneration=True,
|
| 45 |
+
enable_direct_correction=False, # TODO enable_direct_correction not working very well yet
|
| 46 |
+
enable_quality_check_for_persona_adherence=True,
|
| 47 |
+
enable_quality_check_for_selfconsistency=True,
|
| 48 |
+
enable_quality_check_for_fluency=True,
|
| 49 |
+
enable_quality_check_for_suitability=False,
|
| 50 |
+
enable_quality_check_for_similarity=False,
|
| 51 |
+
continue_on_failure=True,
|
| 52 |
+
quality_threshold=7,
|
| 53 |
+
max_action_similarity=0.6,
|
| 54 |
+
enable_reasoning_step=False): # TODO enable_reasoning_step not working very well yet
|
| 55 |
+
"""
|
| 56 |
+
Initializes the ActionGenerator.
|
| 57 |
+
|
| 58 |
+
Args:
|
| 59 |
+
max_attempts (int): The maximum number of attempts to generate an action.
|
| 60 |
+
enable_quality_checks (bool): Whether to perform quality checks on the generated action. If False, the first action generated
|
| 61 |
+
is returned without any checks.
|
| 62 |
+
enable_regeneration (bool): Whether to try to make the agent regenerate the action if the first attempt fails.
|
| 63 |
+
enable_direct_correction (bool): Whether to directly correct the action if the first attempt fails, without asking the agent to regenerate it.
|
| 64 |
+
enable_quality_check_for_persona_adherence (bool): Whether to check the action for persona adherence.
|
| 65 |
+
enable_quality_check_for_selfconsistency (bool): Whether to check the action for self-consistency.
|
| 66 |
+
enable_quality_check_for_fluency (bool): Whether to check the action for fluency.
|
| 67 |
+
enable_quality_check_for_suitability (bool): Whether to check the action for suitability.
|
| 68 |
+
continue_on_failure (bool): Whether to return the last tentative action, even if it fails to pass quality checks.
|
| 69 |
+
Presumably, the last tentative action is the one that is most likely to be correct, since it has gone through the most iterations of regeneration and correction.
|
| 70 |
+
quality_threshold (int): The minimum score for each quality check for the action to be considered good quality.
|
| 71 |
+
enable_reasoning_step (bool): Whether to enable reasoning step in the action generation process. This IS NOT the use of "reasoning models" (e.g., o1, o3),
|
| 72 |
+
but rather the use of an additional reasoning step in the regular text completion.
|
| 73 |
+
"""
|
| 74 |
+
|
| 75 |
+
self.max_attempts = max_attempts
|
| 76 |
+
self.regeneration_attempts = 0
|
| 77 |
+
self.direct_correction_attempts = 0
|
| 78 |
+
|
| 79 |
+
self.enable_quality_checks = enable_quality_checks
|
| 80 |
+
self.enable_regeneration = enable_regeneration
|
| 81 |
+
self.enable_direct_correction = enable_direct_correction
|
| 82 |
+
|
| 83 |
+
self.enable_quality_check_for_persona_adherence = enable_quality_check_for_persona_adherence
|
| 84 |
+
self.enable_quality_check_for_selfconsistency = enable_quality_check_for_selfconsistency
|
| 85 |
+
self.enable_quality_check_for_fluency = enable_quality_check_for_fluency
|
| 86 |
+
self.enable_quality_check_for_suitability = enable_quality_check_for_suitability
|
| 87 |
+
self.enable_quality_check_for_similarity = enable_quality_check_for_similarity
|
| 88 |
+
|
| 89 |
+
self.continue_on_failure = continue_on_failure
|
| 90 |
+
self.quality_threshold = quality_threshold
|
| 91 |
+
self.max_action_similarity = max_action_similarity
|
| 92 |
+
|
| 93 |
+
self.enable_reasoning_step = enable_reasoning_step
|
| 94 |
+
|
| 95 |
+
# This generator has its own copies of the propositions, in order to be able to isolate them
|
| 96 |
+
# from other agents, particularly when running the simulation in parallel.
|
| 97 |
+
self.action_persona_adherence = propositions.hard_action_persona_adherence.copy()
|
| 98 |
+
self.action_self_consistency = propositions.action_self_consistency.copy()
|
| 99 |
+
self.action_fluency = propositions.action_fluency.copy()
|
| 100 |
+
self.action_suitability = propositions.action_suitability.copy()
|
| 101 |
+
|
| 102 |
+
# initialize statistics
|
| 103 |
+
self.regeneration_failures = 0
|
| 104 |
+
self.direct_correction_failures = 0
|
| 105 |
+
self.regeneration_scores = []
|
| 106 |
+
self.direct_correction_scores = []
|
| 107 |
+
self.total_actions_produced = 0
|
| 108 |
+
self.total_original_actions_succeeded = 0
|
| 109 |
+
|
| 110 |
+
def generate_next_action(self, agent, current_messages:list):
|
| 111 |
+
|
| 112 |
+
from tinytroupe.agent import logger # import here to avoid circular import issues
|
| 113 |
+
|
| 114 |
+
# clean up (remove unnecessary elements) and copy the list of current messages to avoid modifying the original ones
|
| 115 |
+
current_messages = [
|
| 116 |
+
{"role": msg["role"], "content": json.dumps(msg["content"])}
|
| 117 |
+
for msg in current_messages
|
| 118 |
+
]
|
| 119 |
+
|
| 120 |
+
# starts with no feedback
|
| 121 |
+
cur_feedback = None
|
| 122 |
+
all_negative_feedbacks = []
|
| 123 |
+
|
| 124 |
+
best_action = None
|
| 125 |
+
best_role = None
|
| 126 |
+
best_content = None
|
| 127 |
+
best_score = float('-inf')
|
| 128 |
+
original_score = None
|
| 129 |
+
|
| 130 |
+
def update_best(tentative_action, role, content, total_score):
|
| 131 |
+
nonlocal best_action, best_role, best_content, best_score
|
| 132 |
+
if total_score > best_score:
|
| 133 |
+
best_action = tentative_action
|
| 134 |
+
best_role = role
|
| 135 |
+
best_content = content
|
| 136 |
+
best_score = total_score
|
| 137 |
+
|
| 138 |
+
def finish_return(tentative_action, role, content, final_score):
|
| 139 |
+
if original_score is not None and final_score > original_score:
|
| 140 |
+
logger.warning(f"[{agent.name}] improved total quality from {original_score} to {final_score}")
|
| 141 |
+
|
| 142 |
+
# ensure that tentative_action and content are dicts
|
| 143 |
+
if isinstance(tentative_action, str):
|
| 144 |
+
tentative_action = json.loads(tentative_action)
|
| 145 |
+
if isinstance(content, str):
|
| 146 |
+
content = json.loads(content)
|
| 147 |
+
|
| 148 |
+
return tentative_action, role, content, all_negative_feedbacks
|
| 149 |
+
|
| 150 |
+
# First attempt to generate an action
|
| 151 |
+
tentative_action, role, content = self._generate_tentative_action(agent, current_messages,
|
| 152 |
+
feedback_from_previous_attempt=cur_feedback,
|
| 153 |
+
previous_tentative_action=None,
|
| 154 |
+
previous_llm_role=None, previous_llm_content=None)
|
| 155 |
+
|
| 156 |
+
if self.enable_quality_checks:
|
| 157 |
+
# First quality check
|
| 158 |
+
good_quality, total_score, cur_feedback = self._check_action_quality("Original Action", agent, tentative_action=tentative_action)
|
| 159 |
+
update_best(tentative_action, role, content, total_score)
|
| 160 |
+
if original_score is None:
|
| 161 |
+
original_score = total_score
|
| 162 |
+
if good_quality:
|
| 163 |
+
self.total_original_actions_succeeded += 1
|
| 164 |
+
# Found a good action, let's return it now
|
| 165 |
+
return finish_return(tentative_action, role, content, total_score)
|
| 166 |
+
else:
|
| 167 |
+
logger.warning(f"[{agent.name}] Original action did not pass quality checks: {cur_feedback}")
|
| 168 |
+
all_negative_feedbacks.append(cur_feedback)
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
# GENERATE AND REGENERATE the action by the agent
|
| 172 |
+
#
|
| 173 |
+
# We first try to make the agent generate (via the current_messages passed) or regenerate the
|
| 174 |
+
# action based on feedback.
|
| 175 |
+
if self.enable_regeneration:
|
| 176 |
+
for attempt in range(self.max_attempts):
|
| 177 |
+
|
| 178 |
+
# Generate tentative action
|
| 179 |
+
tentative_action, role, content = self._generate_tentative_action(agent, current_messages,
|
| 180 |
+
feedback_from_previous_attempt=cur_feedback,
|
| 181 |
+
previous_tentative_action=tentative_action,
|
| 182 |
+
previous_llm_role=role, previous_llm_content=content)
|
| 183 |
+
logger.debug(f"[{agent.name}] Tentative action: {tentative_action}")
|
| 184 |
+
self.regeneration_attempts += 1
|
| 185 |
+
|
| 186 |
+
good_quality, total_score, cur_feedback = self._check_action_quality(f"Action Regeneration ({attempt})", agent, tentative_action=tentative_action)
|
| 187 |
+
update_best(tentative_action, role, content, total_score)
|
| 188 |
+
if good_quality:
|
| 189 |
+
# Found a good action, let's return it now
|
| 190 |
+
return finish_return(tentative_action, role, content, total_score)
|
| 191 |
+
else:
|
| 192 |
+
self.regeneration_failures += 1
|
| 193 |
+
self.regeneration_scores.append(total_score) # Assuming feedback contains a score
|
| 194 |
+
all_negative_feedbacks.append(cur_feedback)
|
| 195 |
+
|
| 196 |
+
# CORRECT OR REPHRASE the action directly
|
| 197 |
+
#
|
| 198 |
+
# If we got here, it means the agent was not able to directly generate an action
|
| 199 |
+
# of sufficient quality, so we'll try to rephrase it correctly directly now.
|
| 200 |
+
if self.enable_direct_correction:
|
| 201 |
+
for attempt in range(self.max_attempts):
|
| 202 |
+
tentative_action, role, content = self._correct_action(tentative_action, feedback=cur_feedback, llm_role=role, llm_content=content)
|
| 203 |
+
logger.warning(f"[{agent.name}] Rephrased the action directly as: {tentative_action}")
|
| 204 |
+
self.direct_correction_attempts += 1
|
| 205 |
+
|
| 206 |
+
good_quality, total_score, cur_feedback = self._check_action_quality(f"Direct Action Correction or Rephrasing ({attempt})", agent, tentative_action=tentative_action)
|
| 207 |
+
update_best(tentative_action, role, content, total_score)
|
| 208 |
+
if good_quality:
|
| 209 |
+
# Found a good action, let's return it now
|
| 210 |
+
return finish_return(tentative_action, role, content, total_score)
|
| 211 |
+
else:
|
| 212 |
+
self.direct_correction_failures += 1
|
| 213 |
+
self.direct_correction_scores.append(total_score) # Assuming feedback contains a score
|
| 214 |
+
all_negative_feedbacks.append(cur_feedback)
|
| 215 |
+
|
| 216 |
+
# If we got here, all attempts to generate a good action failed
|
| 217 |
+
if self.continue_on_failure:
|
| 218 |
+
logger.warning(f"[{agent.name}] All attempts to generate a good action failed. Returning the best one.")
|
| 219 |
+
return finish_return(best_action, best_role, best_content, best_score)
|
| 220 |
+
|
| 221 |
+
else:
|
| 222 |
+
raise PoorQualityActionException()
|
| 223 |
+
|
| 224 |
+
else:
|
| 225 |
+
# If we got here, it means that the action was generated without quality checks
|
| 226 |
+
# and we are not doing any regeneration or direct correction, so we can return it now.
|
| 227 |
+
return tentative_action, role, content, []
|
| 228 |
+
|
| 229 |
+
def _generate_tentative_action(self, agent, current_messages, feedback_from_previous_attempt=None,
|
| 230 |
+
previous_tentative_action=None,
|
| 231 |
+
previous_llm_role=None, previous_llm_content=None):
|
| 232 |
+
|
| 233 |
+
from tinytroupe.agent import logger, CognitiveActionModel, CognitiveActionModelWithReasoning # import here to avoid circular import issues
|
| 234 |
+
|
| 235 |
+
self.total_actions_produced += 1
|
| 236 |
+
|
| 237 |
+
# shallow clone current_messages
|
| 238 |
+
current_messages_context = current_messages.copy()
|
| 239 |
+
|
| 240 |
+
logger.debug(f"[{agent.name}] Sending messages to OpenAI API")
|
| 241 |
+
logger.debug(f"[{agent.name}] Last interaction: {current_messages[-1]}")
|
| 242 |
+
|
| 243 |
+
if feedback_from_previous_attempt:
|
| 244 |
+
#current_messages_copy.append({"role": previous_llm_role,
|
| 245 |
+
# "content": "TENTATIVE ACTION:" + json.dumps(previous_llm_content)})
|
| 246 |
+
|
| 247 |
+
current_messages_context.append({"role": "user",
|
| 248 |
+
"content": \
|
| 249 |
+
f"""
|
| 250 |
+
WARNING! TENTATIVE ACTION GENERATION FAILED IN QUALITY CHECKS!
|
| 251 |
+
|
| 252 |
+
You were about to produce the following action, as a sequence for the previous actions or feedbacks (if any):
|
| 253 |
+
```
|
| 254 |
+
{previous_tentative_action}
|
| 255 |
+
```
|
| 256 |
+
|
| 257 |
+
However, it failed to pass the quality checks (as described in the quality feedback below), and therefore it was aborted and not added
|
| 258 |
+
to the simulation trajectory.
|
| 259 |
+
|
| 260 |
+
Now you **must** try again to generate a **BETTER** action, such that the quality issues mentioned in the feedback are addressed,
|
| 261 |
+
or instead issue a DONE action and stop for this turn if it is unclear how to improve quality.
|
| 262 |
+
Your objective is to **PASS** the quality checks this time if possible.
|
| 263 |
+
|
| 264 |
+
You can choose either to FIX somehow the action you were about to produce, or to generate something COMPLETELY NEW and DIFFERENT.
|
| 265 |
+
Each time your tentative action fail a quality check, you should be MORE RADICAL in your changes, and try to produce
|
| 266 |
+
something that is **very** different from the previous attempts.
|
| 267 |
+
|
| 268 |
+
If it is unclear how to produce a better action, you can choose to issue a DONE action instead.
|
| 269 |
+
**It is better to stop acting than to act poorly.**
|
| 270 |
+
|
| 271 |
+
In general, desireable properties of the action are:
|
| 272 |
+
- The action is consistent with the agent's persona, it is what one would expect from the agent given its persona.
|
| 273 |
+
- The action is self-consistent, it does contradict the agent's previous actions.
|
| 274 |
+
- The action is fluent and natural, and does not repeat itself or use overly formulaic language.
|
| 275 |
+
|
| 276 |
+
{feedback_from_previous_attempt}
|
| 277 |
+
"""})
|
| 278 |
+
|
| 279 |
+
current_messages_context.append({"role": "system",
|
| 280 |
+
"content": "Now generate a better action based on the above feedback, or issue a DONE action if it is unclear how to improve quality."})
|
| 281 |
+
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
# TODO: remind the model of some key rules to follow?
|
| 285 |
+
#
|
| 286 |
+
#
|
| 287 |
+
#current_messages_context.append({"role": "user",
|
| 288 |
+
# "content": """
|
| 289 |
+
# Now you must generate a sequence of actions following the directives in your agent specification,
|
| 290 |
+
# complying with **all** instructions and contraints related to the action you use.
|
| 291 |
+
# In particular, to ensure the quality of your actions:
|
| 292 |
+
# - **DO NOT** generate similar content in a row! We want human-like, natural and fluent behavior, and thus avoid#repeatitive behavior.
|
| 293 |
+
# - THINK before taking further actions.
|
| 294 |
+
# - Avoid thinking for too long, and actually take some concrete action before being done, particularly if you are expected to provide some action.
|
| 295 |
+
# - Intercalate thinking with other actions.
|
| 296 |
+
# - The new sequence of actions must be coherent and consistent with the previous actions and stimuli. For example, do not assume an expected or
|
| 297 |
+
# desireable action already happened if that's not registered in the simulation history.
|
| 298 |
+
# - If you received any quality feedback, you **MUST** take it into account and improve your performance. Your next actions
|
| 299 |
+
# **must** be better than your previous ones if possible.
|
| 300 |
+
#
|
| 301 |
+
# If you can't produce a very good action, you may just issue a DONE action instead and remain silent. Rules to follow in #this case:
|
| 302 |
+
# - It is better to remain silent than repeating similar actions or making other mistakes.
|
| 303 |
+
# - Avoid remaining silent for too long (i.e., more than 3 times in a row), as this looks robotic and unnatural. If #necessary, you
|
| 304 |
+
# can communicate your difficulties in coming up with a proper action, or just say something like "I don't know what to say".
|
| 305 |
+
# - In case your thoughts or goals insistenly require you to **not** being quiet or silent, then you avoid just issuing #DONE if possible,
|
| 306 |
+
# and try to produce a new action. In this case, the new action might refer to the difficulties you are having in #coming up with
|
| 307 |
+
# a proper action in the first place.
|
| 308 |
+
#
|
| 309 |
+
# All of these actions **MUST** be rendered following the JSON specification perfectly, including all required keys (even #if their value is empty), **ALWAYS**.
|
| 310 |
+
# """
|
| 311 |
+
# })
|
| 312 |
+
#
|
| 313 |
+
|
| 314 |
+
current_messages_context.append({"role": "system",
|
| 315 |
+
"content": "Remember: the action you will now generate **MUST** be a **well-formatted** and **valid** JSON object. No extra text, no extra brackets, commas, or other syntax errors."})
|
| 316 |
+
|
| 317 |
+
if not self.enable_reasoning_step:
|
| 318 |
+
logger.debug(f"[{agent.name}] Reasoning step disabled.")
|
| 319 |
+
next_message = openai_utils.client().send_message(current_messages_context, response_format=CognitiveActionModel)
|
| 320 |
+
|
| 321 |
+
else:
|
| 322 |
+
logger.debug(f"[{agent.name}] Reasoning step enabled.")
|
| 323 |
+
|
| 324 |
+
# If the reasoning step is enabled, we add a system message to the context asking it to think step-by-step
|
| 325 |
+
#
|
| 326 |
+
#
|
| 327 |
+
#current_messages_context.append({"role": "system",
|
| 328 |
+
# "content": "In your response, you first use the \"reasoning\" field to think step-by-step about what is the next action and cognitive state that you are going to generate. To do so, you carefully consider: the agent specification given initially; additional instructions given later; and the history of stimuli and actions present in the simulation trajectory." +
|
| 329 |
+
# "Then, you generate the action in the \"action\" field, and generate cognitive state in the \"cognitive_state\" field." })
|
| 330 |
+
current_messages_context.append({"role": "system",
|
| 331 |
+
"content": "Use the \"reasoning\" field to add any reasoning process you might wish to use before generating the next action and cognitive state. "})
|
| 332 |
+
|
| 333 |
+
next_message = openai_utils.client().send_message(current_messages_context, response_format=CognitiveActionModelWithReasoning)
|
| 334 |
+
|
| 335 |
+
logger.debug(f"[{agent.name}] Received message: {next_message}")
|
| 336 |
+
|
| 337 |
+
role, content = next_message["role"], utils.extract_json(next_message["content"])
|
| 338 |
+
|
| 339 |
+
action = content['action']
|
| 340 |
+
logger.debug(f"{agent.name}'s action: {action}")
|
| 341 |
+
|
| 342 |
+
return action, role, content
|
| 343 |
+
|
| 344 |
+
###############################################################################################
|
| 345 |
+
# Quality evaluation methods
|
| 346 |
+
###############################################################################################
|
| 347 |
+
|
| 348 |
+
def _check_action_quality(self, stage, agent, tentative_action):
|
| 349 |
+
|
| 350 |
+
from tinytroupe.agent import logger # import here to avoid circular import issues
|
| 351 |
+
|
| 352 |
+
#
|
| 353 |
+
# Compute various propositions about the action
|
| 354 |
+
#
|
| 355 |
+
persona_adherence_passed, persona_adherence_score, persona_adherence_feedback = \
|
| 356 |
+
self._check_proposition(agent, self.action_persona_adherence, tentative_action, enable_proposition_check=self.enable_quality_check_for_persona_adherence)
|
| 357 |
+
|
| 358 |
+
selfconsistency_passed, selfconsistency_score, selfconsistency_feedback = \
|
| 359 |
+
self._check_proposition(agent, self.action_self_consistency, tentative_action, minimum_required_qty_of_actions=1, enable_proposition_check=self.enable_quality_check_for_selfconsistency)
|
| 360 |
+
|
| 361 |
+
fluency_passed, fluency_passed_score, fluency_feedback = \
|
| 362 |
+
self._check_proposition(agent, self.action_fluency, tentative_action, enable_proposition_check=self.enable_quality_check_for_fluency)
|
| 363 |
+
|
| 364 |
+
suitability_passed, suitability_score, suitability_feedback = \
|
| 365 |
+
self._check_proposition(agent, self.action_suitability, tentative_action, enable_proposition_check=self.enable_quality_check_for_suitability)
|
| 366 |
+
|
| 367 |
+
similarity_passed, similarity_score, similarity_feedback = \
|
| 368 |
+
self._check_next_action_similarity(agent, tentative_action, threshold=self.max_action_similarity, enable_similarity_check=self.enable_quality_check_for_similarity)
|
| 369 |
+
|
| 370 |
+
# put the results together
|
| 371 |
+
good_quality = persona_adherence_passed and selfconsistency_passed and fluency_passed and suitability_passed and similarity_passed
|
| 372 |
+
total_score = persona_adherence_score + selfconsistency_score + fluency_passed_score + suitability_score + (similarity_score * Proposition.MAX_SCORE)
|
| 373 |
+
|
| 374 |
+
combined_feedback = utils.combine_texts(
|
| 375 |
+
persona_adherence_feedback, selfconsistency_feedback, fluency_feedback, suitability_feedback, similarity_feedback
|
| 376 |
+
)
|
| 377 |
+
|
| 378 |
+
# give verdict
|
| 379 |
+
if good_quality:
|
| 380 |
+
return True, total_score, combined_feedback
|
| 381 |
+
|
| 382 |
+
else:
|
| 383 |
+
|
| 384 |
+
failure_feedback = \
|
| 385 |
+
f"""
|
| 386 |
+
# Quality feedback
|
| 387 |
+
|
| 388 |
+
This is the action that was about to be generated by the agent:
|
| 389 |
+
{tentative_action}
|
| 390 |
+
|
| 391 |
+
Unfortunately, the action failed to pass the quality checks, and therefore was aborted and not added to the similation trajectory.
|
| 392 |
+
The following problems were detected.
|
| 393 |
+
"""
|
| 394 |
+
|
| 395 |
+
if not persona_adherence_passed:
|
| 396 |
+
failure_feedback += f"""
|
| 397 |
+
## Problem: The action does not adhere to the persona specification.
|
| 398 |
+
{persona_adherence_feedback}
|
| 399 |
+
|
| 400 |
+
### RECOMMENDATIONS FOR IMPROVEMENT
|
| 401 |
+
Please follow the recommendations below when trying to generate this action again.
|
| 402 |
+
|
| 403 |
+
{self.action_persona_adherence.recommendations_for_improvement()}
|
| 404 |
+
|
| 405 |
+
"""
|
| 406 |
+
|
| 407 |
+
if not selfconsistency_passed:
|
| 408 |
+
failure_feedback += f"""
|
| 409 |
+
## Problem: The action is not self-consistent.
|
| 410 |
+
{selfconsistency_feedback}
|
| 411 |
+
|
| 412 |
+
### RECOMMENDATIONS FOR IMPROVEMENT
|
| 413 |
+
Please follow the recommendations below when trying to generate this action again.
|
| 414 |
+
|
| 415 |
+
{self.action_self_consistency.recommendations_for_improvement()}
|
| 416 |
+
|
| 417 |
+
"""
|
| 418 |
+
|
| 419 |
+
if not fluency_passed:
|
| 420 |
+
failure_feedback += f"""
|
| 421 |
+
## Problem: The action is not fluent.
|
| 422 |
+
{fluency_feedback}
|
| 423 |
+
|
| 424 |
+
### RECOMMENDATIONS FOR IMPROVEMENT
|
| 425 |
+
Please follow the recommendations below when trying to generate this action again.
|
| 426 |
+
|
| 427 |
+
{self.action_fluency.recommendations_for_improvement()}
|
| 428 |
+
|
| 429 |
+
"""
|
| 430 |
+
|
| 431 |
+
if not suitability_passed:
|
| 432 |
+
failure_feedback += f"""
|
| 433 |
+
## Problem: The action is not suitable to the situation or task.
|
| 434 |
+
{suitability_feedback}
|
| 435 |
+
|
| 436 |
+
### RECOMMENDATIONS FOR IMPROVEMENT
|
| 437 |
+
Please follow the recommendations below when trying to generate this action again.
|
| 438 |
+
|
| 439 |
+
{self.action_suitability.recommendations_for_improvement()}
|
| 440 |
+
|
| 441 |
+
"""
|
| 442 |
+
|
| 443 |
+
if not similarity_passed:
|
| 444 |
+
failure_feedback += f"""
|
| 445 |
+
## Problem: The action is too similar to the previous one.
|
| 446 |
+
{similarity_feedback}
|
| 447 |
+
|
| 448 |
+
"""
|
| 449 |
+
|
| 450 |
+
logger.warning(f"[{agent.name}][{stage}] failed to pass quality checks: {failure_feedback}")
|
| 451 |
+
return False, total_score, failure_feedback
|
| 452 |
+
|
| 453 |
+
|
| 454 |
+
def _check_proposition(self, agent, proposition, tentative_action, minimum_required_qty_of_actions=0, enable_proposition_check=True):
|
| 455 |
+
|
| 456 |
+
if enable_proposition_check:
|
| 457 |
+
if agent.actions_count >= minimum_required_qty_of_actions:
|
| 458 |
+
result = proposition.score(target=agent, claim_variables={"action": tentative_action}, return_full_response=True)
|
| 459 |
+
|
| 460 |
+
value_with_justification = f"Score = {result['value']} (out of {Proposition.MAX_SCORE}). Justification = {result['justification']}"
|
| 461 |
+
|
| 462 |
+
if result["value"] >= self.quality_threshold:
|
| 463 |
+
return True, result["value"], value_with_justification
|
| 464 |
+
else:
|
| 465 |
+
return False, result["value"], value_with_justification
|
| 466 |
+
|
| 467 |
+
else:
|
| 468 |
+
return True, Proposition.MAX_SCORE, f"The proposition is trivially true due to the lack of enough actions for comparison."
|
| 469 |
+
else:
|
| 470 |
+
# If the proposition check is disabled, we assume it passed
|
| 471 |
+
return True, Proposition.MAX_SCORE, f"The proposition check is disabled, so it is assumed to have passed."
|
| 472 |
+
|
| 473 |
+
def _check_next_action_similarity(self, agent, proposed_next_action, threshold, enable_similarity_check=True):
|
| 474 |
+
"""
|
| 475 |
+
Checks the similarity between the agent's current action and a proposed next action.
|
| 476 |
+
High similarity indicates that the proposed action is too similar to the current one, and this
|
| 477 |
+
check fails.
|
| 478 |
+
"""
|
| 479 |
+
from tinytroupe.agent import logger # import here to avoid circular import issues
|
| 480 |
+
|
| 481 |
+
if enable_similarity_check:
|
| 482 |
+
similarity = utils.next_action_jaccard_similarity(agent, proposed_next_action)
|
| 483 |
+
logger.debug(f"[{agent.name}] Next-action Jaccard similarity: {similarity}")
|
| 484 |
+
|
| 485 |
+
if similarity >= threshold:
|
| 486 |
+
logger.warning(f"[{agent.name}] Next-action Jaccard similarity is above the threshold ({threshold}).")
|
| 487 |
+
return False, similarity, f"Similarity = {similarity} (range: 0.0 to 1.0). The action is too similar to the previous one."
|
| 488 |
+
else:
|
| 489 |
+
logger.debug(f"[{agent.name}] Next-action Jaccard similarity is below the threshold ({threshold}).")
|
| 490 |
+
return True, similarity, f"Similarity = {similarity} (range: 0.0 to 1.0). The action is sufficiently different from the previous one."
|
| 491 |
+
|
| 492 |
+
else:
|
| 493 |
+
# If the similarity check is disabled, we assume it passed
|
| 494 |
+
return True, 0.0, f"The similarity check is disabled, so it is assumed to have passed."
|
| 495 |
+
|
| 496 |
+
################################################################################################
|
| 497 |
+
# Action correction methods
|
| 498 |
+
################################################################################################
|
| 499 |
+
|
| 500 |
+
def _correct_action(self, action:dict, feedback, llm_role, llm_content):
|
| 501 |
+
situation = \
|
| 502 |
+
f"""
|
| 503 |
+
The following action by an agent was observed:
|
| 504 |
+
|
| 505 |
+
{action}
|
| 506 |
+
|
| 507 |
+
However, it does not conform to expectations about this agent behavior,
|
| 508 |
+
due to the following reasons.
|
| 509 |
+
{feedback}
|
| 510 |
+
"""
|
| 511 |
+
#restructured_situation =\
|
| 512 |
+
# utils.restructure_as_observed_vs_expected(\
|
| 513 |
+
|
| 514 |
+
# """)
|
| 515 |
+
#rule = utils.formulate_corrective_rule(restructured_situation)
|
| 516 |
+
rules = utils.extract_observed_vs_expected_rules(situation)
|
| 517 |
+
rephrased_action_content = utils.correct_according_to_rule(action["content"], rules)
|
| 518 |
+
|
| 519 |
+
# copy action
|
| 520 |
+
rephrased_action = action.copy()
|
| 521 |
+
|
| 522 |
+
# update content
|
| 523 |
+
rephrased_action["content"] = rephrased_action_content
|
| 524 |
+
|
| 525 |
+
# replace in the 'action' key in the original llm content message
|
| 526 |
+
llm_content["action"] = rephrased_action
|
| 527 |
+
|
| 528 |
+
return rephrased_action, llm_role, llm_content
|
| 529 |
+
|
| 530 |
+
def get_statistics(self):
|
| 531 |
+
regeneration_failure_rate = self.regeneration_failures / self.regeneration_attempts if self.regeneration_attempts else 0
|
| 532 |
+
direct_correction_failure_rate = self.direct_correction_failures / self.direct_correction_attempts if self.direct_correction_attempts else 0
|
| 533 |
+
|
| 534 |
+
regeneration_mean_score = statistics.mean(self.regeneration_scores) if self.regeneration_scores else 0
|
| 535 |
+
regeneration_sd_score = statistics.stdev(self.regeneration_scores) if len(self.regeneration_scores) > 1 else 0
|
| 536 |
+
|
| 537 |
+
direct_correction_mean_score = statistics.mean(self.direct_correction_scores) if self.direct_correction_scores else 0
|
| 538 |
+
direct_correction_sd_score = statistics.stdev(self.direct_correction_scores) if len(self.direct_correction_scores) > 1 else 0
|
| 539 |
+
|
| 540 |
+
original_success_rate = self.total_original_actions_succeeded / self.total_actions_produced if self.total_actions_produced else 0
|
| 541 |
+
|
| 542 |
+
return {
|
| 543 |
+
"regeneration_failure_rate": regeneration_failure_rate,
|
| 544 |
+
"direct_correction_failure_rate": direct_correction_failure_rate,
|
| 545 |
+
"regeneration_mean_score": regeneration_mean_score,
|
| 546 |
+
"regeneration_sd_score": regeneration_sd_score,
|
| 547 |
+
"direct_correction_mean_score": direct_correction_mean_score,
|
| 548 |
+
"direct_correction_sd_score": direct_correction_sd_score,
|
| 549 |
+
"total_actions_produced": self.total_actions_produced,
|
| 550 |
+
"total_original_actions_succeeded": self.total_original_actions_succeeded,
|
| 551 |
+
"original_success_rate": original_success_rate,
|
| 552 |
+
"regeneration_success_rate": 1 - regeneration_failure_rate,
|
| 553 |
+
"direct_correction_success_rate": 1 - direct_correction_failure_rate
|
| 554 |
+
}
|
| 555 |
+
|
| 556 |
+
|
| 557 |
+
class PoorQualityActionException(Exception):
|
| 558 |
+
def __init__(self, message="The generated action is of poor quality"):
|
| 559 |
+
self.message = message
|
| 560 |
+
super().__init__(self.message)</code></pre>
|
| 561 |
+
</details>
|
| 562 |
+
</section>
|
| 563 |
+
<section>
|
| 564 |
+
</section>
|
| 565 |
+
<section>
|
| 566 |
+
</section>
|
| 567 |
+
<section>
|
| 568 |
+
</section>
|
| 569 |
+
<section>
|
| 570 |
+
<h2 class="section-title" id="header-classes">Classes</h2>
|
| 571 |
+
<dl>
|
| 572 |
+
<dt id="tinytroupe.agent.action_generator.ActionGenerator"><code class="flex name class">
|
| 573 |
+
<span>class <span class="ident">ActionGenerator</span></span>
|
| 574 |
+
<span>(</span><span>max_attempts=2, enable_quality_checks=True, enable_regeneration=True, enable_direct_correction=False, enable_quality_check_for_persona_adherence=True, enable_quality_check_for_selfconsistency=True, enable_quality_check_for_fluency=True, enable_quality_check_for_suitability=False, enable_quality_check_for_similarity=False, continue_on_failure=True, quality_threshold=7, max_action_similarity=0.6, enable_reasoning_step=False)</span>
|
| 575 |
+
</code></dt>
|
| 576 |
+
<dd>
|
| 577 |
+
<div class="desc"><p>A mixin class that provides JSON serialization, deserialization, and subclass registration.</p>
|
| 578 |
+
<p>Initializes the ActionGenerator.</p>
|
| 579 |
+
<h2 id="args">Args</h2>
|
| 580 |
+
<dl>
|
| 581 |
+
<dt><strong><code>max_attempts</code></strong> : <code>int</code></dt>
|
| 582 |
+
<dd>The maximum number of attempts to generate an action.</dd>
|
| 583 |
+
<dt><strong><code>enable_quality_checks</code></strong> : <code>bool</code></dt>
|
| 584 |
+
<dd>Whether to perform quality checks on the generated action. If False, the first action generated
|
| 585 |
+
is returned without any checks.</dd>
|
| 586 |
+
<dt><strong><code>enable_regeneration</code></strong> : <code>bool</code></dt>
|
| 587 |
+
<dd>Whether to try to make the agent regenerate the action if the first attempt fails.</dd>
|
| 588 |
+
<dt><strong><code>enable_direct_correction</code></strong> : <code>bool</code></dt>
|
| 589 |
+
<dd>Whether to directly correct the action if the first attempt fails, without asking the agent to regenerate it.</dd>
|
| 590 |
+
<dt><strong><code>enable_quality_check_for_persona_adherence</code></strong> : <code>bool</code></dt>
|
| 591 |
+
<dd>Whether to check the action for persona adherence.</dd>
|
| 592 |
+
<dt><strong><code>enable_quality_check_for_selfconsistency</code></strong> : <code>bool</code></dt>
|
| 593 |
+
<dd>Whether to check the action for self-consistency.</dd>
|
| 594 |
+
<dt><strong><code>enable_quality_check_for_fluency</code></strong> : <code>bool</code></dt>
|
| 595 |
+
<dd>Whether to check the action for fluency.</dd>
|
| 596 |
+
<dt><strong><code>enable_quality_check_for_suitability</code></strong> : <code>bool</code></dt>
|
| 597 |
+
<dd>Whether to check the action for suitability.</dd>
|
| 598 |
+
<dt><strong><code>continue_on_failure</code></strong> : <code>bool</code></dt>
|
| 599 |
+
<dd>Whether to return the last tentative action, even if it fails to pass quality checks.
|
| 600 |
+
Presumably, the last tentative action is the one that is most likely to be correct, since it has gone through the most iterations of regeneration and correction.</dd>
|
| 601 |
+
<dt><strong><code>quality_threshold</code></strong> : <code>int</code></dt>
|
| 602 |
+
<dd>The minimum score for each quality check for the action to be considered good quality.</dd>
|
| 603 |
+
<dt><strong><code>enable_reasoning_step</code></strong> : <code>bool</code></dt>
|
| 604 |
+
<dd>Whether to enable reasoning step in the action generation process. This IS NOT the use of "reasoning models" (e.g., o1, o3),
|
| 605 |
+
but rather the use of an additional reasoning step in the regular text completion.</dd>
|
| 606 |
+
</dl></div>
|
| 607 |
+
<details class="source">
|
| 608 |
+
<summary>
|
| 609 |
+
<span>Expand source code</span>
|
| 610 |
+
</summary>
|
| 611 |
+
<pre><code class="python">class ActionGenerator(JsonSerializableRegistry):
|
| 612 |
+
|
| 613 |
+
def __init__(self, max_attempts=2,
|
| 614 |
+
enable_quality_checks=True,
|
| 615 |
+
enable_regeneration=True,
|
| 616 |
+
enable_direct_correction=False, # TODO enable_direct_correction not working very well yet
|
| 617 |
+
enable_quality_check_for_persona_adherence=True,
|
| 618 |
+
enable_quality_check_for_selfconsistency=True,
|
| 619 |
+
enable_quality_check_for_fluency=True,
|
| 620 |
+
enable_quality_check_for_suitability=False,
|
| 621 |
+
enable_quality_check_for_similarity=False,
|
| 622 |
+
continue_on_failure=True,
|
| 623 |
+
quality_threshold=7,
|
| 624 |
+
max_action_similarity=0.6,
|
| 625 |
+
enable_reasoning_step=False): # TODO enable_reasoning_step not working very well yet
|
| 626 |
+
"""
|
| 627 |
+
Initializes the ActionGenerator.
|
| 628 |
+
|
| 629 |
+
Args:
|
| 630 |
+
max_attempts (int): The maximum number of attempts to generate an action.
|
| 631 |
+
enable_quality_checks (bool): Whether to perform quality checks on the generated action. If False, the first action generated
|
| 632 |
+
is returned without any checks.
|
| 633 |
+
enable_regeneration (bool): Whether to try to make the agent regenerate the action if the first attempt fails.
|
| 634 |
+
enable_direct_correction (bool): Whether to directly correct the action if the first attempt fails, without asking the agent to regenerate it.
|
| 635 |
+
enable_quality_check_for_persona_adherence (bool): Whether to check the action for persona adherence.
|
| 636 |
+
enable_quality_check_for_selfconsistency (bool): Whether to check the action for self-consistency.
|
| 637 |
+
enable_quality_check_for_fluency (bool): Whether to check the action for fluency.
|
| 638 |
+
enable_quality_check_for_suitability (bool): Whether to check the action for suitability.
|
| 639 |
+
continue_on_failure (bool): Whether to return the last tentative action, even if it fails to pass quality checks.
|
| 640 |
+
Presumably, the last tentative action is the one that is most likely to be correct, since it has gone through the most iterations of regeneration and correction.
|
| 641 |
+
quality_threshold (int): The minimum score for each quality check for the action to be considered good quality.
|
| 642 |
+
enable_reasoning_step (bool): Whether to enable reasoning step in the action generation process. This IS NOT the use of "reasoning models" (e.g., o1, o3),
|
| 643 |
+
but rather the use of an additional reasoning step in the regular text completion.
|
| 644 |
+
"""
|
| 645 |
+
|
| 646 |
+
self.max_attempts = max_attempts
|
| 647 |
+
self.regeneration_attempts = 0
|
| 648 |
+
self.direct_correction_attempts = 0
|
| 649 |
+
|
| 650 |
+
self.enable_quality_checks = enable_quality_checks
|
| 651 |
+
self.enable_regeneration = enable_regeneration
|
| 652 |
+
self.enable_direct_correction = enable_direct_correction
|
| 653 |
+
|
| 654 |
+
self.enable_quality_check_for_persona_adherence = enable_quality_check_for_persona_adherence
|
| 655 |
+
self.enable_quality_check_for_selfconsistency = enable_quality_check_for_selfconsistency
|
| 656 |
+
self.enable_quality_check_for_fluency = enable_quality_check_for_fluency
|
| 657 |
+
self.enable_quality_check_for_suitability = enable_quality_check_for_suitability
|
| 658 |
+
self.enable_quality_check_for_similarity = enable_quality_check_for_similarity
|
| 659 |
+
|
| 660 |
+
self.continue_on_failure = continue_on_failure
|
| 661 |
+
self.quality_threshold = quality_threshold
|
| 662 |
+
self.max_action_similarity = max_action_similarity
|
| 663 |
+
|
| 664 |
+
self.enable_reasoning_step = enable_reasoning_step
|
| 665 |
+
|
| 666 |
+
# This generator has its own copies of the propositions, in order to be able to isolate them
|
| 667 |
+
# from other agents, particularly when running the simulation in parallel.
|
| 668 |
+
self.action_persona_adherence = propositions.hard_action_persona_adherence.copy()
|
| 669 |
+
self.action_self_consistency = propositions.action_self_consistency.copy()
|
| 670 |
+
self.action_fluency = propositions.action_fluency.copy()
|
| 671 |
+
self.action_suitability = propositions.action_suitability.copy()
|
| 672 |
+
|
| 673 |
+
# initialize statistics
|
| 674 |
+
self.regeneration_failures = 0
|
| 675 |
+
self.direct_correction_failures = 0
|
| 676 |
+
self.regeneration_scores = []
|
| 677 |
+
self.direct_correction_scores = []
|
| 678 |
+
self.total_actions_produced = 0
|
| 679 |
+
self.total_original_actions_succeeded = 0
|
| 680 |
+
|
| 681 |
+
def generate_next_action(self, agent, current_messages:list):
|
| 682 |
+
|
| 683 |
+
from tinytroupe.agent import logger # import here to avoid circular import issues
|
| 684 |
+
|
| 685 |
+
# clean up (remove unnecessary elements) and copy the list of current messages to avoid modifying the original ones
|
| 686 |
+
current_messages = [
|
| 687 |
+
{"role": msg["role"], "content": json.dumps(msg["content"])}
|
| 688 |
+
for msg in current_messages
|
| 689 |
+
]
|
| 690 |
+
|
| 691 |
+
# starts with no feedback
|
| 692 |
+
cur_feedback = None
|
| 693 |
+
all_negative_feedbacks = []
|
| 694 |
+
|
| 695 |
+
best_action = None
|
| 696 |
+
best_role = None
|
| 697 |
+
best_content = None
|
| 698 |
+
best_score = float('-inf')
|
| 699 |
+
original_score = None
|
| 700 |
+
|
| 701 |
+
def update_best(tentative_action, role, content, total_score):
|
| 702 |
+
nonlocal best_action, best_role, best_content, best_score
|
| 703 |
+
if total_score > best_score:
|
| 704 |
+
best_action = tentative_action
|
| 705 |
+
best_role = role
|
| 706 |
+
best_content = content
|
| 707 |
+
best_score = total_score
|
| 708 |
+
|
| 709 |
+
def finish_return(tentative_action, role, content, final_score):
|
| 710 |
+
if original_score is not None and final_score > original_score:
|
| 711 |
+
logger.warning(f"[{agent.name}] improved total quality from {original_score} to {final_score}")
|
| 712 |
+
|
| 713 |
+
# ensure that tentative_action and content are dicts
|
| 714 |
+
if isinstance(tentative_action, str):
|
| 715 |
+
tentative_action = json.loads(tentative_action)
|
| 716 |
+
if isinstance(content, str):
|
| 717 |
+
content = json.loads(content)
|
| 718 |
+
|
| 719 |
+
return tentative_action, role, content, all_negative_feedbacks
|
| 720 |
+
|
| 721 |
+
# First attempt to generate an action
|
| 722 |
+
tentative_action, role, content = self._generate_tentative_action(agent, current_messages,
|
| 723 |
+
feedback_from_previous_attempt=cur_feedback,
|
| 724 |
+
previous_tentative_action=None,
|
| 725 |
+
previous_llm_role=None, previous_llm_content=None)
|
| 726 |
+
|
| 727 |
+
if self.enable_quality_checks:
|
| 728 |
+
# First quality check
|
| 729 |
+
good_quality, total_score, cur_feedback = self._check_action_quality("Original Action", agent, tentative_action=tentative_action)
|
| 730 |
+
update_best(tentative_action, role, content, total_score)
|
| 731 |
+
if original_score is None:
|
| 732 |
+
original_score = total_score
|
| 733 |
+
if good_quality:
|
| 734 |
+
self.total_original_actions_succeeded += 1
|
| 735 |
+
# Found a good action, let's return it now
|
| 736 |
+
return finish_return(tentative_action, role, content, total_score)
|
| 737 |
+
else:
|
| 738 |
+
logger.warning(f"[{agent.name}] Original action did not pass quality checks: {cur_feedback}")
|
| 739 |
+
all_negative_feedbacks.append(cur_feedback)
|
| 740 |
+
|
| 741 |
+
|
| 742 |
+
# GENERATE AND REGENERATE the action by the agent
|
| 743 |
+
#
|
| 744 |
+
# We first try to make the agent generate (via the current_messages passed) or regenerate the
|
| 745 |
+
# action based on feedback.
|
| 746 |
+
if self.enable_regeneration:
|
| 747 |
+
for attempt in range(self.max_attempts):
|
| 748 |
+
|
| 749 |
+
# Generate tentative action
|
| 750 |
+
tentative_action, role, content = self._generate_tentative_action(agent, current_messages,
|
| 751 |
+
feedback_from_previous_attempt=cur_feedback,
|
| 752 |
+
previous_tentative_action=tentative_action,
|
| 753 |
+
previous_llm_role=role, previous_llm_content=content)
|
| 754 |
+
logger.debug(f"[{agent.name}] Tentative action: {tentative_action}")
|
| 755 |
+
self.regeneration_attempts += 1
|
| 756 |
+
|
| 757 |
+
good_quality, total_score, cur_feedback = self._check_action_quality(f"Action Regeneration ({attempt})", agent, tentative_action=tentative_action)
|
| 758 |
+
update_best(tentative_action, role, content, total_score)
|
| 759 |
+
if good_quality:
|
| 760 |
+
# Found a good action, let's return it now
|
| 761 |
+
return finish_return(tentative_action, role, content, total_score)
|
| 762 |
+
else:
|
| 763 |
+
self.regeneration_failures += 1
|
| 764 |
+
self.regeneration_scores.append(total_score) # Assuming feedback contains a score
|
| 765 |
+
all_negative_feedbacks.append(cur_feedback)
|
| 766 |
+
|
| 767 |
+
# CORRECT OR REPHRASE the action directly
|
| 768 |
+
#
|
| 769 |
+
# If we got here, it means the agent was not able to directly generate an action
|
| 770 |
+
# of sufficient quality, so we'll try to rephrase it correctly directly now.
|
| 771 |
+
if self.enable_direct_correction:
|
| 772 |
+
for attempt in range(self.max_attempts):
|
| 773 |
+
tentative_action, role, content = self._correct_action(tentative_action, feedback=cur_feedback, llm_role=role, llm_content=content)
|
| 774 |
+
logger.warning(f"[{agent.name}] Rephrased the action directly as: {tentative_action}")
|
| 775 |
+
self.direct_correction_attempts += 1
|
| 776 |
+
|
| 777 |
+
good_quality, total_score, cur_feedback = self._check_action_quality(f"Direct Action Correction or Rephrasing ({attempt})", agent, tentative_action=tentative_action)
|
| 778 |
+
update_best(tentative_action, role, content, total_score)
|
| 779 |
+
if good_quality:
|
| 780 |
+
# Found a good action, let's return it now
|
| 781 |
+
return finish_return(tentative_action, role, content, total_score)
|
| 782 |
+
else:
|
| 783 |
+
self.direct_correction_failures += 1
|
| 784 |
+
self.direct_correction_scores.append(total_score) # Assuming feedback contains a score
|
| 785 |
+
all_negative_feedbacks.append(cur_feedback)
|
| 786 |
+
|
| 787 |
+
# If we got here, all attempts to generate a good action failed
|
| 788 |
+
if self.continue_on_failure:
|
| 789 |
+
logger.warning(f"[{agent.name}] All attempts to generate a good action failed. Returning the best one.")
|
| 790 |
+
return finish_return(best_action, best_role, best_content, best_score)
|
| 791 |
+
|
| 792 |
+
else:
|
| 793 |
+
raise PoorQualityActionException()
|
| 794 |
+
|
| 795 |
+
else:
|
| 796 |
+
# If we got here, it means that the action was generated without quality checks
|
| 797 |
+
# and we are not doing any regeneration or direct correction, so we can return it now.
|
| 798 |
+
return tentative_action, role, content, []
|
| 799 |
+
|
| 800 |
+
def _generate_tentative_action(self, agent, current_messages, feedback_from_previous_attempt=None,
|
| 801 |
+
previous_tentative_action=None,
|
| 802 |
+
previous_llm_role=None, previous_llm_content=None):
|
| 803 |
+
|
| 804 |
+
from tinytroupe.agent import logger, CognitiveActionModel, CognitiveActionModelWithReasoning # import here to avoid circular import issues
|
| 805 |
+
|
| 806 |
+
self.total_actions_produced += 1
|
| 807 |
+
|
| 808 |
+
# shallow clone current_messages
|
| 809 |
+
current_messages_context = current_messages.copy()
|
| 810 |
+
|
| 811 |
+
logger.debug(f"[{agent.name}] Sending messages to OpenAI API")
|
| 812 |
+
logger.debug(f"[{agent.name}] Last interaction: {current_messages[-1]}")
|
| 813 |
+
|
| 814 |
+
if feedback_from_previous_attempt:
|
| 815 |
+
#current_messages_copy.append({"role": previous_llm_role,
|
| 816 |
+
# "content": "TENTATIVE ACTION:" + json.dumps(previous_llm_content)})
|
| 817 |
+
|
| 818 |
+
current_messages_context.append({"role": "user",
|
| 819 |
+
"content": \
|
| 820 |
+
f"""
|
| 821 |
+
WARNING! TENTATIVE ACTION GENERATION FAILED IN QUALITY CHECKS!
|
| 822 |
+
|
| 823 |
+
You were about to produce the following action, as a sequence for the previous actions or feedbacks (if any):
|
| 824 |
+
```
|
| 825 |
+
{previous_tentative_action}
|
| 826 |
+
```
|
| 827 |
+
|
| 828 |
+
However, it failed to pass the quality checks (as described in the quality feedback below), and therefore it was aborted and not added
|
| 829 |
+
to the simulation trajectory.
|
| 830 |
+
|
| 831 |
+
Now you **must** try again to generate a **BETTER** action, such that the quality issues mentioned in the feedback are addressed,
|
| 832 |
+
or instead issue a DONE action and stop for this turn if it is unclear how to improve quality.
|
| 833 |
+
Your objective is to **PASS** the quality checks this time if possible.
|
| 834 |
+
|
| 835 |
+
You can choose either to FIX somehow the action you were about to produce, or to generate something COMPLETELY NEW and DIFFERENT.
|
| 836 |
+
Each time your tentative action fail a quality check, you should be MORE RADICAL in your changes, and try to produce
|
| 837 |
+
something that is **very** different from the previous attempts.
|
| 838 |
+
|
| 839 |
+
If it is unclear how to produce a better action, you can choose to issue a DONE action instead.
|
| 840 |
+
**It is better to stop acting than to act poorly.**
|
| 841 |
+
|
| 842 |
+
In general, desireable properties of the action are:
|
| 843 |
+
- The action is consistent with the agent's persona, it is what one would expect from the agent given its persona.
|
| 844 |
+
- The action is self-consistent, it does contradict the agent's previous actions.
|
| 845 |
+
- The action is fluent and natural, and does not repeat itself or use overly formulaic language.
|
| 846 |
+
|
| 847 |
+
{feedback_from_previous_attempt}
|
| 848 |
+
"""})
|
| 849 |
+
|
| 850 |
+
current_messages_context.append({"role": "system",
|
| 851 |
+
"content": "Now generate a better action based on the above feedback, or issue a DONE action if it is unclear how to improve quality."})
|
| 852 |
+
|
| 853 |
+
|
| 854 |
+
|
| 855 |
+
# TODO: remind the model of some key rules to follow?
|
| 856 |
+
#
|
| 857 |
+
#
|
| 858 |
+
#current_messages_context.append({"role": "user",
|
| 859 |
+
# "content": """
|
| 860 |
+
# Now you must generate a sequence of actions following the directives in your agent specification,
|
| 861 |
+
# complying with **all** instructions and contraints related to the action you use.
|
| 862 |
+
# In particular, to ensure the quality of your actions:
|
| 863 |
+
# - **DO NOT** generate similar content in a row! We want human-like, natural and fluent behavior, and thus avoid#repeatitive behavior.
|
| 864 |
+
# - THINK before taking further actions.
|
| 865 |
+
# - Avoid thinking for too long, and actually take some concrete action before being done, particularly if you are expected to provide some action.
|
| 866 |
+
# - Intercalate thinking with other actions.
|
| 867 |
+
# - The new sequence of actions must be coherent and consistent with the previous actions and stimuli. For example, do not assume an expected or
|
| 868 |
+
# desireable action already happened if that's not registered in the simulation history.
|
| 869 |
+
# - If you received any quality feedback, you **MUST** take it into account and improve your performance. Your next actions
|
| 870 |
+
# **must** be better than your previous ones if possible.
|
| 871 |
+
#
|
| 872 |
+
# If you can't produce a very good action, you may just issue a DONE action instead and remain silent. Rules to follow in #this case:
|
| 873 |
+
# - It is better to remain silent than repeating similar actions or making other mistakes.
|
| 874 |
+
# - Avoid remaining silent for too long (i.e., more than 3 times in a row), as this looks robotic and unnatural. If #necessary, you
|
| 875 |
+
# can communicate your difficulties in coming up with a proper action, or just say something like "I don't know what to say".
|
| 876 |
+
# - In case your thoughts or goals insistenly require you to **not** being quiet or silent, then you avoid just issuing #DONE if possible,
|
| 877 |
+
# and try to produce a new action. In this case, the new action might refer to the difficulties you are having in #coming up with
|
| 878 |
+
# a proper action in the first place.
|
| 879 |
+
#
|
| 880 |
+
# All of these actions **MUST** be rendered following the JSON specification perfectly, including all required keys (even #if their value is empty), **ALWAYS**.
|
| 881 |
+
# """
|
| 882 |
+
# })
|
| 883 |
+
#
|
| 884 |
+
|
| 885 |
+
current_messages_context.append({"role": "system",
|
| 886 |
+
"content": "Remember: the action you will now generate **MUST** be a **well-formatted** and **valid** JSON object. No extra text, no extra brackets, commas, or other syntax errors."})
|
| 887 |
+
|
| 888 |
+
if not self.enable_reasoning_step:
|
| 889 |
+
logger.debug(f"[{agent.name}] Reasoning step disabled.")
|
| 890 |
+
next_message = openai_utils.client().send_message(current_messages_context, response_format=CognitiveActionModel)
|
| 891 |
+
|
| 892 |
+
else:
|
| 893 |
+
logger.debug(f"[{agent.name}] Reasoning step enabled.")
|
| 894 |
+
|
| 895 |
+
# If the reasoning step is enabled, we add a system message to the context asking it to think step-by-step
|
| 896 |
+
#
|
| 897 |
+
#
|
| 898 |
+
#current_messages_context.append({"role": "system",
|
| 899 |
+
# "content": "In your response, you first use the \"reasoning\" field to think step-by-step about what is the next action and cognitive state that you are going to generate. To do so, you carefully consider: the agent specification given initially; additional instructions given later; and the history of stimuli and actions present in the simulation trajectory." +
|
| 900 |
+
# "Then, you generate the action in the \"action\" field, and generate cognitive state in the \"cognitive_state\" field." })
|
| 901 |
+
current_messages_context.append({"role": "system",
|
| 902 |
+
"content": "Use the \"reasoning\" field to add any reasoning process you might wish to use before generating the next action and cognitive state. "})
|
| 903 |
+
|
| 904 |
+
next_message = openai_utils.client().send_message(current_messages_context, response_format=CognitiveActionModelWithReasoning)
|
| 905 |
+
|
| 906 |
+
logger.debug(f"[{agent.name}] Received message: {next_message}")
|
| 907 |
+
|
| 908 |
+
role, content = next_message["role"], utils.extract_json(next_message["content"])
|
| 909 |
+
|
| 910 |
+
action = content['action']
|
| 911 |
+
logger.debug(f"{agent.name}'s action: {action}")
|
| 912 |
+
|
| 913 |
+
return action, role, content
|
| 914 |
+
|
| 915 |
+
###############################################################################################
|
| 916 |
+
# Quality evaluation methods
|
| 917 |
+
###############################################################################################
|
| 918 |
+
|
| 919 |
+
def _check_action_quality(self, stage, agent, tentative_action):
|
| 920 |
+
|
| 921 |
+
from tinytroupe.agent import logger # import here to avoid circular import issues
|
| 922 |
+
|
| 923 |
+
#
|
| 924 |
+
# Compute various propositions about the action
|
| 925 |
+
#
|
| 926 |
+
persona_adherence_passed, persona_adherence_score, persona_adherence_feedback = \
|
| 927 |
+
self._check_proposition(agent, self.action_persona_adherence, tentative_action, enable_proposition_check=self.enable_quality_check_for_persona_adherence)
|
| 928 |
+
|
| 929 |
+
selfconsistency_passed, selfconsistency_score, selfconsistency_feedback = \
|
| 930 |
+
self._check_proposition(agent, self.action_self_consistency, tentative_action, minimum_required_qty_of_actions=1, enable_proposition_check=self.enable_quality_check_for_selfconsistency)
|
| 931 |
+
|
| 932 |
+
fluency_passed, fluency_passed_score, fluency_feedback = \
|
| 933 |
+
self._check_proposition(agent, self.action_fluency, tentative_action, enable_proposition_check=self.enable_quality_check_for_fluency)
|
| 934 |
+
|
| 935 |
+
suitability_passed, suitability_score, suitability_feedback = \
|
| 936 |
+
self._check_proposition(agent, self.action_suitability, tentative_action, enable_proposition_check=self.enable_quality_check_for_suitability)
|
| 937 |
+
|
| 938 |
+
similarity_passed, similarity_score, similarity_feedback = \
|
| 939 |
+
self._check_next_action_similarity(agent, tentative_action, threshold=self.max_action_similarity, enable_similarity_check=self.enable_quality_check_for_similarity)
|
| 940 |
+
|
| 941 |
+
# put the results together
|
| 942 |
+
good_quality = persona_adherence_passed and selfconsistency_passed and fluency_passed and suitability_passed and similarity_passed
|
| 943 |
+
total_score = persona_adherence_score + selfconsistency_score + fluency_passed_score + suitability_score + (similarity_score * Proposition.MAX_SCORE)
|
| 944 |
+
|
| 945 |
+
combined_feedback = utils.combine_texts(
|
| 946 |
+
persona_adherence_feedback, selfconsistency_feedback, fluency_feedback, suitability_feedback, similarity_feedback
|
| 947 |
+
)
|
| 948 |
+
|
| 949 |
+
# give verdict
|
| 950 |
+
if good_quality:
|
| 951 |
+
return True, total_score, combined_feedback
|
| 952 |
+
|
| 953 |
+
else:
|
| 954 |
+
|
| 955 |
+
failure_feedback = \
|
| 956 |
+
f"""
|
| 957 |
+
# Quality feedback
|
| 958 |
+
|
| 959 |
+
This is the action that was about to be generated by the agent:
|
| 960 |
+
{tentative_action}
|
| 961 |
+
|
| 962 |
+
Unfortunately, the action failed to pass the quality checks, and therefore was aborted and not added to the similation trajectory.
|
| 963 |
+
The following problems were detected.
|
| 964 |
+
"""
|
| 965 |
+
|
| 966 |
+
if not persona_adherence_passed:
|
| 967 |
+
failure_feedback += f"""
|
| 968 |
+
## Problem: The action does not adhere to the persona specification.
|
| 969 |
+
{persona_adherence_feedback}
|
| 970 |
+
|
| 971 |
+
### RECOMMENDATIONS FOR IMPROVEMENT
|
| 972 |
+
Please follow the recommendations below when trying to generate this action again.
|
| 973 |
+
|
| 974 |
+
{self.action_persona_adherence.recommendations_for_improvement()}
|
| 975 |
+
|
| 976 |
+
"""
|
| 977 |
+
|
| 978 |
+
if not selfconsistency_passed:
|
| 979 |
+
failure_feedback += f"""
|
| 980 |
+
## Problem: The action is not self-consistent.
|
| 981 |
+
{selfconsistency_feedback}
|
| 982 |
+
|
| 983 |
+
### RECOMMENDATIONS FOR IMPROVEMENT
|
| 984 |
+
Please follow the recommendations below when trying to generate this action again.
|
| 985 |
+
|
| 986 |
+
{self.action_self_consistency.recommendations_for_improvement()}
|
| 987 |
+
|
| 988 |
+
"""
|
| 989 |
+
|
| 990 |
+
if not fluency_passed:
|
| 991 |
+
failure_feedback += f"""
|
| 992 |
+
## Problem: The action is not fluent.
|
| 993 |
+
{fluency_feedback}
|
| 994 |
+
|
| 995 |
+
### RECOMMENDATIONS FOR IMPROVEMENT
|
| 996 |
+
Please follow the recommendations below when trying to generate this action again.
|
| 997 |
+
|
| 998 |
+
{self.action_fluency.recommendations_for_improvement()}
|
| 999 |
+
|
| 1000 |
+
"""
|
| 1001 |
+
|
| 1002 |
+
if not suitability_passed:
|
| 1003 |
+
failure_feedback += f"""
|
| 1004 |
+
## Problem: The action is not suitable to the situation or task.
|
| 1005 |
+
{suitability_feedback}
|
| 1006 |
+
|
| 1007 |
+
### RECOMMENDATIONS FOR IMPROVEMENT
|
| 1008 |
+
Please follow the recommendations below when trying to generate this action again.
|
| 1009 |
+
|
| 1010 |
+
{self.action_suitability.recommendations_for_improvement()}
|
| 1011 |
+
|
| 1012 |
+
"""
|
| 1013 |
+
|
| 1014 |
+
if not similarity_passed:
|
| 1015 |
+
failure_feedback += f"""
|
| 1016 |
+
## Problem: The action is too similar to the previous one.
|
| 1017 |
+
{similarity_feedback}
|
| 1018 |
+
|
| 1019 |
+
"""
|
| 1020 |
+
|
| 1021 |
+
logger.warning(f"[{agent.name}][{stage}] failed to pass quality checks: {failure_feedback}")
|
| 1022 |
+
return False, total_score, failure_feedback
|
| 1023 |
+
|
| 1024 |
+
|
| 1025 |
+
def _check_proposition(self, agent, proposition, tentative_action, minimum_required_qty_of_actions=0, enable_proposition_check=True):
|
| 1026 |
+
|
| 1027 |
+
if enable_proposition_check:
|
| 1028 |
+
if agent.actions_count >= minimum_required_qty_of_actions:
|
| 1029 |
+
result = proposition.score(target=agent, claim_variables={"action": tentative_action}, return_full_response=True)
|
| 1030 |
+
|
| 1031 |
+
value_with_justification = f"Score = {result['value']} (out of {Proposition.MAX_SCORE}). Justification = {result['justification']}"
|
| 1032 |
+
|
| 1033 |
+
if result["value"] >= self.quality_threshold:
|
| 1034 |
+
return True, result["value"], value_with_justification
|
| 1035 |
+
else:
|
| 1036 |
+
return False, result["value"], value_with_justification
|
| 1037 |
+
|
| 1038 |
+
else:
|
| 1039 |
+
return True, Proposition.MAX_SCORE, f"The proposition is trivially true due to the lack of enough actions for comparison."
|
| 1040 |
+
else:
|
| 1041 |
+
# If the proposition check is disabled, we assume it passed
|
| 1042 |
+
return True, Proposition.MAX_SCORE, f"The proposition check is disabled, so it is assumed to have passed."
|
| 1043 |
+
|
| 1044 |
+
def _check_next_action_similarity(self, agent, proposed_next_action, threshold, enable_similarity_check=True):
|
| 1045 |
+
"""
|
| 1046 |
+
Checks the similarity between the agent's current action and a proposed next action.
|
| 1047 |
+
High similarity indicates that the proposed action is too similar to the current one, and this
|
| 1048 |
+
check fails.
|
| 1049 |
+
"""
|
| 1050 |
+
from tinytroupe.agent import logger # import here to avoid circular import issues
|
| 1051 |
+
|
| 1052 |
+
if enable_similarity_check:
|
| 1053 |
+
similarity = utils.next_action_jaccard_similarity(agent, proposed_next_action)
|
| 1054 |
+
logger.debug(f"[{agent.name}] Next-action Jaccard similarity: {similarity}")
|
| 1055 |
+
|
| 1056 |
+
if similarity >= threshold:
|
| 1057 |
+
logger.warning(f"[{agent.name}] Next-action Jaccard similarity is above the threshold ({threshold}).")
|
| 1058 |
+
return False, similarity, f"Similarity = {similarity} (range: 0.0 to 1.0). The action is too similar to the previous one."
|
| 1059 |
+
else:
|
| 1060 |
+
logger.debug(f"[{agent.name}] Next-action Jaccard similarity is below the threshold ({threshold}).")
|
| 1061 |
+
return True, similarity, f"Similarity = {similarity} (range: 0.0 to 1.0). The action is sufficiently different from the previous one."
|
| 1062 |
+
|
| 1063 |
+
else:
|
| 1064 |
+
# If the similarity check is disabled, we assume it passed
|
| 1065 |
+
return True, 0.0, f"The similarity check is disabled, so it is assumed to have passed."
|
| 1066 |
+
|
| 1067 |
+
################################################################################################
|
| 1068 |
+
# Action correction methods
|
| 1069 |
+
################################################################################################
|
| 1070 |
+
|
| 1071 |
+
def _correct_action(self, action:dict, feedback, llm_role, llm_content):
|
| 1072 |
+
situation = \
|
| 1073 |
+
f"""
|
| 1074 |
+
The following action by an agent was observed:
|
| 1075 |
+
|
| 1076 |
+
{action}
|
| 1077 |
+
|
| 1078 |
+
However, it does not conform to expectations about this agent behavior,
|
| 1079 |
+
due to the following reasons.
|
| 1080 |
+
{feedback}
|
| 1081 |
+
"""
|
| 1082 |
+
#restructured_situation =\
|
| 1083 |
+
# utils.restructure_as_observed_vs_expected(\
|
| 1084 |
+
|
| 1085 |
+
# """)
|
| 1086 |
+
#rule = utils.formulate_corrective_rule(restructured_situation)
|
| 1087 |
+
rules = utils.extract_observed_vs_expected_rules(situation)
|
| 1088 |
+
rephrased_action_content = utils.correct_according_to_rule(action["content"], rules)
|
| 1089 |
+
|
| 1090 |
+
# copy action
|
| 1091 |
+
rephrased_action = action.copy()
|
| 1092 |
+
|
| 1093 |
+
# update content
|
| 1094 |
+
rephrased_action["content"] = rephrased_action_content
|
| 1095 |
+
|
| 1096 |
+
# replace in the 'action' key in the original llm content message
|
| 1097 |
+
llm_content["action"] = rephrased_action
|
| 1098 |
+
|
| 1099 |
+
return rephrased_action, llm_role, llm_content
|
| 1100 |
+
|
| 1101 |
+
def get_statistics(self):
|
| 1102 |
+
regeneration_failure_rate = self.regeneration_failures / self.regeneration_attempts if self.regeneration_attempts else 0
|
| 1103 |
+
direct_correction_failure_rate = self.direct_correction_failures / self.direct_correction_attempts if self.direct_correction_attempts else 0
|
| 1104 |
+
|
| 1105 |
+
regeneration_mean_score = statistics.mean(self.regeneration_scores) if self.regeneration_scores else 0
|
| 1106 |
+
regeneration_sd_score = statistics.stdev(self.regeneration_scores) if len(self.regeneration_scores) > 1 else 0
|
| 1107 |
+
|
| 1108 |
+
direct_correction_mean_score = statistics.mean(self.direct_correction_scores) if self.direct_correction_scores else 0
|
| 1109 |
+
direct_correction_sd_score = statistics.stdev(self.direct_correction_scores) if len(self.direct_correction_scores) > 1 else 0
|
| 1110 |
+
|
| 1111 |
+
original_success_rate = self.total_original_actions_succeeded / self.total_actions_produced if self.total_actions_produced else 0
|
| 1112 |
+
|
| 1113 |
+
return {
|
| 1114 |
+
"regeneration_failure_rate": regeneration_failure_rate,
|
| 1115 |
+
"direct_correction_failure_rate": direct_correction_failure_rate,
|
| 1116 |
+
"regeneration_mean_score": regeneration_mean_score,
|
| 1117 |
+
"regeneration_sd_score": regeneration_sd_score,
|
| 1118 |
+
"direct_correction_mean_score": direct_correction_mean_score,
|
| 1119 |
+
"direct_correction_sd_score": direct_correction_sd_score,
|
| 1120 |
+
"total_actions_produced": self.total_actions_produced,
|
| 1121 |
+
"total_original_actions_succeeded": self.total_original_actions_succeeded,
|
| 1122 |
+
"original_success_rate": original_success_rate,
|
| 1123 |
+
"regeneration_success_rate": 1 - regeneration_failure_rate,
|
| 1124 |
+
"direct_correction_success_rate": 1 - direct_correction_failure_rate
|
| 1125 |
+
}</code></pre>
|
| 1126 |
+
</details>
|
| 1127 |
+
<h3>Ancestors</h3>
|
| 1128 |
+
<ul class="hlist">
|
| 1129 |
+
<li><a title="tinytroupe.utils.json.JsonSerializableRegistry" href="../utils/json.html#tinytroupe.utils.json.JsonSerializableRegistry">JsonSerializableRegistry</a></li>
|
| 1130 |
+
</ul>
|
| 1131 |
+
<h3>Methods</h3>
|
| 1132 |
+
<dl>
|
| 1133 |
+
<dt id="tinytroupe.agent.action_generator.ActionGenerator.generate_next_action"><code class="name flex">
|
| 1134 |
+
<span>def <span class="ident">generate_next_action</span></span>(<span>self, agent, current_messages: list)</span>
|
| 1135 |
+
</code></dt>
|
| 1136 |
+
<dd>
|
| 1137 |
+
<div class="desc"></div>
|
| 1138 |
+
<details class="source">
|
| 1139 |
+
<summary>
|
| 1140 |
+
<span>Expand source code</span>
|
| 1141 |
+
</summary>
|
| 1142 |
+
<pre><code class="python">def generate_next_action(self, agent, current_messages:list):
|
| 1143 |
+
|
| 1144 |
+
from tinytroupe.agent import logger # import here to avoid circular import issues
|
| 1145 |
+
|
| 1146 |
+
# clean up (remove unnecessary elements) and copy the list of current messages to avoid modifying the original ones
|
| 1147 |
+
current_messages = [
|
| 1148 |
+
{"role": msg["role"], "content": json.dumps(msg["content"])}
|
| 1149 |
+
for msg in current_messages
|
| 1150 |
+
]
|
| 1151 |
+
|
| 1152 |
+
# starts with no feedback
|
| 1153 |
+
cur_feedback = None
|
| 1154 |
+
all_negative_feedbacks = []
|
| 1155 |
+
|
| 1156 |
+
best_action = None
|
| 1157 |
+
best_role = None
|
| 1158 |
+
best_content = None
|
| 1159 |
+
best_score = float('-inf')
|
| 1160 |
+
original_score = None
|
| 1161 |
+
|
| 1162 |
+
def update_best(tentative_action, role, content, total_score):
|
| 1163 |
+
nonlocal best_action, best_role, best_content, best_score
|
| 1164 |
+
if total_score > best_score:
|
| 1165 |
+
best_action = tentative_action
|
| 1166 |
+
best_role = role
|
| 1167 |
+
best_content = content
|
| 1168 |
+
best_score = total_score
|
| 1169 |
+
|
| 1170 |
+
def finish_return(tentative_action, role, content, final_score):
|
| 1171 |
+
if original_score is not None and final_score > original_score:
|
| 1172 |
+
logger.warning(f"[{agent.name}] improved total quality from {original_score} to {final_score}")
|
| 1173 |
+
|
| 1174 |
+
# ensure that tentative_action and content are dicts
|
| 1175 |
+
if isinstance(tentative_action, str):
|
| 1176 |
+
tentative_action = json.loads(tentative_action)
|
| 1177 |
+
if isinstance(content, str):
|
| 1178 |
+
content = json.loads(content)
|
| 1179 |
+
|
| 1180 |
+
return tentative_action, role, content, all_negative_feedbacks
|
| 1181 |
+
|
| 1182 |
+
# First attempt to generate an action
|
| 1183 |
+
tentative_action, role, content = self._generate_tentative_action(agent, current_messages,
|
| 1184 |
+
feedback_from_previous_attempt=cur_feedback,
|
| 1185 |
+
previous_tentative_action=None,
|
| 1186 |
+
previous_llm_role=None, previous_llm_content=None)
|
| 1187 |
+
|
| 1188 |
+
if self.enable_quality_checks:
|
| 1189 |
+
# First quality check
|
| 1190 |
+
good_quality, total_score, cur_feedback = self._check_action_quality("Original Action", agent, tentative_action=tentative_action)
|
| 1191 |
+
update_best(tentative_action, role, content, total_score)
|
| 1192 |
+
if original_score is None:
|
| 1193 |
+
original_score = total_score
|
| 1194 |
+
if good_quality:
|
| 1195 |
+
self.total_original_actions_succeeded += 1
|
| 1196 |
+
# Found a good action, let's return it now
|
| 1197 |
+
return finish_return(tentative_action, role, content, total_score)
|
| 1198 |
+
else:
|
| 1199 |
+
logger.warning(f"[{agent.name}] Original action did not pass quality checks: {cur_feedback}")
|
| 1200 |
+
all_negative_feedbacks.append(cur_feedback)
|
| 1201 |
+
|
| 1202 |
+
|
| 1203 |
+
# GENERATE AND REGENERATE the action by the agent
|
| 1204 |
+
#
|
| 1205 |
+
# We first try to make the agent generate (via the current_messages passed) or regenerate the
|
| 1206 |
+
# action based on feedback.
|
| 1207 |
+
if self.enable_regeneration:
|
| 1208 |
+
for attempt in range(self.max_attempts):
|
| 1209 |
+
|
| 1210 |
+
# Generate tentative action
|
| 1211 |
+
tentative_action, role, content = self._generate_tentative_action(agent, current_messages,
|
| 1212 |
+
feedback_from_previous_attempt=cur_feedback,
|
| 1213 |
+
previous_tentative_action=tentative_action,
|
| 1214 |
+
previous_llm_role=role, previous_llm_content=content)
|
| 1215 |
+
logger.debug(f"[{agent.name}] Tentative action: {tentative_action}")
|
| 1216 |
+
self.regeneration_attempts += 1
|
| 1217 |
+
|
| 1218 |
+
good_quality, total_score, cur_feedback = self._check_action_quality(f"Action Regeneration ({attempt})", agent, tentative_action=tentative_action)
|
| 1219 |
+
update_best(tentative_action, role, content, total_score)
|
| 1220 |
+
if good_quality:
|
| 1221 |
+
# Found a good action, let's return it now
|
| 1222 |
+
return finish_return(tentative_action, role, content, total_score)
|
| 1223 |
+
else:
|
| 1224 |
+
self.regeneration_failures += 1
|
| 1225 |
+
self.regeneration_scores.append(total_score) # Assuming feedback contains a score
|
| 1226 |
+
all_negative_feedbacks.append(cur_feedback)
|
| 1227 |
+
|
| 1228 |
+
# CORRECT OR REPHRASE the action directly
|
| 1229 |
+
#
|
| 1230 |
+
# If we got here, it means the agent was not able to directly generate an action
|
| 1231 |
+
# of sufficient quality, so we'll try to rephrase it correctly directly now.
|
| 1232 |
+
if self.enable_direct_correction:
|
| 1233 |
+
for attempt in range(self.max_attempts):
|
| 1234 |
+
tentative_action, role, content = self._correct_action(tentative_action, feedback=cur_feedback, llm_role=role, llm_content=content)
|
| 1235 |
+
logger.warning(f"[{agent.name}] Rephrased the action directly as: {tentative_action}")
|
| 1236 |
+
self.direct_correction_attempts += 1
|
| 1237 |
+
|
| 1238 |
+
good_quality, total_score, cur_feedback = self._check_action_quality(f"Direct Action Correction or Rephrasing ({attempt})", agent, tentative_action=tentative_action)
|
| 1239 |
+
update_best(tentative_action, role, content, total_score)
|
| 1240 |
+
if good_quality:
|
| 1241 |
+
# Found a good action, let's return it now
|
| 1242 |
+
return finish_return(tentative_action, role, content, total_score)
|
| 1243 |
+
else:
|
| 1244 |
+
self.direct_correction_failures += 1
|
| 1245 |
+
self.direct_correction_scores.append(total_score) # Assuming feedback contains a score
|
| 1246 |
+
all_negative_feedbacks.append(cur_feedback)
|
| 1247 |
+
|
| 1248 |
+
# If we got here, all attempts to generate a good action failed
|
| 1249 |
+
if self.continue_on_failure:
|
| 1250 |
+
logger.warning(f"[{agent.name}] All attempts to generate a good action failed. Returning the best one.")
|
| 1251 |
+
return finish_return(best_action, best_role, best_content, best_score)
|
| 1252 |
+
|
| 1253 |
+
else:
|
| 1254 |
+
raise PoorQualityActionException()
|
| 1255 |
+
|
| 1256 |
+
else:
|
| 1257 |
+
# If we got here, it means that the action was generated without quality checks
|
| 1258 |
+
# and we are not doing any regeneration or direct correction, so we can return it now.
|
| 1259 |
+
return tentative_action, role, content, []</code></pre>
|
| 1260 |
+
</details>
|
| 1261 |
+
</dd>
|
| 1262 |
+
<dt id="tinytroupe.agent.action_generator.ActionGenerator.get_statistics"><code class="name flex">
|
| 1263 |
+
<span>def <span class="ident">get_statistics</span></span>(<span>self)</span>
|
| 1264 |
+
</code></dt>
|
| 1265 |
+
<dd>
|
| 1266 |
+
<div class="desc"></div>
|
| 1267 |
+
<details class="source">
|
| 1268 |
+
<summary>
|
| 1269 |
+
<span>Expand source code</span>
|
| 1270 |
+
</summary>
|
| 1271 |
+
<pre><code class="python">def get_statistics(self):
|
| 1272 |
+
regeneration_failure_rate = self.regeneration_failures / self.regeneration_attempts if self.regeneration_attempts else 0
|
| 1273 |
+
direct_correction_failure_rate = self.direct_correction_failures / self.direct_correction_attempts if self.direct_correction_attempts else 0
|
| 1274 |
+
|
| 1275 |
+
regeneration_mean_score = statistics.mean(self.regeneration_scores) if self.regeneration_scores else 0
|
| 1276 |
+
regeneration_sd_score = statistics.stdev(self.regeneration_scores) if len(self.regeneration_scores) > 1 else 0
|
| 1277 |
+
|
| 1278 |
+
direct_correction_mean_score = statistics.mean(self.direct_correction_scores) if self.direct_correction_scores else 0
|
| 1279 |
+
direct_correction_sd_score = statistics.stdev(self.direct_correction_scores) if len(self.direct_correction_scores) > 1 else 0
|
| 1280 |
+
|
| 1281 |
+
original_success_rate = self.total_original_actions_succeeded / self.total_actions_produced if self.total_actions_produced else 0
|
| 1282 |
+
|
| 1283 |
+
return {
|
| 1284 |
+
"regeneration_failure_rate": regeneration_failure_rate,
|
| 1285 |
+
"direct_correction_failure_rate": direct_correction_failure_rate,
|
| 1286 |
+
"regeneration_mean_score": regeneration_mean_score,
|
| 1287 |
+
"regeneration_sd_score": regeneration_sd_score,
|
| 1288 |
+
"direct_correction_mean_score": direct_correction_mean_score,
|
| 1289 |
+
"direct_correction_sd_score": direct_correction_sd_score,
|
| 1290 |
+
"total_actions_produced": self.total_actions_produced,
|
| 1291 |
+
"total_original_actions_succeeded": self.total_original_actions_succeeded,
|
| 1292 |
+
"original_success_rate": original_success_rate,
|
| 1293 |
+
"regeneration_success_rate": 1 - regeneration_failure_rate,
|
| 1294 |
+
"direct_correction_success_rate": 1 - direct_correction_failure_rate
|
| 1295 |
+
}</code></pre>
|
| 1296 |
+
</details>
|
| 1297 |
+
</dd>
|
| 1298 |
+
</dl>
|
| 1299 |
+
<h3>Inherited members</h3>
|
| 1300 |
+
<ul class="hlist">
|
| 1301 |
+
<li><code><b><a title="tinytroupe.utils.json.JsonSerializableRegistry" href="../utils/json.html#tinytroupe.utils.json.JsonSerializableRegistry">JsonSerializableRegistry</a></b></code>:
|
| 1302 |
+
<ul class="hlist">
|
| 1303 |
+
<li><code><a title="tinytroupe.utils.json.JsonSerializableRegistry.from_json" href="../utils/json.html#tinytroupe.utils.json.JsonSerializableRegistry.from_json">from_json</a></code></li>
|
| 1304 |
+
<li><code><a title="tinytroupe.utils.json.JsonSerializableRegistry.to_json" href="../utils/json.html#tinytroupe.utils.json.JsonSerializableRegistry.to_json">to_json</a></code></li>
|
| 1305 |
+
</ul>
|
| 1306 |
+
</li>
|
| 1307 |
+
</ul>
|
| 1308 |
+
</dd>
|
| 1309 |
+
<dt id="tinytroupe.agent.action_generator.PoorQualityActionException"><code class="flex name class">
|
| 1310 |
+
<span>class <span class="ident">PoorQualityActionException</span></span>
|
| 1311 |
+
<span>(</span><span>message='The generated action is of poor quality')</span>
|
| 1312 |
+
</code></dt>
|
| 1313 |
+
<dd>
|
| 1314 |
+
<div class="desc"><p>Common base class for all non-exit exceptions.</p></div>
|
| 1315 |
+
<details class="source">
|
| 1316 |
+
<summary>
|
| 1317 |
+
<span>Expand source code</span>
|
| 1318 |
+
</summary>
|
| 1319 |
+
<pre><code class="python">class PoorQualityActionException(Exception):
|
| 1320 |
+
def __init__(self, message="The generated action is of poor quality"):
|
| 1321 |
+
self.message = message
|
| 1322 |
+
super().__init__(self.message)</code></pre>
|
| 1323 |
+
</details>
|
| 1324 |
+
<h3>Ancestors</h3>
|
| 1325 |
+
<ul class="hlist">
|
| 1326 |
+
<li>builtins.Exception</li>
|
| 1327 |
+
<li>builtins.BaseException</li>
|
| 1328 |
+
</ul>
|
| 1329 |
+
</dd>
|
| 1330 |
+
</dl>
|
| 1331 |
+
</section>
|
| 1332 |
+
</article>
|
| 1333 |
+
<nav id="sidebar">
|
| 1334 |
+
<h1>Index</h1>
|
| 1335 |
+
<div class="toc">
|
| 1336 |
+
<ul></ul>
|
| 1337 |
+
</div>
|
| 1338 |
+
<ul id="index">
|
| 1339 |
+
<li><h3>Super-module</h3>
|
| 1340 |
+
<ul>
|
| 1341 |
+
<li><code><a title="tinytroupe.agent" href="index.html">tinytroupe.agent</a></code></li>
|
| 1342 |
+
</ul>
|
| 1343 |
+
</li>
|
| 1344 |
+
<li><h3><a href="#header-classes">Classes</a></h3>
|
| 1345 |
+
<ul>
|
| 1346 |
+
<li>
|
| 1347 |
+
<h4><code><a title="tinytroupe.agent.action_generator.ActionGenerator" href="#tinytroupe.agent.action_generator.ActionGenerator">ActionGenerator</a></code></h4>
|
| 1348 |
+
<ul class="">
|
| 1349 |
+
<li><code><a title="tinytroupe.agent.action_generator.ActionGenerator.generate_next_action" href="#tinytroupe.agent.action_generator.ActionGenerator.generate_next_action">generate_next_action</a></code></li>
|
| 1350 |
+
<li><code><a title="tinytroupe.agent.action_generator.ActionGenerator.get_statistics" href="#tinytroupe.agent.action_generator.ActionGenerator.get_statistics">get_statistics</a></code></li>
|
| 1351 |
+
</ul>
|
| 1352 |
+
</li>
|
| 1353 |
+
<li>
|
| 1354 |
+
<h4><code><a title="tinytroupe.agent.action_generator.PoorQualityActionException" href="#tinytroupe.agent.action_generator.PoorQualityActionException">PoorQualityActionException</a></code></h4>
|
| 1355 |
+
</li>
|
| 1356 |
+
</ul>
|
| 1357 |
+
</li>
|
| 1358 |
+
</ul>
|
| 1359 |
+
</nav>
|
| 1360 |
+
</main>
|
| 1361 |
+
<footer id="footer">
|
| 1362 |
+
<p>Generated by <a href="https://pdoc3.github.io/pdoc" title="pdoc: Python API documentation generator"><cite>pdoc</cite> 0.10.0</a>.</p>
|
| 1363 |
+
</footer>
|
| 1364 |
+
</body>
|
| 1365 |
+
</html>
|
external/TinyTroupe/docs/api/tinytroupe/agent/grounding.html
ADDED
|
@@ -0,0 +1,1383 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
|
| 6 |
+
<meta name="generator" content="pdoc 0.10.0" />
|
| 7 |
+
<title>tinytroupe.agent.grounding API documentation</title>
|
| 8 |
+
<meta name="description" content="" />
|
| 9 |
+
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
|
| 10 |
+
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css" integrity="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg=" crossorigin>
|
| 11 |
+
<link rel="stylesheet preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css" crossorigin>
|
| 12 |
+
<style>:root{--highlight-color:#fe9}.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}#sidebar > *:last-child{margin-bottom:2cm}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}h1:target,h2:target,h3:target,h4:target,h5:target,h6:target{background:var(--highlight-color);padding:.2em 0}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{margin-top:.6em;font-weight:bold}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}dt:target .name{background:var(--highlight-color)}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}td{padding:0 .5em}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
|
| 13 |
+
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%;height:100vh;overflow:auto;position:sticky;top:0}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
|
| 14 |
+
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
|
| 15 |
+
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js" integrity="sha256-Uv3H6lx7dJmRfRvH8TH6kJD1TSK1aFcwgx+mdg3epi8=" crossorigin></script>
|
| 16 |
+
<script>window.addEventListener('DOMContentLoaded', () => hljs.initHighlighting())</script>
|
| 17 |
+
</head>
|
| 18 |
+
<body>
|
| 19 |
+
<main>
|
| 20 |
+
<article id="content">
|
| 21 |
+
<header>
|
| 22 |
+
<h1 class="title">Module <code>tinytroupe.agent.grounding</code></h1>
|
| 23 |
+
</header>
|
| 24 |
+
<section id="section-intro">
|
| 25 |
+
<details class="source">
|
| 26 |
+
<summary>
|
| 27 |
+
<span>Expand source code</span>
|
| 28 |
+
</summary>
|
| 29 |
+
<pre><code class="python">from tinytroupe.utils import JsonSerializableRegistry
|
| 30 |
+
import tinytroupe.utils as utils
|
| 31 |
+
|
| 32 |
+
from tinytroupe.agent import logger
|
| 33 |
+
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, Document, StorageContext, load_index_from_storage
|
| 34 |
+
from llama_index.core.vector_stores import SimpleVectorStore
|
| 35 |
+
from llama_index.readers.web import SimpleWebPageReader
|
| 36 |
+
import json
|
| 37 |
+
import tempfile
|
| 38 |
+
import os
|
| 39 |
+
import shutil
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
#######################################################################################################################
|
| 43 |
+
# Grounding connectors
|
| 44 |
+
#######################################################################################################################
|
| 45 |
+
|
| 46 |
+
class GroundingConnector(JsonSerializableRegistry):
|
| 47 |
+
"""
|
| 48 |
+
An abstract class representing a grounding connector. A grounding connector is a component that allows an agent to ground
|
| 49 |
+
its knowledge in external sources, such as files, web pages, databases, etc.
|
| 50 |
+
"""
|
| 51 |
+
|
| 52 |
+
serializable_attributes = ["name"]
|
| 53 |
+
|
| 54 |
+
def __init__(self, name:str) -> None:
|
| 55 |
+
self.name = name
|
| 56 |
+
|
| 57 |
+
def retrieve_relevant(self, relevance_target:str, source:str, top_k=20) -> list:
|
| 58 |
+
raise NotImplementedError("Subclasses must implement this method.")
|
| 59 |
+
|
| 60 |
+
def retrieve_by_name(self, name:str) -> str:
|
| 61 |
+
raise NotImplementedError("Subclasses must implement this method.")
|
| 62 |
+
|
| 63 |
+
def list_sources(self) -> list:
|
| 64 |
+
raise NotImplementedError("Subclasses must implement this method.")
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
@utils.post_init
|
| 68 |
+
class BaseSemanticGroundingConnector(GroundingConnector):
|
| 69 |
+
"""
|
| 70 |
+
A base class for semantic grounding connectors. A semantic grounding connector is a component that indexes and retrieves
|
| 71 |
+
documents based on so-called "semantic search" (i.e, embeddings-based search). This specific implementation
|
| 72 |
+
is based on the VectorStoreIndex class from the LLaMa-Index library. Here, "documents" refer to the llama-index's
|
| 73 |
+
data structure that stores a unit of content, not necessarily a file.
|
| 74 |
+
"""
|
| 75 |
+
|
| 76 |
+
serializable_attributes = ["documents", "index"]
|
| 77 |
+
|
| 78 |
+
# needs custom deserialization to handle Pydantic models (Document is a Pydantic model)
|
| 79 |
+
custom_deserializers = {"documents": lambda docs_json: [Document.from_json(doc_json) for doc_json in docs_json],
|
| 80 |
+
"index": lambda index_json: BaseSemanticGroundingConnector._deserialize_index(index_json)}
|
| 81 |
+
|
| 82 |
+
custom_serializers = {"documents": lambda docs: [doc.to_json() for doc in docs] if docs is not None else None,
|
| 83 |
+
"index": lambda index: BaseSemanticGroundingConnector._serialize_index(index)}
|
| 84 |
+
|
| 85 |
+
def __init__(self, name:str="Semantic Grounding") -> None:
|
| 86 |
+
super().__init__(name)
|
| 87 |
+
|
| 88 |
+
self.documents = None
|
| 89 |
+
self.name_to_document = None
|
| 90 |
+
self.index = None
|
| 91 |
+
|
| 92 |
+
# @post_init ensures that _post_init is called after the __init__ method
|
| 93 |
+
|
| 94 |
+
def _post_init(self):
|
| 95 |
+
"""
|
| 96 |
+
This will run after __init__, since the class has the @post_init decorator.
|
| 97 |
+
It is convenient to separate some of the initialization processes to make deserialize easier.
|
| 98 |
+
"""
|
| 99 |
+
self.index = None
|
| 100 |
+
|
| 101 |
+
if not hasattr(self, 'documents') or self.documents is None:
|
| 102 |
+
self.documents = []
|
| 103 |
+
|
| 104 |
+
if not hasattr(self, 'name_to_document') or self.name_to_document is None:
|
| 105 |
+
self.name_to_document = {}
|
| 106 |
+
|
| 107 |
+
if hasattr(self, 'documents') and self.documents is not None:
|
| 108 |
+
for document in self.documents:
|
| 109 |
+
# if the document has a semantic memory ID, we use it as the identifier
|
| 110 |
+
name = document.metadata.get("semantic_memory_id", document.id_)
|
| 111 |
+
|
| 112 |
+
# self.name_to_document[name] contains a list, since each source file could be split into multiple pages
|
| 113 |
+
if name in self.name_to_document:
|
| 114 |
+
self.name_to_document[name].append(document)
|
| 115 |
+
else:
|
| 116 |
+
self.name_to_document[name] = [document]
|
| 117 |
+
|
| 118 |
+
# Rebuild index from documents if it's None or invalid
|
| 119 |
+
if self.index is None and self.documents:
|
| 120 |
+
logger.warning("No index found. Rebuilding index from documents.")
|
| 121 |
+
vector_store = SimpleVectorStore()
|
| 122 |
+
self.index = VectorStoreIndex.from_documents(
|
| 123 |
+
self.documents,
|
| 124 |
+
vector_store=vector_store,
|
| 125 |
+
store_nodes_override=True
|
| 126 |
+
)
|
| 127 |
+
|
| 128 |
+
# TODO remove?
|
| 129 |
+
#self.add_documents(self.documents)
|
| 130 |
+
|
| 131 |
+
@staticmethod
|
| 132 |
+
def _serialize_index(index):
|
| 133 |
+
"""Helper function to serialize index with proper storage context"""
|
| 134 |
+
if index is None:
|
| 135 |
+
return None
|
| 136 |
+
|
| 137 |
+
try:
|
| 138 |
+
# Create a temporary directory to store the index
|
| 139 |
+
with tempfile.TemporaryDirectory() as temp_dir:
|
| 140 |
+
# Persist the index to the temporary directory
|
| 141 |
+
index.storage_context.persist(persist_dir=temp_dir)
|
| 142 |
+
|
| 143 |
+
# Read all the persisted files and store them in a dictionary
|
| 144 |
+
persisted_data = {}
|
| 145 |
+
for filename in os.listdir(temp_dir):
|
| 146 |
+
filepath = os.path.join(temp_dir, filename)
|
| 147 |
+
if os.path.isfile(filepath):
|
| 148 |
+
with open(filepath, 'r') as f:
|
| 149 |
+
persisted_data[filename] = f.read()
|
| 150 |
+
|
| 151 |
+
return persisted_data
|
| 152 |
+
except Exception as e:
|
| 153 |
+
logger.warning(f"Failed to serialize index: {e}")
|
| 154 |
+
return None
|
| 155 |
+
|
| 156 |
+
@staticmethod
|
| 157 |
+
def _deserialize_index(index_data):
|
| 158 |
+
"""Helper function to deserialize index with proper error handling"""
|
| 159 |
+
if not index_data:
|
| 160 |
+
return None
|
| 161 |
+
|
| 162 |
+
try:
|
| 163 |
+
# Create a temporary directory to restore the index
|
| 164 |
+
with tempfile.TemporaryDirectory() as temp_dir:
|
| 165 |
+
# Write all the persisted files to the temporary directory
|
| 166 |
+
for filename, content in index_data.items():
|
| 167 |
+
filepath = os.path.join(temp_dir, filename)
|
| 168 |
+
with open(filepath, 'w') as f:
|
| 169 |
+
f.write(content)
|
| 170 |
+
|
| 171 |
+
# Load the index from the temporary directory
|
| 172 |
+
storage_context = StorageContext.from_defaults(persist_dir=temp_dir)
|
| 173 |
+
index = load_index_from_storage(storage_context)
|
| 174 |
+
|
| 175 |
+
return index
|
| 176 |
+
except Exception as e:
|
| 177 |
+
# If deserialization fails, return None
|
| 178 |
+
# The index will be rebuilt from documents in _post_init
|
| 179 |
+
logger.warning(f"Failed to deserialize index: {e}. Index will be rebuilt.")
|
| 180 |
+
return None
|
| 181 |
+
|
| 182 |
+
def retrieve_relevant(self, relevance_target:str, top_k=20) -> list:
|
| 183 |
+
"""
|
| 184 |
+
Retrieves all values from memory that are relevant to a given target.
|
| 185 |
+
"""
|
| 186 |
+
# Handle empty or None query
|
| 187 |
+
if not relevance_target or not relevance_target.strip():
|
| 188 |
+
return []
|
| 189 |
+
|
| 190 |
+
if self.index is not None:
|
| 191 |
+
retriever = self.index.as_retriever(similarity_top_k=top_k)
|
| 192 |
+
nodes = retriever.retrieve(relevance_target)
|
| 193 |
+
else:
|
| 194 |
+
nodes = []
|
| 195 |
+
|
| 196 |
+
retrieved = []
|
| 197 |
+
for node in nodes:
|
| 198 |
+
content = "SOURCE: " + node.metadata.get('file_name', '(unknown)')
|
| 199 |
+
content += "\n" + "SIMILARITY SCORE:" + str(node.score)
|
| 200 |
+
content += "\n" + "RELEVANT CONTENT:" + node.text
|
| 201 |
+
retrieved.append(content)
|
| 202 |
+
|
| 203 |
+
logger.debug(f"Content retrieved: {content[:200]}")
|
| 204 |
+
|
| 205 |
+
return retrieved
|
| 206 |
+
|
| 207 |
+
def retrieve_by_name(self, name:str) -> list:
|
| 208 |
+
"""
|
| 209 |
+
Retrieves a content source by its name.
|
| 210 |
+
"""
|
| 211 |
+
# TODO also optionally provide a relevance target?
|
| 212 |
+
results = []
|
| 213 |
+
if self.name_to_document is not None and name in self.name_to_document:
|
| 214 |
+
docs = self.name_to_document[name]
|
| 215 |
+
for i, doc in enumerate(docs):
|
| 216 |
+
if doc is not None:
|
| 217 |
+
content = f"SOURCE: {name}\n"
|
| 218 |
+
content += f"PAGE: {i}\n"
|
| 219 |
+
content += "CONTENT: \n" + doc.text[:10000] # TODO a more intelligent way to limit the content
|
| 220 |
+
results.append(content)
|
| 221 |
+
|
| 222 |
+
return results
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
def list_sources(self) -> list:
|
| 226 |
+
"""
|
| 227 |
+
Lists the names of the available content sources.
|
| 228 |
+
"""
|
| 229 |
+
if self.name_to_document is not None:
|
| 230 |
+
return list(self.name_to_document.keys())
|
| 231 |
+
else:
|
| 232 |
+
return []
|
| 233 |
+
|
| 234 |
+
def add_document(self, document) -> None:
|
| 235 |
+
"""
|
| 236 |
+
Indexes a document for semantic retrieval.
|
| 237 |
+
|
| 238 |
+
Assumes the document has a metadata field called "semantic_memory_id" that is used to identify the document within Semantic Memory.
|
| 239 |
+
"""
|
| 240 |
+
self.add_documents([document])
|
| 241 |
+
|
| 242 |
+
def add_documents(self, new_documents) -> list:
|
| 243 |
+
"""
|
| 244 |
+
Indexes documents for semantic retrieval.
|
| 245 |
+
"""
|
| 246 |
+
# index documents by name
|
| 247 |
+
if len(new_documents) > 0:
|
| 248 |
+
|
| 249 |
+
# process documents individually too
|
| 250 |
+
for document in new_documents:
|
| 251 |
+
logger.debug(f"Adding document {document} to index, text is: {document.text}")
|
| 252 |
+
|
| 253 |
+
# out of an abundance of caution, we sanitize the text
|
| 254 |
+
document.text = utils.sanitize_raw_string(document.text)
|
| 255 |
+
|
| 256 |
+
logger.debug(f"Document text after sanitization: {document.text}")
|
| 257 |
+
|
| 258 |
+
# add the new document to the list of documents after all sanitization and checks
|
| 259 |
+
self.documents.append(document)
|
| 260 |
+
|
| 261 |
+
if document.metadata.get("semantic_memory_id") is not None:
|
| 262 |
+
# if the document has a semantic memory ID, we use it as the identifier
|
| 263 |
+
name = document.metadata["semantic_memory_id"]
|
| 264 |
+
|
| 265 |
+
# Ensure name_to_document is initialized
|
| 266 |
+
if not hasattr(self, 'name_to_document') or self.name_to_document is None:
|
| 267 |
+
self.name_to_document = {}
|
| 268 |
+
|
| 269 |
+
# self.name_to_document[name] contains a list, since each source file could be split into multiple pages
|
| 270 |
+
if name in self.name_to_document:
|
| 271 |
+
self.name_to_document[name].append(document)
|
| 272 |
+
else:
|
| 273 |
+
self.name_to_document[name] = [document]
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
# index documents for semantic retrieval
|
| 277 |
+
if self.index is None:
|
| 278 |
+
# Create storage context with vector store
|
| 279 |
+
vector_store = SimpleVectorStore()
|
| 280 |
+
storage_context = StorageContext.from_defaults(vector_store=vector_store)
|
| 281 |
+
|
| 282 |
+
self.index = VectorStoreIndex.from_documents(
|
| 283 |
+
self.documents,
|
| 284 |
+
storage_context=storage_context,
|
| 285 |
+
store_nodes_override=True # This ensures nodes (with text) are stored
|
| 286 |
+
)
|
| 287 |
+
else:
|
| 288 |
+
self.index.refresh(self.documents)
|
| 289 |
+
|
| 290 |
+
@staticmethod
|
| 291 |
+
def _set_internal_id_to_documents(documents:list, external_attribute_name:str ="file_name") -> None:
|
| 292 |
+
"""
|
| 293 |
+
Sets the internal ID for each document in the list of documents.
|
| 294 |
+
This is useful to ensure that each document has a unique identifier.
|
| 295 |
+
"""
|
| 296 |
+
for doc in documents:
|
| 297 |
+
if not hasattr(doc, 'metadata'):
|
| 298 |
+
doc.metadata = {}
|
| 299 |
+
doc.metadata["semantic_memory_id"] = doc.metadata.get(external_attribute_name, doc.id_)
|
| 300 |
+
|
| 301 |
+
return documents
|
| 302 |
+
|
| 303 |
+
|
| 304 |
+
@utils.post_init
|
| 305 |
+
class LocalFilesGroundingConnector(BaseSemanticGroundingConnector):
|
| 306 |
+
|
| 307 |
+
serializable_attributes = ["folders_paths"]
|
| 308 |
+
|
| 309 |
+
def __init__(self, name:str="Local Files", folders_paths: list=None) -> None:
|
| 310 |
+
super().__init__(name)
|
| 311 |
+
|
| 312 |
+
self.folders_paths = folders_paths
|
| 313 |
+
|
| 314 |
+
# @post_init ensures that _post_init is called after the __init__ method
|
| 315 |
+
|
| 316 |
+
def _post_init(self):
|
| 317 |
+
"""
|
| 318 |
+
This will run after __init__, since the class has the @post_init decorator.
|
| 319 |
+
It is convenient to separate some of the initialization processes to make deserialize easier.
|
| 320 |
+
"""
|
| 321 |
+
self.loaded_folders_paths = []
|
| 322 |
+
|
| 323 |
+
if not hasattr(self, 'folders_paths') or self.folders_paths is None:
|
| 324 |
+
self.folders_paths = []
|
| 325 |
+
|
| 326 |
+
self.add_folders(self.folders_paths)
|
| 327 |
+
|
| 328 |
+
def add_folders(self, folders_paths:list) -> None:
|
| 329 |
+
"""
|
| 330 |
+
Adds a path to a folder with files used for grounding.
|
| 331 |
+
"""
|
| 332 |
+
|
| 333 |
+
if folders_paths is not None:
|
| 334 |
+
for folder_path in folders_paths:
|
| 335 |
+
try:
|
| 336 |
+
logger.debug(f"Adding the following folder to grounding index: {folder_path}")
|
| 337 |
+
self.add_folder(folder_path)
|
| 338 |
+
except (FileNotFoundError, ValueError) as e:
|
| 339 |
+
print(f"Error: {e}")
|
| 340 |
+
print(f"Current working directory: {os.getcwd()}")
|
| 341 |
+
print(f"Provided path: {folder_path}")
|
| 342 |
+
print("Please check if the path exists and is accessible.")
|
| 343 |
+
|
| 344 |
+
def add_folder(self, folder_path:str) -> None:
|
| 345 |
+
"""
|
| 346 |
+
Adds a path to a folder with files used for grounding.
|
| 347 |
+
"""
|
| 348 |
+
|
| 349 |
+
if folder_path not in self.loaded_folders_paths:
|
| 350 |
+
self._mark_folder_as_loaded(folder_path)
|
| 351 |
+
|
| 352 |
+
# for PDF files, please note that the document will be split into pages: https://github.com/run-llama/llama_index/issues/15903
|
| 353 |
+
new_files = SimpleDirectoryReader(folder_path).load_data()
|
| 354 |
+
BaseSemanticGroundingConnector._set_internal_id_to_documents(new_files, "file_name")
|
| 355 |
+
|
| 356 |
+
self.add_documents(new_files)
|
| 357 |
+
|
| 358 |
+
def add_file_path(self, file_path:str) -> None:
|
| 359 |
+
"""
|
| 360 |
+
Adds a path to a file used for grounding.
|
| 361 |
+
"""
|
| 362 |
+
# a trick to make SimpleDirectoryReader work with a single file
|
| 363 |
+
new_files = SimpleDirectoryReader(input_files=[file_path]).load_data()
|
| 364 |
+
|
| 365 |
+
logger.debug(f"Adding the following file to grounding index: {new_files}")
|
| 366 |
+
BaseSemanticGroundingConnector._set_internal_id_to_documents(new_files, "file_name")
|
| 367 |
+
|
| 368 |
+
def _mark_folder_as_loaded(self, folder_path:str) -> None:
|
| 369 |
+
if folder_path not in self.loaded_folders_paths:
|
| 370 |
+
self.loaded_folders_paths.append(folder_path)
|
| 371 |
+
|
| 372 |
+
if folder_path not in self.folders_paths:
|
| 373 |
+
self.folders_paths.append(folder_path)
|
| 374 |
+
|
| 375 |
+
|
| 376 |
+
|
| 377 |
+
|
| 378 |
+
@utils.post_init
|
| 379 |
+
class WebPagesGroundingConnector(BaseSemanticGroundingConnector):
|
| 380 |
+
|
| 381 |
+
serializable_attributes = ["web_urls"]
|
| 382 |
+
|
| 383 |
+
def __init__(self, name:str="Web Pages", web_urls: list=None) -> None:
|
| 384 |
+
super().__init__(name)
|
| 385 |
+
|
| 386 |
+
self.web_urls = web_urls
|
| 387 |
+
|
| 388 |
+
# @post_init ensures that _post_init is called after the __init__ method
|
| 389 |
+
|
| 390 |
+
def _post_init(self):
|
| 391 |
+
self.loaded_web_urls = []
|
| 392 |
+
|
| 393 |
+
if not hasattr(self, 'web_urls') or self.web_urls is None:
|
| 394 |
+
self.web_urls = []
|
| 395 |
+
|
| 396 |
+
# load web urls
|
| 397 |
+
self.add_web_urls(self.web_urls)
|
| 398 |
+
|
| 399 |
+
def add_web_urls(self, web_urls:list) -> None:
|
| 400 |
+
"""
|
| 401 |
+
Adds the data retrieved from the specified URLs to grounding.
|
| 402 |
+
"""
|
| 403 |
+
filtered_web_urls = [url for url in web_urls if url not in self.loaded_web_urls]
|
| 404 |
+
for url in filtered_web_urls:
|
| 405 |
+
self._mark_web_url_as_loaded(url)
|
| 406 |
+
|
| 407 |
+
if len(filtered_web_urls) > 0:
|
| 408 |
+
new_documents = SimpleWebPageReader(html_to_text=True).load_data(filtered_web_urls)
|
| 409 |
+
BaseSemanticGroundingConnector._set_internal_id_to_documents(new_documents, "url")
|
| 410 |
+
self.add_documents(new_documents)
|
| 411 |
+
|
| 412 |
+
def add_web_url(self, web_url:str) -> None:
|
| 413 |
+
"""
|
| 414 |
+
Adds the data retrieved from the specified URL to grounding.
|
| 415 |
+
"""
|
| 416 |
+
# we do it like this because the add_web_urls could run scrapes in parallel, so it is better
|
| 417 |
+
# to implement this one in terms of the other
|
| 418 |
+
self.add_web_urls([web_url])
|
| 419 |
+
|
| 420 |
+
def _mark_web_url_as_loaded(self, web_url:str) -> None:
|
| 421 |
+
if web_url not in self.loaded_web_urls:
|
| 422 |
+
self.loaded_web_urls.append(web_url)
|
| 423 |
+
|
| 424 |
+
if web_url not in self.web_urls:
|
| 425 |
+
self.web_urls.append(web_url)</code></pre>
|
| 426 |
+
</details>
|
| 427 |
+
</section>
|
| 428 |
+
<section>
|
| 429 |
+
</section>
|
| 430 |
+
<section>
|
| 431 |
+
</section>
|
| 432 |
+
<section>
|
| 433 |
+
</section>
|
| 434 |
+
<section>
|
| 435 |
+
<h2 class="section-title" id="header-classes">Classes</h2>
|
| 436 |
+
<dl>
|
| 437 |
+
<dt id="tinytroupe.agent.grounding.BaseSemanticGroundingConnector"><code class="flex name class">
|
| 438 |
+
<span>class <span class="ident">BaseSemanticGroundingConnector</span></span>
|
| 439 |
+
<span>(</span><span>*args, **kwargs)</span>
|
| 440 |
+
</code></dt>
|
| 441 |
+
<dd>
|
| 442 |
+
<div class="desc"><p>A base class for semantic grounding connectors. A semantic grounding connector is a component that indexes and retrieves
|
| 443 |
+
documents based on so-called "semantic search" (i.e, embeddings-based search). This specific implementation
|
| 444 |
+
is based on the VectorStoreIndex class from the LLaMa-Index library. Here, "documents" refer to the llama-index's
|
| 445 |
+
data structure that stores a unit of content, not necessarily a file.</p></div>
|
| 446 |
+
<details class="source">
|
| 447 |
+
<summary>
|
| 448 |
+
<span>Expand source code</span>
|
| 449 |
+
</summary>
|
| 450 |
+
<pre><code class="python">@utils.post_init
|
| 451 |
+
class BaseSemanticGroundingConnector(GroundingConnector):
|
| 452 |
+
"""
|
| 453 |
+
A base class for semantic grounding connectors. A semantic grounding connector is a component that indexes and retrieves
|
| 454 |
+
documents based on so-called "semantic search" (i.e, embeddings-based search). This specific implementation
|
| 455 |
+
is based on the VectorStoreIndex class from the LLaMa-Index library. Here, "documents" refer to the llama-index's
|
| 456 |
+
data structure that stores a unit of content, not necessarily a file.
|
| 457 |
+
"""
|
| 458 |
+
|
| 459 |
+
serializable_attributes = ["documents", "index"]
|
| 460 |
+
|
| 461 |
+
# needs custom deserialization to handle Pydantic models (Document is a Pydantic model)
|
| 462 |
+
custom_deserializers = {"documents": lambda docs_json: [Document.from_json(doc_json) for doc_json in docs_json],
|
| 463 |
+
"index": lambda index_json: BaseSemanticGroundingConnector._deserialize_index(index_json)}
|
| 464 |
+
|
| 465 |
+
custom_serializers = {"documents": lambda docs: [doc.to_json() for doc in docs] if docs is not None else None,
|
| 466 |
+
"index": lambda index: BaseSemanticGroundingConnector._serialize_index(index)}
|
| 467 |
+
|
| 468 |
+
def __init__(self, name:str="Semantic Grounding") -> None:
|
| 469 |
+
super().__init__(name)
|
| 470 |
+
|
| 471 |
+
self.documents = None
|
| 472 |
+
self.name_to_document = None
|
| 473 |
+
self.index = None
|
| 474 |
+
|
| 475 |
+
# @post_init ensures that _post_init is called after the __init__ method
|
| 476 |
+
|
| 477 |
+
def _post_init(self):
|
| 478 |
+
"""
|
| 479 |
+
This will run after __init__, since the class has the @post_init decorator.
|
| 480 |
+
It is convenient to separate some of the initialization processes to make deserialize easier.
|
| 481 |
+
"""
|
| 482 |
+
self.index = None
|
| 483 |
+
|
| 484 |
+
if not hasattr(self, 'documents') or self.documents is None:
|
| 485 |
+
self.documents = []
|
| 486 |
+
|
| 487 |
+
if not hasattr(self, 'name_to_document') or self.name_to_document is None:
|
| 488 |
+
self.name_to_document = {}
|
| 489 |
+
|
| 490 |
+
if hasattr(self, 'documents') and self.documents is not None:
|
| 491 |
+
for document in self.documents:
|
| 492 |
+
# if the document has a semantic memory ID, we use it as the identifier
|
| 493 |
+
name = document.metadata.get("semantic_memory_id", document.id_)
|
| 494 |
+
|
| 495 |
+
# self.name_to_document[name] contains a list, since each source file could be split into multiple pages
|
| 496 |
+
if name in self.name_to_document:
|
| 497 |
+
self.name_to_document[name].append(document)
|
| 498 |
+
else:
|
| 499 |
+
self.name_to_document[name] = [document]
|
| 500 |
+
|
| 501 |
+
# Rebuild index from documents if it's None or invalid
|
| 502 |
+
if self.index is None and self.documents:
|
| 503 |
+
logger.warning("No index found. Rebuilding index from documents.")
|
| 504 |
+
vector_store = SimpleVectorStore()
|
| 505 |
+
self.index = VectorStoreIndex.from_documents(
|
| 506 |
+
self.documents,
|
| 507 |
+
vector_store=vector_store,
|
| 508 |
+
store_nodes_override=True
|
| 509 |
+
)
|
| 510 |
+
|
| 511 |
+
# TODO remove?
|
| 512 |
+
#self.add_documents(self.documents)
|
| 513 |
+
|
| 514 |
+
@staticmethod
|
| 515 |
+
def _serialize_index(index):
|
| 516 |
+
"""Helper function to serialize index with proper storage context"""
|
| 517 |
+
if index is None:
|
| 518 |
+
return None
|
| 519 |
+
|
| 520 |
+
try:
|
| 521 |
+
# Create a temporary directory to store the index
|
| 522 |
+
with tempfile.TemporaryDirectory() as temp_dir:
|
| 523 |
+
# Persist the index to the temporary directory
|
| 524 |
+
index.storage_context.persist(persist_dir=temp_dir)
|
| 525 |
+
|
| 526 |
+
# Read all the persisted files and store them in a dictionary
|
| 527 |
+
persisted_data = {}
|
| 528 |
+
for filename in os.listdir(temp_dir):
|
| 529 |
+
filepath = os.path.join(temp_dir, filename)
|
| 530 |
+
if os.path.isfile(filepath):
|
| 531 |
+
with open(filepath, 'r') as f:
|
| 532 |
+
persisted_data[filename] = f.read()
|
| 533 |
+
|
| 534 |
+
return persisted_data
|
| 535 |
+
except Exception as e:
|
| 536 |
+
logger.warning(f"Failed to serialize index: {e}")
|
| 537 |
+
return None
|
| 538 |
+
|
| 539 |
+
@staticmethod
|
| 540 |
+
def _deserialize_index(index_data):
|
| 541 |
+
"""Helper function to deserialize index with proper error handling"""
|
| 542 |
+
if not index_data:
|
| 543 |
+
return None
|
| 544 |
+
|
| 545 |
+
try:
|
| 546 |
+
# Create a temporary directory to restore the index
|
| 547 |
+
with tempfile.TemporaryDirectory() as temp_dir:
|
| 548 |
+
# Write all the persisted files to the temporary directory
|
| 549 |
+
for filename, content in index_data.items():
|
| 550 |
+
filepath = os.path.join(temp_dir, filename)
|
| 551 |
+
with open(filepath, 'w') as f:
|
| 552 |
+
f.write(content)
|
| 553 |
+
|
| 554 |
+
# Load the index from the temporary directory
|
| 555 |
+
storage_context = StorageContext.from_defaults(persist_dir=temp_dir)
|
| 556 |
+
index = load_index_from_storage(storage_context)
|
| 557 |
+
|
| 558 |
+
return index
|
| 559 |
+
except Exception as e:
|
| 560 |
+
# If deserialization fails, return None
|
| 561 |
+
# The index will be rebuilt from documents in _post_init
|
| 562 |
+
logger.warning(f"Failed to deserialize index: {e}. Index will be rebuilt.")
|
| 563 |
+
return None
|
| 564 |
+
|
| 565 |
+
def retrieve_relevant(self, relevance_target:str, top_k=20) -> list:
|
| 566 |
+
"""
|
| 567 |
+
Retrieves all values from memory that are relevant to a given target.
|
| 568 |
+
"""
|
| 569 |
+
# Handle empty or None query
|
| 570 |
+
if not relevance_target or not relevance_target.strip():
|
| 571 |
+
return []
|
| 572 |
+
|
| 573 |
+
if self.index is not None:
|
| 574 |
+
retriever = self.index.as_retriever(similarity_top_k=top_k)
|
| 575 |
+
nodes = retriever.retrieve(relevance_target)
|
| 576 |
+
else:
|
| 577 |
+
nodes = []
|
| 578 |
+
|
| 579 |
+
retrieved = []
|
| 580 |
+
for node in nodes:
|
| 581 |
+
content = "SOURCE: " + node.metadata.get('file_name', '(unknown)')
|
| 582 |
+
content += "\n" + "SIMILARITY SCORE:" + str(node.score)
|
| 583 |
+
content += "\n" + "RELEVANT CONTENT:" + node.text
|
| 584 |
+
retrieved.append(content)
|
| 585 |
+
|
| 586 |
+
logger.debug(f"Content retrieved: {content[:200]}")
|
| 587 |
+
|
| 588 |
+
return retrieved
|
| 589 |
+
|
| 590 |
+
def retrieve_by_name(self, name:str) -> list:
|
| 591 |
+
"""
|
| 592 |
+
Retrieves a content source by its name.
|
| 593 |
+
"""
|
| 594 |
+
# TODO also optionally provide a relevance target?
|
| 595 |
+
results = []
|
| 596 |
+
if self.name_to_document is not None and name in self.name_to_document:
|
| 597 |
+
docs = self.name_to_document[name]
|
| 598 |
+
for i, doc in enumerate(docs):
|
| 599 |
+
if doc is not None:
|
| 600 |
+
content = f"SOURCE: {name}\n"
|
| 601 |
+
content += f"PAGE: {i}\n"
|
| 602 |
+
content += "CONTENT: \n" + doc.text[:10000] # TODO a more intelligent way to limit the content
|
| 603 |
+
results.append(content)
|
| 604 |
+
|
| 605 |
+
return results
|
| 606 |
+
|
| 607 |
+
|
| 608 |
+
def list_sources(self) -> list:
|
| 609 |
+
"""
|
| 610 |
+
Lists the names of the available content sources.
|
| 611 |
+
"""
|
| 612 |
+
if self.name_to_document is not None:
|
| 613 |
+
return list(self.name_to_document.keys())
|
| 614 |
+
else:
|
| 615 |
+
return []
|
| 616 |
+
|
| 617 |
+
def add_document(self, document) -> None:
|
| 618 |
+
"""
|
| 619 |
+
Indexes a document for semantic retrieval.
|
| 620 |
+
|
| 621 |
+
Assumes the document has a metadata field called "semantic_memory_id" that is used to identify the document within Semantic Memory.
|
| 622 |
+
"""
|
| 623 |
+
self.add_documents([document])
|
| 624 |
+
|
| 625 |
+
def add_documents(self, new_documents) -> list:
|
| 626 |
+
"""
|
| 627 |
+
Indexes documents for semantic retrieval.
|
| 628 |
+
"""
|
| 629 |
+
# index documents by name
|
| 630 |
+
if len(new_documents) > 0:
|
| 631 |
+
|
| 632 |
+
# process documents individually too
|
| 633 |
+
for document in new_documents:
|
| 634 |
+
logger.debug(f"Adding document {document} to index, text is: {document.text}")
|
| 635 |
+
|
| 636 |
+
# out of an abundance of caution, we sanitize the text
|
| 637 |
+
document.text = utils.sanitize_raw_string(document.text)
|
| 638 |
+
|
| 639 |
+
logger.debug(f"Document text after sanitization: {document.text}")
|
| 640 |
+
|
| 641 |
+
# add the new document to the list of documents after all sanitization and checks
|
| 642 |
+
self.documents.append(document)
|
| 643 |
+
|
| 644 |
+
if document.metadata.get("semantic_memory_id") is not None:
|
| 645 |
+
# if the document has a semantic memory ID, we use it as the identifier
|
| 646 |
+
name = document.metadata["semantic_memory_id"]
|
| 647 |
+
|
| 648 |
+
# Ensure name_to_document is initialized
|
| 649 |
+
if not hasattr(self, 'name_to_document') or self.name_to_document is None:
|
| 650 |
+
self.name_to_document = {}
|
| 651 |
+
|
| 652 |
+
# self.name_to_document[name] contains a list, since each source file could be split into multiple pages
|
| 653 |
+
if name in self.name_to_document:
|
| 654 |
+
self.name_to_document[name].append(document)
|
| 655 |
+
else:
|
| 656 |
+
self.name_to_document[name] = [document]
|
| 657 |
+
|
| 658 |
+
|
| 659 |
+
# index documents for semantic retrieval
|
| 660 |
+
if self.index is None:
|
| 661 |
+
# Create storage context with vector store
|
| 662 |
+
vector_store = SimpleVectorStore()
|
| 663 |
+
storage_context = StorageContext.from_defaults(vector_store=vector_store)
|
| 664 |
+
|
| 665 |
+
self.index = VectorStoreIndex.from_documents(
|
| 666 |
+
self.documents,
|
| 667 |
+
storage_context=storage_context,
|
| 668 |
+
store_nodes_override=True # This ensures nodes (with text) are stored
|
| 669 |
+
)
|
| 670 |
+
else:
|
| 671 |
+
self.index.refresh(self.documents)
|
| 672 |
+
|
| 673 |
+
@staticmethod
|
| 674 |
+
def _set_internal_id_to_documents(documents:list, external_attribute_name:str ="file_name") -> None:
|
| 675 |
+
"""
|
| 676 |
+
Sets the internal ID for each document in the list of documents.
|
| 677 |
+
This is useful to ensure that each document has a unique identifier.
|
| 678 |
+
"""
|
| 679 |
+
for doc in documents:
|
| 680 |
+
if not hasattr(doc, 'metadata'):
|
| 681 |
+
doc.metadata = {}
|
| 682 |
+
doc.metadata["semantic_memory_id"] = doc.metadata.get(external_attribute_name, doc.id_)
|
| 683 |
+
|
| 684 |
+
return documents</code></pre>
|
| 685 |
+
</details>
|
| 686 |
+
<h3>Ancestors</h3>
|
| 687 |
+
<ul class="hlist">
|
| 688 |
+
<li><a title="tinytroupe.agent.grounding.GroundingConnector" href="#tinytroupe.agent.grounding.GroundingConnector">GroundingConnector</a></li>
|
| 689 |
+
<li><a title="tinytroupe.utils.json.JsonSerializableRegistry" href="../utils/json.html#tinytroupe.utils.json.JsonSerializableRegistry">JsonSerializableRegistry</a></li>
|
| 690 |
+
</ul>
|
| 691 |
+
<h3>Subclasses</h3>
|
| 692 |
+
<ul class="hlist">
|
| 693 |
+
<li><a title="tinytroupe.agent.grounding.LocalFilesGroundingConnector" href="#tinytroupe.agent.grounding.LocalFilesGroundingConnector">LocalFilesGroundingConnector</a></li>
|
| 694 |
+
<li><a title="tinytroupe.agent.grounding.WebPagesGroundingConnector" href="#tinytroupe.agent.grounding.WebPagesGroundingConnector">WebPagesGroundingConnector</a></li>
|
| 695 |
+
</ul>
|
| 696 |
+
<h3>Class variables</h3>
|
| 697 |
+
<dl>
|
| 698 |
+
<dt id="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.custom_deserializers"><code class="name">var <span class="ident">custom_deserializers</span></code></dt>
|
| 699 |
+
<dd>
|
| 700 |
+
<div class="desc"></div>
|
| 701 |
+
</dd>
|
| 702 |
+
<dt id="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.custom_serializers"><code class="name">var <span class="ident">custom_serializers</span></code></dt>
|
| 703 |
+
<dd>
|
| 704 |
+
<div class="desc"></div>
|
| 705 |
+
</dd>
|
| 706 |
+
<dt id="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.serializable_attributes"><code class="name">var <span class="ident">serializable_attributes</span></code></dt>
|
| 707 |
+
<dd>
|
| 708 |
+
<div class="desc"></div>
|
| 709 |
+
</dd>
|
| 710 |
+
</dl>
|
| 711 |
+
<h3>Methods</h3>
|
| 712 |
+
<dl>
|
| 713 |
+
<dt id="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.add_document"><code class="name flex">
|
| 714 |
+
<span>def <span class="ident">add_document</span></span>(<span>self, document) ‑> None</span>
|
| 715 |
+
</code></dt>
|
| 716 |
+
<dd>
|
| 717 |
+
<div class="desc"><p>Indexes a document for semantic retrieval.</p>
|
| 718 |
+
<p>Assumes the document has a metadata field called "semantic_memory_id" that is used to identify the document within Semantic Memory.</p></div>
|
| 719 |
+
<details class="source">
|
| 720 |
+
<summary>
|
| 721 |
+
<span>Expand source code</span>
|
| 722 |
+
</summary>
|
| 723 |
+
<pre><code class="python">def add_document(self, document) -> None:
|
| 724 |
+
"""
|
| 725 |
+
Indexes a document for semantic retrieval.
|
| 726 |
+
|
| 727 |
+
Assumes the document has a metadata field called "semantic_memory_id" that is used to identify the document within Semantic Memory.
|
| 728 |
+
"""
|
| 729 |
+
self.add_documents([document])</code></pre>
|
| 730 |
+
</details>
|
| 731 |
+
</dd>
|
| 732 |
+
<dt id="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.add_documents"><code class="name flex">
|
| 733 |
+
<span>def <span class="ident">add_documents</span></span>(<span>self, new_documents) ‑> list</span>
|
| 734 |
+
</code></dt>
|
| 735 |
+
<dd>
|
| 736 |
+
<div class="desc"><p>Indexes documents for semantic retrieval.</p></div>
|
| 737 |
+
<details class="source">
|
| 738 |
+
<summary>
|
| 739 |
+
<span>Expand source code</span>
|
| 740 |
+
</summary>
|
| 741 |
+
<pre><code class="python">def add_documents(self, new_documents) -> list:
|
| 742 |
+
"""
|
| 743 |
+
Indexes documents for semantic retrieval.
|
| 744 |
+
"""
|
| 745 |
+
# index documents by name
|
| 746 |
+
if len(new_documents) > 0:
|
| 747 |
+
|
| 748 |
+
# process documents individually too
|
| 749 |
+
for document in new_documents:
|
| 750 |
+
logger.debug(f"Adding document {document} to index, text is: {document.text}")
|
| 751 |
+
|
| 752 |
+
# out of an abundance of caution, we sanitize the text
|
| 753 |
+
document.text = utils.sanitize_raw_string(document.text)
|
| 754 |
+
|
| 755 |
+
logger.debug(f"Document text after sanitization: {document.text}")
|
| 756 |
+
|
| 757 |
+
# add the new document to the list of documents after all sanitization and checks
|
| 758 |
+
self.documents.append(document)
|
| 759 |
+
|
| 760 |
+
if document.metadata.get("semantic_memory_id") is not None:
|
| 761 |
+
# if the document has a semantic memory ID, we use it as the identifier
|
| 762 |
+
name = document.metadata["semantic_memory_id"]
|
| 763 |
+
|
| 764 |
+
# Ensure name_to_document is initialized
|
| 765 |
+
if not hasattr(self, 'name_to_document') or self.name_to_document is None:
|
| 766 |
+
self.name_to_document = {}
|
| 767 |
+
|
| 768 |
+
# self.name_to_document[name] contains a list, since each source file could be split into multiple pages
|
| 769 |
+
if name in self.name_to_document:
|
| 770 |
+
self.name_to_document[name].append(document)
|
| 771 |
+
else:
|
| 772 |
+
self.name_to_document[name] = [document]
|
| 773 |
+
|
| 774 |
+
|
| 775 |
+
# index documents for semantic retrieval
|
| 776 |
+
if self.index is None:
|
| 777 |
+
# Create storage context with vector store
|
| 778 |
+
vector_store = SimpleVectorStore()
|
| 779 |
+
storage_context = StorageContext.from_defaults(vector_store=vector_store)
|
| 780 |
+
|
| 781 |
+
self.index = VectorStoreIndex.from_documents(
|
| 782 |
+
self.documents,
|
| 783 |
+
storage_context=storage_context,
|
| 784 |
+
store_nodes_override=True # This ensures nodes (with text) are stored
|
| 785 |
+
)
|
| 786 |
+
else:
|
| 787 |
+
self.index.refresh(self.documents)</code></pre>
|
| 788 |
+
</details>
|
| 789 |
+
</dd>
|
| 790 |
+
<dt id="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.list_sources"><code class="name flex">
|
| 791 |
+
<span>def <span class="ident">list_sources</span></span>(<span>self) ‑> list</span>
|
| 792 |
+
</code></dt>
|
| 793 |
+
<dd>
|
| 794 |
+
<div class="desc"><p>Lists the names of the available content sources.</p></div>
|
| 795 |
+
<details class="source">
|
| 796 |
+
<summary>
|
| 797 |
+
<span>Expand source code</span>
|
| 798 |
+
</summary>
|
| 799 |
+
<pre><code class="python">def list_sources(self) -> list:
|
| 800 |
+
"""
|
| 801 |
+
Lists the names of the available content sources.
|
| 802 |
+
"""
|
| 803 |
+
if self.name_to_document is not None:
|
| 804 |
+
return list(self.name_to_document.keys())
|
| 805 |
+
else:
|
| 806 |
+
return []</code></pre>
|
| 807 |
+
</details>
|
| 808 |
+
</dd>
|
| 809 |
+
<dt id="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.retrieve_by_name"><code class="name flex">
|
| 810 |
+
<span>def <span class="ident">retrieve_by_name</span></span>(<span>self, name: str) ‑> list</span>
|
| 811 |
+
</code></dt>
|
| 812 |
+
<dd>
|
| 813 |
+
<div class="desc"><p>Retrieves a content source by its name.</p></div>
|
| 814 |
+
<details class="source">
|
| 815 |
+
<summary>
|
| 816 |
+
<span>Expand source code</span>
|
| 817 |
+
</summary>
|
| 818 |
+
<pre><code class="python">def retrieve_by_name(self, name:str) -> list:
|
| 819 |
+
"""
|
| 820 |
+
Retrieves a content source by its name.
|
| 821 |
+
"""
|
| 822 |
+
# TODO also optionally provide a relevance target?
|
| 823 |
+
results = []
|
| 824 |
+
if self.name_to_document is not None and name in self.name_to_document:
|
| 825 |
+
docs = self.name_to_document[name]
|
| 826 |
+
for i, doc in enumerate(docs):
|
| 827 |
+
if doc is not None:
|
| 828 |
+
content = f"SOURCE: {name}\n"
|
| 829 |
+
content += f"PAGE: {i}\n"
|
| 830 |
+
content += "CONTENT: \n" + doc.text[:10000] # TODO a more intelligent way to limit the content
|
| 831 |
+
results.append(content)
|
| 832 |
+
|
| 833 |
+
return results</code></pre>
|
| 834 |
+
</details>
|
| 835 |
+
</dd>
|
| 836 |
+
<dt id="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.retrieve_relevant"><code class="name flex">
|
| 837 |
+
<span>def <span class="ident">retrieve_relevant</span></span>(<span>self, relevance_target: str, top_k=20) ‑> list</span>
|
| 838 |
+
</code></dt>
|
| 839 |
+
<dd>
|
| 840 |
+
<div class="desc"><p>Retrieves all values from memory that are relevant to a given target.</p></div>
|
| 841 |
+
<details class="source">
|
| 842 |
+
<summary>
|
| 843 |
+
<span>Expand source code</span>
|
| 844 |
+
</summary>
|
| 845 |
+
<pre><code class="python">def retrieve_relevant(self, relevance_target:str, top_k=20) -> list:
|
| 846 |
+
"""
|
| 847 |
+
Retrieves all values from memory that are relevant to a given target.
|
| 848 |
+
"""
|
| 849 |
+
# Handle empty or None query
|
| 850 |
+
if not relevance_target or not relevance_target.strip():
|
| 851 |
+
return []
|
| 852 |
+
|
| 853 |
+
if self.index is not None:
|
| 854 |
+
retriever = self.index.as_retriever(similarity_top_k=top_k)
|
| 855 |
+
nodes = retriever.retrieve(relevance_target)
|
| 856 |
+
else:
|
| 857 |
+
nodes = []
|
| 858 |
+
|
| 859 |
+
retrieved = []
|
| 860 |
+
for node in nodes:
|
| 861 |
+
content = "SOURCE: " + node.metadata.get('file_name', '(unknown)')
|
| 862 |
+
content += "\n" + "SIMILARITY SCORE:" + str(node.score)
|
| 863 |
+
content += "\n" + "RELEVANT CONTENT:" + node.text
|
| 864 |
+
retrieved.append(content)
|
| 865 |
+
|
| 866 |
+
logger.debug(f"Content retrieved: {content[:200]}")
|
| 867 |
+
|
| 868 |
+
return retrieved</code></pre>
|
| 869 |
+
</details>
|
| 870 |
+
</dd>
|
| 871 |
+
</dl>
|
| 872 |
+
<h3>Inherited members</h3>
|
| 873 |
+
<ul class="hlist">
|
| 874 |
+
<li><code><b><a title="tinytroupe.agent.grounding.GroundingConnector" href="#tinytroupe.agent.grounding.GroundingConnector">GroundingConnector</a></b></code>:
|
| 875 |
+
<ul class="hlist">
|
| 876 |
+
<li><code><a title="tinytroupe.agent.grounding.GroundingConnector.from_json" href="../utils/json.html#tinytroupe.utils.json.JsonSerializableRegistry.from_json">from_json</a></code></li>
|
| 877 |
+
<li><code><a title="tinytroupe.agent.grounding.GroundingConnector.to_json" href="../utils/json.html#tinytroupe.utils.json.JsonSerializableRegistry.to_json">to_json</a></code></li>
|
| 878 |
+
</ul>
|
| 879 |
+
</li>
|
| 880 |
+
</ul>
|
| 881 |
+
</dd>
|
| 882 |
+
<dt id="tinytroupe.agent.grounding.GroundingConnector"><code class="flex name class">
|
| 883 |
+
<span>class <span class="ident">GroundingConnector</span></span>
|
| 884 |
+
<span>(</span><span>name: str)</span>
|
| 885 |
+
</code></dt>
|
| 886 |
+
<dd>
|
| 887 |
+
<div class="desc"><p>An abstract class representing a grounding connector. A grounding connector is a component that allows an agent to ground
|
| 888 |
+
its knowledge in external sources, such as files, web pages, databases, etc.</p></div>
|
| 889 |
+
<details class="source">
|
| 890 |
+
<summary>
|
| 891 |
+
<span>Expand source code</span>
|
| 892 |
+
</summary>
|
| 893 |
+
<pre><code class="python">class GroundingConnector(JsonSerializableRegistry):
|
| 894 |
+
"""
|
| 895 |
+
An abstract class representing a grounding connector. A grounding connector is a component that allows an agent to ground
|
| 896 |
+
its knowledge in external sources, such as files, web pages, databases, etc.
|
| 897 |
+
"""
|
| 898 |
+
|
| 899 |
+
serializable_attributes = ["name"]
|
| 900 |
+
|
| 901 |
+
def __init__(self, name:str) -> None:
|
| 902 |
+
self.name = name
|
| 903 |
+
|
| 904 |
+
def retrieve_relevant(self, relevance_target:str, source:str, top_k=20) -> list:
|
| 905 |
+
raise NotImplementedError("Subclasses must implement this method.")
|
| 906 |
+
|
| 907 |
+
def retrieve_by_name(self, name:str) -> str:
|
| 908 |
+
raise NotImplementedError("Subclasses must implement this method.")
|
| 909 |
+
|
| 910 |
+
def list_sources(self) -> list:
|
| 911 |
+
raise NotImplementedError("Subclasses must implement this method.")</code></pre>
|
| 912 |
+
</details>
|
| 913 |
+
<h3>Ancestors</h3>
|
| 914 |
+
<ul class="hlist">
|
| 915 |
+
<li><a title="tinytroupe.utils.json.JsonSerializableRegistry" href="../utils/json.html#tinytroupe.utils.json.JsonSerializableRegistry">JsonSerializableRegistry</a></li>
|
| 916 |
+
</ul>
|
| 917 |
+
<h3>Subclasses</h3>
|
| 918 |
+
<ul class="hlist">
|
| 919 |
+
<li><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector" href="#tinytroupe.agent.grounding.BaseSemanticGroundingConnector">BaseSemanticGroundingConnector</a></li>
|
| 920 |
+
</ul>
|
| 921 |
+
<h3>Class variables</h3>
|
| 922 |
+
<dl>
|
| 923 |
+
<dt id="tinytroupe.agent.grounding.GroundingConnector.serializable_attributes"><code class="name">var <span class="ident">serializable_attributes</span></code></dt>
|
| 924 |
+
<dd>
|
| 925 |
+
<div class="desc"></div>
|
| 926 |
+
</dd>
|
| 927 |
+
</dl>
|
| 928 |
+
<h3>Methods</h3>
|
| 929 |
+
<dl>
|
| 930 |
+
<dt id="tinytroupe.agent.grounding.GroundingConnector.list_sources"><code class="name flex">
|
| 931 |
+
<span>def <span class="ident">list_sources</span></span>(<span>self) ‑> list</span>
|
| 932 |
+
</code></dt>
|
| 933 |
+
<dd>
|
| 934 |
+
<div class="desc"></div>
|
| 935 |
+
<details class="source">
|
| 936 |
+
<summary>
|
| 937 |
+
<span>Expand source code</span>
|
| 938 |
+
</summary>
|
| 939 |
+
<pre><code class="python">def list_sources(self) -> list:
|
| 940 |
+
raise NotImplementedError("Subclasses must implement this method.")</code></pre>
|
| 941 |
+
</details>
|
| 942 |
+
</dd>
|
| 943 |
+
<dt id="tinytroupe.agent.grounding.GroundingConnector.retrieve_by_name"><code class="name flex">
|
| 944 |
+
<span>def <span class="ident">retrieve_by_name</span></span>(<span>self, name: str) ‑> str</span>
|
| 945 |
+
</code></dt>
|
| 946 |
+
<dd>
|
| 947 |
+
<div class="desc"></div>
|
| 948 |
+
<details class="source">
|
| 949 |
+
<summary>
|
| 950 |
+
<span>Expand source code</span>
|
| 951 |
+
</summary>
|
| 952 |
+
<pre><code class="python">def retrieve_by_name(self, name:str) -> str:
|
| 953 |
+
raise NotImplementedError("Subclasses must implement this method.")</code></pre>
|
| 954 |
+
</details>
|
| 955 |
+
</dd>
|
| 956 |
+
<dt id="tinytroupe.agent.grounding.GroundingConnector.retrieve_relevant"><code class="name flex">
|
| 957 |
+
<span>def <span class="ident">retrieve_relevant</span></span>(<span>self, relevance_target: str, source: str, top_k=20) ‑> list</span>
|
| 958 |
+
</code></dt>
|
| 959 |
+
<dd>
|
| 960 |
+
<div class="desc"></div>
|
| 961 |
+
<details class="source">
|
| 962 |
+
<summary>
|
| 963 |
+
<span>Expand source code</span>
|
| 964 |
+
</summary>
|
| 965 |
+
<pre><code class="python">def retrieve_relevant(self, relevance_target:str, source:str, top_k=20) -> list:
|
| 966 |
+
raise NotImplementedError("Subclasses must implement this method.")</code></pre>
|
| 967 |
+
</details>
|
| 968 |
+
</dd>
|
| 969 |
+
</dl>
|
| 970 |
+
<h3>Inherited members</h3>
|
| 971 |
+
<ul class="hlist">
|
| 972 |
+
<li><code><b><a title="tinytroupe.utils.json.JsonSerializableRegistry" href="../utils/json.html#tinytroupe.utils.json.JsonSerializableRegistry">JsonSerializableRegistry</a></b></code>:
|
| 973 |
+
<ul class="hlist">
|
| 974 |
+
<li><code><a title="tinytroupe.utils.json.JsonSerializableRegistry.from_json" href="../utils/json.html#tinytroupe.utils.json.JsonSerializableRegistry.from_json">from_json</a></code></li>
|
| 975 |
+
<li><code><a title="tinytroupe.utils.json.JsonSerializableRegistry.to_json" href="../utils/json.html#tinytroupe.utils.json.JsonSerializableRegistry.to_json">to_json</a></code></li>
|
| 976 |
+
</ul>
|
| 977 |
+
</li>
|
| 978 |
+
</ul>
|
| 979 |
+
</dd>
|
| 980 |
+
<dt id="tinytroupe.agent.grounding.LocalFilesGroundingConnector"><code class="flex name class">
|
| 981 |
+
<span>class <span class="ident">LocalFilesGroundingConnector</span></span>
|
| 982 |
+
<span>(</span><span>*args, **kwargs)</span>
|
| 983 |
+
</code></dt>
|
| 984 |
+
<dd>
|
| 985 |
+
<div class="desc"><p>A base class for semantic grounding connectors. A semantic grounding connector is a component that indexes and retrieves
|
| 986 |
+
documents based on so-called "semantic search" (i.e, embeddings-based search). This specific implementation
|
| 987 |
+
is based on the VectorStoreIndex class from the LLaMa-Index library. Here, "documents" refer to the llama-index's
|
| 988 |
+
data structure that stores a unit of content, not necessarily a file.</p></div>
|
| 989 |
+
<details class="source">
|
| 990 |
+
<summary>
|
| 991 |
+
<span>Expand source code</span>
|
| 992 |
+
</summary>
|
| 993 |
+
<pre><code class="python">@utils.post_init
|
| 994 |
+
class LocalFilesGroundingConnector(BaseSemanticGroundingConnector):
|
| 995 |
+
|
| 996 |
+
serializable_attributes = ["folders_paths"]
|
| 997 |
+
|
| 998 |
+
def __init__(self, name:str="Local Files", folders_paths: list=None) -> None:
|
| 999 |
+
super().__init__(name)
|
| 1000 |
+
|
| 1001 |
+
self.folders_paths = folders_paths
|
| 1002 |
+
|
| 1003 |
+
# @post_init ensures that _post_init is called after the __init__ method
|
| 1004 |
+
|
| 1005 |
+
def _post_init(self):
|
| 1006 |
+
"""
|
| 1007 |
+
This will run after __init__, since the class has the @post_init decorator.
|
| 1008 |
+
It is convenient to separate some of the initialization processes to make deserialize easier.
|
| 1009 |
+
"""
|
| 1010 |
+
self.loaded_folders_paths = []
|
| 1011 |
+
|
| 1012 |
+
if not hasattr(self, 'folders_paths') or self.folders_paths is None:
|
| 1013 |
+
self.folders_paths = []
|
| 1014 |
+
|
| 1015 |
+
self.add_folders(self.folders_paths)
|
| 1016 |
+
|
| 1017 |
+
def add_folders(self, folders_paths:list) -> None:
|
| 1018 |
+
"""
|
| 1019 |
+
Adds a path to a folder with files used for grounding.
|
| 1020 |
+
"""
|
| 1021 |
+
|
| 1022 |
+
if folders_paths is not None:
|
| 1023 |
+
for folder_path in folders_paths:
|
| 1024 |
+
try:
|
| 1025 |
+
logger.debug(f"Adding the following folder to grounding index: {folder_path}")
|
| 1026 |
+
self.add_folder(folder_path)
|
| 1027 |
+
except (FileNotFoundError, ValueError) as e:
|
| 1028 |
+
print(f"Error: {e}")
|
| 1029 |
+
print(f"Current working directory: {os.getcwd()}")
|
| 1030 |
+
print(f"Provided path: {folder_path}")
|
| 1031 |
+
print("Please check if the path exists and is accessible.")
|
| 1032 |
+
|
| 1033 |
+
def add_folder(self, folder_path:str) -> None:
|
| 1034 |
+
"""
|
| 1035 |
+
Adds a path to a folder with files used for grounding.
|
| 1036 |
+
"""
|
| 1037 |
+
|
| 1038 |
+
if folder_path not in self.loaded_folders_paths:
|
| 1039 |
+
self._mark_folder_as_loaded(folder_path)
|
| 1040 |
+
|
| 1041 |
+
# for PDF files, please note that the document will be split into pages: https://github.com/run-llama/llama_index/issues/15903
|
| 1042 |
+
new_files = SimpleDirectoryReader(folder_path).load_data()
|
| 1043 |
+
BaseSemanticGroundingConnector._set_internal_id_to_documents(new_files, "file_name")
|
| 1044 |
+
|
| 1045 |
+
self.add_documents(new_files)
|
| 1046 |
+
|
| 1047 |
+
def add_file_path(self, file_path:str) -> None:
|
| 1048 |
+
"""
|
| 1049 |
+
Adds a path to a file used for grounding.
|
| 1050 |
+
"""
|
| 1051 |
+
# a trick to make SimpleDirectoryReader work with a single file
|
| 1052 |
+
new_files = SimpleDirectoryReader(input_files=[file_path]).load_data()
|
| 1053 |
+
|
| 1054 |
+
logger.debug(f"Adding the following file to grounding index: {new_files}")
|
| 1055 |
+
BaseSemanticGroundingConnector._set_internal_id_to_documents(new_files, "file_name")
|
| 1056 |
+
|
| 1057 |
+
def _mark_folder_as_loaded(self, folder_path:str) -> None:
|
| 1058 |
+
if folder_path not in self.loaded_folders_paths:
|
| 1059 |
+
self.loaded_folders_paths.append(folder_path)
|
| 1060 |
+
|
| 1061 |
+
if folder_path not in self.folders_paths:
|
| 1062 |
+
self.folders_paths.append(folder_path)</code></pre>
|
| 1063 |
+
</details>
|
| 1064 |
+
<h3>Ancestors</h3>
|
| 1065 |
+
<ul class="hlist">
|
| 1066 |
+
<li><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector" href="#tinytroupe.agent.grounding.BaseSemanticGroundingConnector">BaseSemanticGroundingConnector</a></li>
|
| 1067 |
+
<li><a title="tinytroupe.agent.grounding.GroundingConnector" href="#tinytroupe.agent.grounding.GroundingConnector">GroundingConnector</a></li>
|
| 1068 |
+
<li><a title="tinytroupe.utils.json.JsonSerializableRegistry" href="../utils/json.html#tinytroupe.utils.json.JsonSerializableRegistry">JsonSerializableRegistry</a></li>
|
| 1069 |
+
</ul>
|
| 1070 |
+
<h3>Class variables</h3>
|
| 1071 |
+
<dl>
|
| 1072 |
+
<dt id="tinytroupe.agent.grounding.LocalFilesGroundingConnector.custom_deserializers"><code class="name">var <span class="ident">custom_deserializers</span></code></dt>
|
| 1073 |
+
<dd>
|
| 1074 |
+
<div class="desc"></div>
|
| 1075 |
+
</dd>
|
| 1076 |
+
<dt id="tinytroupe.agent.grounding.LocalFilesGroundingConnector.custom_serializers"><code class="name">var <span class="ident">custom_serializers</span></code></dt>
|
| 1077 |
+
<dd>
|
| 1078 |
+
<div class="desc"></div>
|
| 1079 |
+
</dd>
|
| 1080 |
+
<dt id="tinytroupe.agent.grounding.LocalFilesGroundingConnector.serializable_attributes"><code class="name">var <span class="ident">serializable_attributes</span></code></dt>
|
| 1081 |
+
<dd>
|
| 1082 |
+
<div class="desc"></div>
|
| 1083 |
+
</dd>
|
| 1084 |
+
</dl>
|
| 1085 |
+
<h3>Methods</h3>
|
| 1086 |
+
<dl>
|
| 1087 |
+
<dt id="tinytroupe.agent.grounding.LocalFilesGroundingConnector.add_file_path"><code class="name flex">
|
| 1088 |
+
<span>def <span class="ident">add_file_path</span></span>(<span>self, file_path: str) ‑> None</span>
|
| 1089 |
+
</code></dt>
|
| 1090 |
+
<dd>
|
| 1091 |
+
<div class="desc"><p>Adds a path to a file used for grounding.</p></div>
|
| 1092 |
+
<details class="source">
|
| 1093 |
+
<summary>
|
| 1094 |
+
<span>Expand source code</span>
|
| 1095 |
+
</summary>
|
| 1096 |
+
<pre><code class="python">def add_file_path(self, file_path:str) -> None:
|
| 1097 |
+
"""
|
| 1098 |
+
Adds a path to a file used for grounding.
|
| 1099 |
+
"""
|
| 1100 |
+
# a trick to make SimpleDirectoryReader work with a single file
|
| 1101 |
+
new_files = SimpleDirectoryReader(input_files=[file_path]).load_data()
|
| 1102 |
+
|
| 1103 |
+
logger.debug(f"Adding the following file to grounding index: {new_files}")
|
| 1104 |
+
BaseSemanticGroundingConnector._set_internal_id_to_documents(new_files, "file_name")</code></pre>
|
| 1105 |
+
</details>
|
| 1106 |
+
</dd>
|
| 1107 |
+
<dt id="tinytroupe.agent.grounding.LocalFilesGroundingConnector.add_folder"><code class="name flex">
|
| 1108 |
+
<span>def <span class="ident">add_folder</span></span>(<span>self, folder_path: str) ‑> None</span>
|
| 1109 |
+
</code></dt>
|
| 1110 |
+
<dd>
|
| 1111 |
+
<div class="desc"><p>Adds a path to a folder with files used for grounding.</p></div>
|
| 1112 |
+
<details class="source">
|
| 1113 |
+
<summary>
|
| 1114 |
+
<span>Expand source code</span>
|
| 1115 |
+
</summary>
|
| 1116 |
+
<pre><code class="python">def add_folder(self, folder_path:str) -> None:
|
| 1117 |
+
"""
|
| 1118 |
+
Adds a path to a folder with files used for grounding.
|
| 1119 |
+
"""
|
| 1120 |
+
|
| 1121 |
+
if folder_path not in self.loaded_folders_paths:
|
| 1122 |
+
self._mark_folder_as_loaded(folder_path)
|
| 1123 |
+
|
| 1124 |
+
# for PDF files, please note that the document will be split into pages: https://github.com/run-llama/llama_index/issues/15903
|
| 1125 |
+
new_files = SimpleDirectoryReader(folder_path).load_data()
|
| 1126 |
+
BaseSemanticGroundingConnector._set_internal_id_to_documents(new_files, "file_name")
|
| 1127 |
+
|
| 1128 |
+
self.add_documents(new_files)</code></pre>
|
| 1129 |
+
</details>
|
| 1130 |
+
</dd>
|
| 1131 |
+
<dt id="tinytroupe.agent.grounding.LocalFilesGroundingConnector.add_folders"><code class="name flex">
|
| 1132 |
+
<span>def <span class="ident">add_folders</span></span>(<span>self, folders_paths: list) ‑> None</span>
|
| 1133 |
+
</code></dt>
|
| 1134 |
+
<dd>
|
| 1135 |
+
<div class="desc"><p>Adds a path to a folder with files used for grounding.</p></div>
|
| 1136 |
+
<details class="source">
|
| 1137 |
+
<summary>
|
| 1138 |
+
<span>Expand source code</span>
|
| 1139 |
+
</summary>
|
| 1140 |
+
<pre><code class="python">def add_folders(self, folders_paths:list) -> None:
|
| 1141 |
+
"""
|
| 1142 |
+
Adds a path to a folder with files used for grounding.
|
| 1143 |
+
"""
|
| 1144 |
+
|
| 1145 |
+
if folders_paths is not None:
|
| 1146 |
+
for folder_path in folders_paths:
|
| 1147 |
+
try:
|
| 1148 |
+
logger.debug(f"Adding the following folder to grounding index: {folder_path}")
|
| 1149 |
+
self.add_folder(folder_path)
|
| 1150 |
+
except (FileNotFoundError, ValueError) as e:
|
| 1151 |
+
print(f"Error: {e}")
|
| 1152 |
+
print(f"Current working directory: {os.getcwd()}")
|
| 1153 |
+
print(f"Provided path: {folder_path}")
|
| 1154 |
+
print("Please check if the path exists and is accessible.")</code></pre>
|
| 1155 |
+
</details>
|
| 1156 |
+
</dd>
|
| 1157 |
+
</dl>
|
| 1158 |
+
<h3>Inherited members</h3>
|
| 1159 |
+
<ul class="hlist">
|
| 1160 |
+
<li><code><b><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector" href="#tinytroupe.agent.grounding.BaseSemanticGroundingConnector">BaseSemanticGroundingConnector</a></b></code>:
|
| 1161 |
+
<ul class="hlist">
|
| 1162 |
+
<li><code><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.add_document" href="#tinytroupe.agent.grounding.BaseSemanticGroundingConnector.add_document">add_document</a></code></li>
|
| 1163 |
+
<li><code><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.add_documents" href="#tinytroupe.agent.grounding.BaseSemanticGroundingConnector.add_documents">add_documents</a></code></li>
|
| 1164 |
+
<li><code><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.from_json" href="../utils/json.html#tinytroupe.utils.json.JsonSerializableRegistry.from_json">from_json</a></code></li>
|
| 1165 |
+
<li><code><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.list_sources" href="#tinytroupe.agent.grounding.BaseSemanticGroundingConnector.list_sources">list_sources</a></code></li>
|
| 1166 |
+
<li><code><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.retrieve_by_name" href="#tinytroupe.agent.grounding.BaseSemanticGroundingConnector.retrieve_by_name">retrieve_by_name</a></code></li>
|
| 1167 |
+
<li><code><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.retrieve_relevant" href="#tinytroupe.agent.grounding.BaseSemanticGroundingConnector.retrieve_relevant">retrieve_relevant</a></code></li>
|
| 1168 |
+
<li><code><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.to_json" href="../utils/json.html#tinytroupe.utils.json.JsonSerializableRegistry.to_json">to_json</a></code></li>
|
| 1169 |
+
</ul>
|
| 1170 |
+
</li>
|
| 1171 |
+
</ul>
|
| 1172 |
+
</dd>
|
| 1173 |
+
<dt id="tinytroupe.agent.grounding.WebPagesGroundingConnector"><code class="flex name class">
|
| 1174 |
+
<span>class <span class="ident">WebPagesGroundingConnector</span></span>
|
| 1175 |
+
<span>(</span><span>*args, **kwargs)</span>
|
| 1176 |
+
</code></dt>
|
| 1177 |
+
<dd>
|
| 1178 |
+
<div class="desc"><p>A base class for semantic grounding connectors. A semantic grounding connector is a component that indexes and retrieves
|
| 1179 |
+
documents based on so-called "semantic search" (i.e, embeddings-based search). This specific implementation
|
| 1180 |
+
is based on the VectorStoreIndex class from the LLaMa-Index library. Here, "documents" refer to the llama-index's
|
| 1181 |
+
data structure that stores a unit of content, not necessarily a file.</p></div>
|
| 1182 |
+
<details class="source">
|
| 1183 |
+
<summary>
|
| 1184 |
+
<span>Expand source code</span>
|
| 1185 |
+
</summary>
|
| 1186 |
+
<pre><code class="python">@utils.post_init
|
| 1187 |
+
class WebPagesGroundingConnector(BaseSemanticGroundingConnector):
|
| 1188 |
+
|
| 1189 |
+
serializable_attributes = ["web_urls"]
|
| 1190 |
+
|
| 1191 |
+
def __init__(self, name:str="Web Pages", web_urls: list=None) -> None:
|
| 1192 |
+
super().__init__(name)
|
| 1193 |
+
|
| 1194 |
+
self.web_urls = web_urls
|
| 1195 |
+
|
| 1196 |
+
# @post_init ensures that _post_init is called after the __init__ method
|
| 1197 |
+
|
| 1198 |
+
def _post_init(self):
|
| 1199 |
+
self.loaded_web_urls = []
|
| 1200 |
+
|
| 1201 |
+
if not hasattr(self, 'web_urls') or self.web_urls is None:
|
| 1202 |
+
self.web_urls = []
|
| 1203 |
+
|
| 1204 |
+
# load web urls
|
| 1205 |
+
self.add_web_urls(self.web_urls)
|
| 1206 |
+
|
| 1207 |
+
def add_web_urls(self, web_urls:list) -> None:
|
| 1208 |
+
"""
|
| 1209 |
+
Adds the data retrieved from the specified URLs to grounding.
|
| 1210 |
+
"""
|
| 1211 |
+
filtered_web_urls = [url for url in web_urls if url not in self.loaded_web_urls]
|
| 1212 |
+
for url in filtered_web_urls:
|
| 1213 |
+
self._mark_web_url_as_loaded(url)
|
| 1214 |
+
|
| 1215 |
+
if len(filtered_web_urls) > 0:
|
| 1216 |
+
new_documents = SimpleWebPageReader(html_to_text=True).load_data(filtered_web_urls)
|
| 1217 |
+
BaseSemanticGroundingConnector._set_internal_id_to_documents(new_documents, "url")
|
| 1218 |
+
self.add_documents(new_documents)
|
| 1219 |
+
|
| 1220 |
+
def add_web_url(self, web_url:str) -> None:
|
| 1221 |
+
"""
|
| 1222 |
+
Adds the data retrieved from the specified URL to grounding.
|
| 1223 |
+
"""
|
| 1224 |
+
# we do it like this because the add_web_urls could run scrapes in parallel, so it is better
|
| 1225 |
+
# to implement this one in terms of the other
|
| 1226 |
+
self.add_web_urls([web_url])
|
| 1227 |
+
|
| 1228 |
+
def _mark_web_url_as_loaded(self, web_url:str) -> None:
|
| 1229 |
+
if web_url not in self.loaded_web_urls:
|
| 1230 |
+
self.loaded_web_urls.append(web_url)
|
| 1231 |
+
|
| 1232 |
+
if web_url not in self.web_urls:
|
| 1233 |
+
self.web_urls.append(web_url)</code></pre>
|
| 1234 |
+
</details>
|
| 1235 |
+
<h3>Ancestors</h3>
|
| 1236 |
+
<ul class="hlist">
|
| 1237 |
+
<li><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector" href="#tinytroupe.agent.grounding.BaseSemanticGroundingConnector">BaseSemanticGroundingConnector</a></li>
|
| 1238 |
+
<li><a title="tinytroupe.agent.grounding.GroundingConnector" href="#tinytroupe.agent.grounding.GroundingConnector">GroundingConnector</a></li>
|
| 1239 |
+
<li><a title="tinytroupe.utils.json.JsonSerializableRegistry" href="../utils/json.html#tinytroupe.utils.json.JsonSerializableRegistry">JsonSerializableRegistry</a></li>
|
| 1240 |
+
</ul>
|
| 1241 |
+
<h3>Class variables</h3>
|
| 1242 |
+
<dl>
|
| 1243 |
+
<dt id="tinytroupe.agent.grounding.WebPagesGroundingConnector.custom_deserializers"><code class="name">var <span class="ident">custom_deserializers</span></code></dt>
|
| 1244 |
+
<dd>
|
| 1245 |
+
<div class="desc"></div>
|
| 1246 |
+
</dd>
|
| 1247 |
+
<dt id="tinytroupe.agent.grounding.WebPagesGroundingConnector.custom_serializers"><code class="name">var <span class="ident">custom_serializers</span></code></dt>
|
| 1248 |
+
<dd>
|
| 1249 |
+
<div class="desc"></div>
|
| 1250 |
+
</dd>
|
| 1251 |
+
<dt id="tinytroupe.agent.grounding.WebPagesGroundingConnector.serializable_attributes"><code class="name">var <span class="ident">serializable_attributes</span></code></dt>
|
| 1252 |
+
<dd>
|
| 1253 |
+
<div class="desc"></div>
|
| 1254 |
+
</dd>
|
| 1255 |
+
</dl>
|
| 1256 |
+
<h3>Methods</h3>
|
| 1257 |
+
<dl>
|
| 1258 |
+
<dt id="tinytroupe.agent.grounding.WebPagesGroundingConnector.add_web_url"><code class="name flex">
|
| 1259 |
+
<span>def <span class="ident">add_web_url</span></span>(<span>self, web_url: str) ‑> None</span>
|
| 1260 |
+
</code></dt>
|
| 1261 |
+
<dd>
|
| 1262 |
+
<div class="desc"><p>Adds the data retrieved from the specified URL to grounding.</p></div>
|
| 1263 |
+
<details class="source">
|
| 1264 |
+
<summary>
|
| 1265 |
+
<span>Expand source code</span>
|
| 1266 |
+
</summary>
|
| 1267 |
+
<pre><code class="python">def add_web_url(self, web_url:str) -> None:
|
| 1268 |
+
"""
|
| 1269 |
+
Adds the data retrieved from the specified URL to grounding.
|
| 1270 |
+
"""
|
| 1271 |
+
# we do it like this because the add_web_urls could run scrapes in parallel, so it is better
|
| 1272 |
+
# to implement this one in terms of the other
|
| 1273 |
+
self.add_web_urls([web_url])</code></pre>
|
| 1274 |
+
</details>
|
| 1275 |
+
</dd>
|
| 1276 |
+
<dt id="tinytroupe.agent.grounding.WebPagesGroundingConnector.add_web_urls"><code class="name flex">
|
| 1277 |
+
<span>def <span class="ident">add_web_urls</span></span>(<span>self, web_urls: list) ‑> None</span>
|
| 1278 |
+
</code></dt>
|
| 1279 |
+
<dd>
|
| 1280 |
+
<div class="desc"><p>Adds the data retrieved from the specified URLs to grounding.</p></div>
|
| 1281 |
+
<details class="source">
|
| 1282 |
+
<summary>
|
| 1283 |
+
<span>Expand source code</span>
|
| 1284 |
+
</summary>
|
| 1285 |
+
<pre><code class="python">def add_web_urls(self, web_urls:list) -> None:
|
| 1286 |
+
"""
|
| 1287 |
+
Adds the data retrieved from the specified URLs to grounding.
|
| 1288 |
+
"""
|
| 1289 |
+
filtered_web_urls = [url for url in web_urls if url not in self.loaded_web_urls]
|
| 1290 |
+
for url in filtered_web_urls:
|
| 1291 |
+
self._mark_web_url_as_loaded(url)
|
| 1292 |
+
|
| 1293 |
+
if len(filtered_web_urls) > 0:
|
| 1294 |
+
new_documents = SimpleWebPageReader(html_to_text=True).load_data(filtered_web_urls)
|
| 1295 |
+
BaseSemanticGroundingConnector._set_internal_id_to_documents(new_documents, "url")
|
| 1296 |
+
self.add_documents(new_documents)</code></pre>
|
| 1297 |
+
</details>
|
| 1298 |
+
</dd>
|
| 1299 |
+
</dl>
|
| 1300 |
+
<h3>Inherited members</h3>
|
| 1301 |
+
<ul class="hlist">
|
| 1302 |
+
<li><code><b><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector" href="#tinytroupe.agent.grounding.BaseSemanticGroundingConnector">BaseSemanticGroundingConnector</a></b></code>:
|
| 1303 |
+
<ul class="hlist">
|
| 1304 |
+
<li><code><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.add_document" href="#tinytroupe.agent.grounding.BaseSemanticGroundingConnector.add_document">add_document</a></code></li>
|
| 1305 |
+
<li><code><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.add_documents" href="#tinytroupe.agent.grounding.BaseSemanticGroundingConnector.add_documents">add_documents</a></code></li>
|
| 1306 |
+
<li><code><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.from_json" href="../utils/json.html#tinytroupe.utils.json.JsonSerializableRegistry.from_json">from_json</a></code></li>
|
| 1307 |
+
<li><code><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.list_sources" href="#tinytroupe.agent.grounding.BaseSemanticGroundingConnector.list_sources">list_sources</a></code></li>
|
| 1308 |
+
<li><code><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.retrieve_by_name" href="#tinytroupe.agent.grounding.BaseSemanticGroundingConnector.retrieve_by_name">retrieve_by_name</a></code></li>
|
| 1309 |
+
<li><code><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.retrieve_relevant" href="#tinytroupe.agent.grounding.BaseSemanticGroundingConnector.retrieve_relevant">retrieve_relevant</a></code></li>
|
| 1310 |
+
<li><code><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.to_json" href="../utils/json.html#tinytroupe.utils.json.JsonSerializableRegistry.to_json">to_json</a></code></li>
|
| 1311 |
+
</ul>
|
| 1312 |
+
</li>
|
| 1313 |
+
</ul>
|
| 1314 |
+
</dd>
|
| 1315 |
+
</dl>
|
| 1316 |
+
</section>
|
| 1317 |
+
</article>
|
| 1318 |
+
<nav id="sidebar">
|
| 1319 |
+
<h1>Index</h1>
|
| 1320 |
+
<div class="toc">
|
| 1321 |
+
<ul></ul>
|
| 1322 |
+
</div>
|
| 1323 |
+
<ul id="index">
|
| 1324 |
+
<li><h3>Super-module</h3>
|
| 1325 |
+
<ul>
|
| 1326 |
+
<li><code><a title="tinytroupe.agent" href="index.html">tinytroupe.agent</a></code></li>
|
| 1327 |
+
</ul>
|
| 1328 |
+
</li>
|
| 1329 |
+
<li><h3><a href="#header-classes">Classes</a></h3>
|
| 1330 |
+
<ul>
|
| 1331 |
+
<li>
|
| 1332 |
+
<h4><code><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector" href="#tinytroupe.agent.grounding.BaseSemanticGroundingConnector">BaseSemanticGroundingConnector</a></code></h4>
|
| 1333 |
+
<ul class="">
|
| 1334 |
+
<li><code><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.add_document" href="#tinytroupe.agent.grounding.BaseSemanticGroundingConnector.add_document">add_document</a></code></li>
|
| 1335 |
+
<li><code><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.add_documents" href="#tinytroupe.agent.grounding.BaseSemanticGroundingConnector.add_documents">add_documents</a></code></li>
|
| 1336 |
+
<li><code><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.custom_deserializers" href="#tinytroupe.agent.grounding.BaseSemanticGroundingConnector.custom_deserializers">custom_deserializers</a></code></li>
|
| 1337 |
+
<li><code><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.custom_serializers" href="#tinytroupe.agent.grounding.BaseSemanticGroundingConnector.custom_serializers">custom_serializers</a></code></li>
|
| 1338 |
+
<li><code><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.list_sources" href="#tinytroupe.agent.grounding.BaseSemanticGroundingConnector.list_sources">list_sources</a></code></li>
|
| 1339 |
+
<li><code><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.retrieve_by_name" href="#tinytroupe.agent.grounding.BaseSemanticGroundingConnector.retrieve_by_name">retrieve_by_name</a></code></li>
|
| 1340 |
+
<li><code><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.retrieve_relevant" href="#tinytroupe.agent.grounding.BaseSemanticGroundingConnector.retrieve_relevant">retrieve_relevant</a></code></li>
|
| 1341 |
+
<li><code><a title="tinytroupe.agent.grounding.BaseSemanticGroundingConnector.serializable_attributes" href="#tinytroupe.agent.grounding.BaseSemanticGroundingConnector.serializable_attributes">serializable_attributes</a></code></li>
|
| 1342 |
+
</ul>
|
| 1343 |
+
</li>
|
| 1344 |
+
<li>
|
| 1345 |
+
<h4><code><a title="tinytroupe.agent.grounding.GroundingConnector" href="#tinytroupe.agent.grounding.GroundingConnector">GroundingConnector</a></code></h4>
|
| 1346 |
+
<ul class="">
|
| 1347 |
+
<li><code><a title="tinytroupe.agent.grounding.GroundingConnector.list_sources" href="#tinytroupe.agent.grounding.GroundingConnector.list_sources">list_sources</a></code></li>
|
| 1348 |
+
<li><code><a title="tinytroupe.agent.grounding.GroundingConnector.retrieve_by_name" href="#tinytroupe.agent.grounding.GroundingConnector.retrieve_by_name">retrieve_by_name</a></code></li>
|
| 1349 |
+
<li><code><a title="tinytroupe.agent.grounding.GroundingConnector.retrieve_relevant" href="#tinytroupe.agent.grounding.GroundingConnector.retrieve_relevant">retrieve_relevant</a></code></li>
|
| 1350 |
+
<li><code><a title="tinytroupe.agent.grounding.GroundingConnector.serializable_attributes" href="#tinytroupe.agent.grounding.GroundingConnector.serializable_attributes">serializable_attributes</a></code></li>
|
| 1351 |
+
</ul>
|
| 1352 |
+
</li>
|
| 1353 |
+
<li>
|
| 1354 |
+
<h4><code><a title="tinytroupe.agent.grounding.LocalFilesGroundingConnector" href="#tinytroupe.agent.grounding.LocalFilesGroundingConnector">LocalFilesGroundingConnector</a></code></h4>
|
| 1355 |
+
<ul class="">
|
| 1356 |
+
<li><code><a title="tinytroupe.agent.grounding.LocalFilesGroundingConnector.add_file_path" href="#tinytroupe.agent.grounding.LocalFilesGroundingConnector.add_file_path">add_file_path</a></code></li>
|
| 1357 |
+
<li><code><a title="tinytroupe.agent.grounding.LocalFilesGroundingConnector.add_folder" href="#tinytroupe.agent.grounding.LocalFilesGroundingConnector.add_folder">add_folder</a></code></li>
|
| 1358 |
+
<li><code><a title="tinytroupe.agent.grounding.LocalFilesGroundingConnector.add_folders" href="#tinytroupe.agent.grounding.LocalFilesGroundingConnector.add_folders">add_folders</a></code></li>
|
| 1359 |
+
<li><code><a title="tinytroupe.agent.grounding.LocalFilesGroundingConnector.custom_deserializers" href="#tinytroupe.agent.grounding.LocalFilesGroundingConnector.custom_deserializers">custom_deserializers</a></code></li>
|
| 1360 |
+
<li><code><a title="tinytroupe.agent.grounding.LocalFilesGroundingConnector.custom_serializers" href="#tinytroupe.agent.grounding.LocalFilesGroundingConnector.custom_serializers">custom_serializers</a></code></li>
|
| 1361 |
+
<li><code><a title="tinytroupe.agent.grounding.LocalFilesGroundingConnector.serializable_attributes" href="#tinytroupe.agent.grounding.LocalFilesGroundingConnector.serializable_attributes">serializable_attributes</a></code></li>
|
| 1362 |
+
</ul>
|
| 1363 |
+
</li>
|
| 1364 |
+
<li>
|
| 1365 |
+
<h4><code><a title="tinytroupe.agent.grounding.WebPagesGroundingConnector" href="#tinytroupe.agent.grounding.WebPagesGroundingConnector">WebPagesGroundingConnector</a></code></h4>
|
| 1366 |
+
<ul class="">
|
| 1367 |
+
<li><code><a title="tinytroupe.agent.grounding.WebPagesGroundingConnector.add_web_url" href="#tinytroupe.agent.grounding.WebPagesGroundingConnector.add_web_url">add_web_url</a></code></li>
|
| 1368 |
+
<li><code><a title="tinytroupe.agent.grounding.WebPagesGroundingConnector.add_web_urls" href="#tinytroupe.agent.grounding.WebPagesGroundingConnector.add_web_urls">add_web_urls</a></code></li>
|
| 1369 |
+
<li><code><a title="tinytroupe.agent.grounding.WebPagesGroundingConnector.custom_deserializers" href="#tinytroupe.agent.grounding.WebPagesGroundingConnector.custom_deserializers">custom_deserializers</a></code></li>
|
| 1370 |
+
<li><code><a title="tinytroupe.agent.grounding.WebPagesGroundingConnector.custom_serializers" href="#tinytroupe.agent.grounding.WebPagesGroundingConnector.custom_serializers">custom_serializers</a></code></li>
|
| 1371 |
+
<li><code><a title="tinytroupe.agent.grounding.WebPagesGroundingConnector.serializable_attributes" href="#tinytroupe.agent.grounding.WebPagesGroundingConnector.serializable_attributes">serializable_attributes</a></code></li>
|
| 1372 |
+
</ul>
|
| 1373 |
+
</li>
|
| 1374 |
+
</ul>
|
| 1375 |
+
</li>
|
| 1376 |
+
</ul>
|
| 1377 |
+
</nav>
|
| 1378 |
+
</main>
|
| 1379 |
+
<footer id="footer">
|
| 1380 |
+
<p>Generated by <a href="https://pdoc3.github.io/pdoc" title="pdoc: Python API documentation generator"><cite>pdoc</cite> 0.10.0</a>.</p>
|
| 1381 |
+
</footer>
|
| 1382 |
+
</body>
|
| 1383 |
+
</html>
|
external/TinyTroupe/docs/api/tinytroupe/agent/index.html
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
external/TinyTroupe/docs/api/tinytroupe/agent/memory.html
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|