How dfinke/psai works
Main system components
• User Interface Layer: This is the PowerShell console (or any script/file that the user runs) where commands like Invoke-OAIChat or Invoke-QuickPrompt are executed.
• PSAI Module Core: The heart of the system is the PSAI engine implemented mainly with public functions (in the Public directory). This layer exposes functions for interacting with OpenAI via different commands (e.g., New-Agent, Get-AgentResponse, ConvertTo-AIPrompt).
• Internal Helper and Utility Components: The Private folder contains helper scripts that support core functionality such as argument completion, constructing multipart data, and HTTP calls (like Invoke-OAIBeta).
• Tools Integration: Under Public/Tools (and additional functions elsewhere) you have multiple specialized tools (like CalculatorTool, StockTickerTool, YouTubeTool, etc.) which are registered and used by agents. Represent these as separate modules that plug into the overall agent workflow.
Relationships and Data Flow
• The PSAI core then delegates tasks to internal helper scripts (Private folder) and further relies on the Agents Manager to decide which specialized tool should be engaged.
• The ConvertTo-AIPrompt functionality is another component that takes a repository as input and reformats the content for AI processing. This can be an independent utility module represented within the core PSAI engine.
• Unit and integration tests (represented by the __tests__ folder) should be indicated as a separate “Testing Suite” element verifying interactions between these components.
Architectural Patterns and Design Principles
• Layered Architecture: Clearly delineate the client interface, internal processing (script logic and agents), and the adapter/connector layer that communicates with external services.
• Modularity and Extensibility: Emphasize how new tools (agents and integrations) can be registered and added. Use annotations such as “Tool Registration” or “Modular Plugin Architecture.”
• Separation of Concerns: The distinction between Public and Private functions illustrates a clear separation of API exposure versus internal logic.
Relevant Technologies, Frameworks, and Languages
• PowerShell as the primary development environment.
• OpenAI and Azure OpenAI APIs (with secrets management for API keys).
• Use of GitHub Actions (configuration in .github/workflows/ci.yml) which may be depicted as a CI/CD pipeline node connected to the source repository.
• Testing tools (Pester-based tests in the __tests__ directory).
Elements
• From the user invoking a command to the PSAI module.
• From the module to the Agents Manager and then to registered tools.
• From the tools to external services.
• Adding a layer for “Configuration & Secret Management” where API keys and secrets (e.g., OpenAIKey, TAVILY_API_KEY) are set up.
Additional Details
• You might include a smaller “Utility” cluster that houses functions like ConvertFrom/To functions—demonstrating how source code and prompts are formatted.
• A CI/CD integration block (based on GitHub Actions) that shows automated testing and deployment pipelines.
• Detail any special flows like “Agent Tool Registration” showing that new tools (like from Public/Tools) can plug into the agent workflow to extend PSAI’s capabilities.