{"id":31914106,"url":"https://github.com/bobjac/partnership-agent","last_synced_at":"2025-10-13T18:59:30.398Z","repository":{"id":314518350,"uuid":"1055612246","full_name":"bobjac/partnership-agent","owner":"bobjac","description":"Sample code showing agentic-ai over partnership agreements","archived":false,"fork":false,"pushed_at":"2025-10-07T17:37:03.000Z","size":215,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-07T17:39:42.607Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bobjac.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-12T14:23:25.000Z","updated_at":"2025-10-07T17:37:03.000Z","dependencies_parsed_at":"2025-10-01T08:01:57.897Z","dependency_job_id":null,"html_url":"https://github.com/bobjac/partnership-agent","commit_stats":null,"previous_names":["bobjac/partnership-agent"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bobjac/partnership-agent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bobjac%2Fpartnership-agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bobjac%2Fpartnership-agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bobjac%2Fpartnership-agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bobjac%2Fpartnership-agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bobjac","download_url":"https://codeload.github.com/bobjac/partnership-agent/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bobjac%2Fpartnership-agent/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279016626,"owners_count":26085853,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-13T18:59:28.979Z","updated_at":"2025-10-13T18:59:30.393Z","avatar_url":"https://github.com/bobjac.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Partnership Agent\n\nAn AI-powered partnership management system featuring **advanced citation functionality** and **high-performance vector search** that provides precise document references when answering questions about partnership agreements, revenue sharing, compliance, and operational requirements.\n\nBuilt with Azure OpenAI, Azure AI Search (or Elasticsearch), ASP.NET Core, and enhanced with intelligent document citation tracking and sub-second document retrieval.\n\n## 🚀 Quick Start (Recommended)\n\n### ⭐ **Preferred Method: Cross-Platform .NET Setup**\n\nWorks identically on **Windows, macOS, and Linux**:\n\n```bash\n# Linux/macOS - Default (InMemory chat history, Elasticsearch)\ncd setup\n./setup.sh\n\n# Linux/macOS - High-performance vector search with Azure AI Search\ncd setup\n./setup.sh inmemory --vector-search\n\n# Linux/macOS - SQLite chat history with vector search\ncd setup\n./setup.sh sqlite --vector-search\n\n# Linux/macOS - Azure SQL chat history  \ncd setup\n./setup.sh azuresql\n\n# Windows Command Prompt\ncd setup\nsetup.cmd [inmemory|sqlite|azuresql] [--vector-search]\n\n# Windows PowerShell  \ncd setup\n.\\setup.cmd [inmemory|sqlite|azuresql] [--vector-search]\n```\n\n**Why this is preferred:**\n- ✅ Single codebase - no platform differences\n- ✅ Better error handling and logging\n- ✅ Consistent behavior across all operating systems\n- ✅ Professional development practices\n- ✅ Easier to maintain and extend\n- 🚀 **High-performance vector search option** for production workloads\n\n## 🔧 Alternative Setup Methods\n\n### Platform-Specific Scripts (Legacy)\n\n**Linux/macOS (Bash):**\n```bash\n./setup/start-partnership-agent.sh\n```\n\n**Windows (PowerShell):**\n```powershell\n.\\setup\\start-partnership-agent.ps1\n```\n\n### Manual .NET Execution\n```bash\ncd setup\ndotnet run --project setup.csproj [inmemory|sqlite|azuresql] [--vector-search]\n\n# Examples:\ndotnet run                           # Uses InMemory (default) + Elasticsearch\ndotnet run inmemory --vector-search  # Uses InMemory + Azure AI Search (high performance)\ndotnet run sqlite                    # Uses SQLite + Elasticsearch\ndotnet run sqlite --vector-search   # Uses SQLite + Azure AI Search (recommended)\ndotnet run azuresql                  # Uses Azure SQL Database\n```\n\n## 🔍 Search Engine Options\n\nThe Partnership Agent supports two search engine configurations:\n\n### 🚀 **Azure AI Search (Vector Search) - Recommended for Production**\n- **Best for**: Production deployments, high-performance requirements\n- **Performance**: Sub-second document retrieval (99%+ faster than Elasticsearch)\n- **Technology**: Vector embeddings with semantic similarity search  \n- **Setup**: Requires Azure AI Search service configuration\n- **Cost**: ~$250/month for Basic tier\n- **Benefits**: Semantic understanding, automatic scaling, managed service\n\n### 🗃️ **Elasticsearch (Traditional Text Search) - Default**\n- **Best for**: Development, testing, offline scenarios\n- **Performance**: 60-120 seconds for document search\n- **Technology**: Text-based search with keyword matching\n- **Setup**: Automatic Docker container deployment\n- **Cost**: Free (local Docker container)\n- **Benefits**: No cloud dependencies, familiar technology\n\n## 💾 Chat History Options\n\nThe Partnership Agent supports three chat history storage options:\n\n### 🧠 **InMemory (Default)**\n- **Best for**: Development, testing, quick demos\n- **Persistence**: No persistence - data lost on restart\n- **Setup**: Zero configuration required\n- **Performance**: Fastest startup and response times\n\n### 🗄️ **SQLite (Recommended for Local Development)**\n- **Best for**: Local development with persistence, offline work\n- **Persistence**: Full persistence in local SQLite database\n- **Setup**: Automatic Docker container with volume mounting\n- **Performance**: Fast local file-based storage\n- **Container**: `partnership-agent-sqlite` with persistent volume\n\n### ☁️ **Azure SQL Database**\n- **Best for**: Production deployments, multi-user scenarios\n- **Persistence**: Full persistence in cloud database\n- **Setup**: Requires Azure SQL Database and connection configuration\n- **Performance**: Network-dependent, highly scalable\n- **Features**: Enterprise-grade reliability and backup\n\n## 🎯 What Gets Set Up\n\nThe setup process configures a complete partnership management system with **citation-enhanced AI responses**:\n\n### 🗃️ **Enhanced Document Index**\n- **8 comprehensive documents** with realistic partnership content\n- **Rich metadata** including source paths, modification dates, and versioning\n- **Citation-optimized content** with specific percentages, requirements, and procedures\n\n### 📋 **Document Categories:**\n1. **Partnership Agreement Template** - Formation, revenue tiers, contribution requirements\n2. **Revenue Sharing Guidelines** - Detailed calculation methods, payment terms\n3. **Partnership Compliance Requirements** - Documentation standards, audit procedures\n4. **Standard Partnership Contract** - IP rights, liability, termination procedures\n5. **Partner Onboarding Process** - Assessment criteria, training requirements\n6. **Dispute Resolution Framework** - Escalation procedures, mediation processes\n7. **Performance Metrics and KPIs** - Revenue metrics, operational standards\n8. **Data Security and Privacy Policy** - Classification levels, security controls\n\n### 🔍 **Citation Features**\n- **Precise text excerpts** with character-level positioning\n- **Relevance scoring** based on query-answer term matching\n- **Context awareness** with before/after text snippets\n- **Multi-source references** from multiple documents\n- **Document metadata** including categories and modification dates\n\n## 🧪 Testing Citation Functionality\n\n### Quick Citation Tests\n```bash\n# Linux/macOS\n./setup/test-citations.sh\n\n# Windows\n.\\setup\\test-citations.ps1\n```\n\n### Example Citation Queries\nTry these prompts to see rich citations in action:\n\n1. **\"What are the revenue sharing percentages for different partner tiers?\"**\n   - Expected citations from Partnership Agreement Template and Revenue Sharing Guidelines\n   - Should show specific percentages: Tier 1 (30-35%), Tier 2 (20-25%), Tier 3 (10-15%)\n\n2. **\"What is the minimum credit score requirement for partner verification?\"**\n   - Expected citation from Partnership Compliance Requirements\n   - Should reference the 650 minimum credit score\n\n3. **\"How long is the notice period for partnership termination?\"**\n   - Expected citation from Standard Partnership Contract\n   - Should reference the 90-day written notice requirement\n\n## 🏗️ Architecture Overview\n\n```\n┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐\n│   Console App   │    │     Web API      │    │   Elasticsearch │\n│                 │◄──►│                  │◄──►│                 │\n│ - Interactive   │    │ - REST endpoints │    │ - Document      │\n│   chat          │    │ - Step           │    │   indexing      │\n│ - Test prompts  │    │   orchestration  │    │ - Search        │\n└─────────────────┘    └──────────────────┘    └─────────────────┘\n                                │\n                                ▼\n                       ┌──────────────────┐\n                       │   Citation       │\n                       │   Engine         │\n                       │                  │\n                       │ - Text analysis  │\n                       │ - Excerpt        │\n                       │   extraction     │\n                       │ - Relevance      │\n                       │   scoring        │\n                       └──────────────────┘\n                                │\n                                ▼\n                    ┌──────────────────────────┐\n                    │    Chat History          │\n                    │    Storage               │\n                    ├──────────────────────────┤\n                    │ 🧠 InMemory (Default)    │\n                    │ 🗄️ SQLite Container      │\n                    │ ☁️ Azure SQL Database    │\n                    └──────────────────────────┘\n```\n\n## 🔌 Running the Applications\n\nAfter setup, you can run the applications individually:\n\n### Web API\n```bash\ncd src/PartnershipAgent.WebApi\ndotnet run --urls=\"http://localhost:5001\"\n```\n- REST API available at `http://localhost:5001`\n- Swagger UI at `http://localhost:5001/swagger`\n- Health check at `http://localhost:5001/api/chat/health`\n\n### Console Application\n```bash\ncd src/PartnershipAgent.ConsoleApp\ndotnet run\n```\n- Interactive chat interface\n- Type questions about partnerships\n- See detailed citations in responses\n- Type 'quit' to exit\n\n### Example API Request\n```bash\ncurl -X POST \"http://localhost:5001/api/chat\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"threadId\": \"test-123\",\n    \"prompt\": \"What are the revenue sharing percentages?\"\n  }'\n```\n\n## 📊 Citation Response Format\n\nResponses now include detailed citations:\n\n```json\n{\n  \"answer\": \"Revenue sharing is structured in tiers...\",\n  \"confidence_level\": \"high\",\n  \"source_documents\": [\"Revenue Sharing Guidelines\", \"Partnership Agreement Template\"],\n  \"citations\": [\n    {\n      \"document_id\": \"doc2\",\n      \"document_title\": \"Revenue Sharing Guidelines\",\n      \"category\": \"guidelines\",\n      \"excerpt\": \"Tier 1 (Strategic Partners): 30% of net revenue, paid monthly\",\n      \"start_position\": 1450,\n      \"end_position\": 1502,\n      \"relevance_score\": 0.92,\n      \"context_before\": \"Partner shares are distributed according to contribution tiers:\",\n      \"context_after\": \"- Tier 2 (Operational Partners): 20% of net revenue\"\n    }\n  ],\n  \"has_complete_answer\": true,\n  \"follow_up_suggestions\": [...]\n}\n```\n\n## 🛠️ Requirements\n\n### Essential Requirements\n- **.NET 8 SDK** - [Download here](https://dotnet.microsoft.com/download)\n- **Docker** - [Docker Desktop](https://www.docker.com/products/docker-desktop) (Windows) or Docker Engine (Linux/macOS)\n  - Required for Elasticsearch (default search)\n  - Required for SQLite chat history (optional)\n- **Azure OpenAI** - Access to Azure OpenAI service with deployed model\n- **Internet connection** - For downloading Docker images\n\n### Optional Requirements (Based on Configuration)\n- **Azure AI Search** - Required for high-performance vector search (`--vector-search` option)\n- **Azure SQL Database** - Only required if using Azure SQL chat history option\n\n### For High-Performance Vector Search\nWhen using `--vector-search` option, you'll need:\n- **Azure AI Search service** (Basic tier recommended)\n- **Azure OpenAI with embeddings model** (text-embedding-ada-002)\n- **Additional Azure costs** (~$250/month for Basic tier)\n\n## 📚 Documentation\n\nDetailed guides available in the `/docs` directory:\n\n### Core Setup \u0026 Configuration\n- **[Setup Instructions](docs/setup-instructions.md)** - Complete manual setup guide\n- **[Azure OpenAI Setup](docs/azure-openai-setup.md)** - Azure OpenAI configuration\n- **[Azure AI Search Setup](docs/azure-ai-search-setup.md)** - 🚀 High-performance vector search configuration\n- **[Azure Key Vault Setup](docs/azure-keyvault-setup.md)** - Enterprise credential management\n- **[Credential Management](docs/credential-management.md)** - Security best practices\n- **[Chat History Configuration](docs/chat-history-configuration.md)** - Chat persistence options\n\n### System Features \u0026 Architecture\n- **[Evaluation System](docs/EVALUATION_SYSTEM.md)** - 📊 AI response evaluation framework with quality metrics\n- **[Observability](docs/OBSERVABILITY.md)** - Monitoring and telemetry configuration\n- **[Performance Optimization](docs/PERFORMANCE_OPTIMIZATION_PLAN.md)** - Performance tuning strategies\n\n### Testing \u0026 Troubleshooting\n- **[Citation Testing Guide](setup/TESTING_CITATIONS.md)** - Comprehensive citation testing\n- **[Timeout Troubleshooting](docs/TIMEOUT_TROUBLESHOOTING.md)** - Network and timeout issues\n- **[No Timeouts Configuration](docs/NO_TIMEOUTS_CONFIG.md)** - Disable timeout configurations\n\n## 🧩 Project Structure\n\n```\npartnership-agent/\n├── src/\n│   ├── PartnershipAgent.Core/          # Core business logic \u0026 citation engine\n│   ├── PartnershipAgent.WebApi/        # REST API endpoints\n│   ├── PartnershipAgent.ConsoleApp/    # Interactive console interface\n│   └── PartnershipAgent.Core.Tests/    # Unit tests including citation tests\n├── setup/                              # Setup scripts and tools\n│   ├── setup.sh / setup.cmd           # 🌟 Cross-platform setup (PREFERRED)\n│   ├── start-partnership-agent.sh     # Legacy bash script\n│   ├── start-partnership-agent.ps1    # Legacy PowerShell script\n│   ├── test-citations.sh/ps1          # Citation testing scripts\n│   ├── CrossPlatformSetup.cs          # .NET setup application\n│   └── sample-documents-bulk.json     # Enhanced sample documents\n└── docs/                               # Documentation\n```\n\n## 🔍 Key Features\n\n### Citation Engine\n- **Smart text analysis** with relevance scoring\n- **Precise positioning** with character-level accuracy\n- **Context extraction** for better understanding\n- **Multi-document synthesis** from various sources\n\n### Document Processing\n- **Enhanced metadata** including source paths and timestamps\n- **Categorized content** (templates, guidelines, policies, contracts)\n- **Structured indexing** optimized for citation extraction\n\n### AI Integration\n- **Azure OpenAI** for natural language understanding\n- **Semantic Kernel** for agent orchestration\n- **Step-based processing** with entity resolution and response generation\n\n## ⚙️ Configuration Options\n\n### Chat History Provider Configuration\n\nYou can configure chat history storage through user secrets or directly:\n\n```bash\n# Set chat history provider\ndotnet user-secrets set \"ChatHistory:Provider\" \"sqlite\"\n\n# Configure SQLite connection (if using SQLite)\ndotnet user-secrets set \"SQLite:ConnectionString\" \"Data Source=/data/partnership-agent.db;Cache=Shared\"\n\n# Configure Azure SQL connection (if using Azure SQL)\ndotnet user-secrets set \"AzureSQL:ConnectionString\" \"your-azure-sql-connection-string\"\n```\n\n### Runtime Chat History Switching\n\nYou can also switch providers at runtime by modifying `appsettings.json`:\n\n```json\n{\n  \"ChatHistory\": {\n    \"Provider\": \"sqlite\"  // \"inmemory\", \"sqlite\", or \"azuresql\"\n  },\n  \"SQLite\": {\n    \"ConnectionString\": \"Data Source=/data/partnership-agent.db;Cache=Shared\"\n  }\n}\n```\n\n## 🚦 Getting Started Steps\n\n1. **Clone the repository**\n2. **Choose your configuration**:\n   - `./setup/setup.sh` (InMemory + Elasticsearch - fastest setup)\n   - `./setup/setup.sh sqlite` (SQLite + Elasticsearch - persistent, local)\n   - `./setup/setup.sh sqlite --vector-search` (SQLite + Azure AI Search - high performance)\n   - `./setup/setup.sh azuresql` (Azure SQL - production-ready)\n3. **Configure Azure AI Search** (if using `--vector-search`):\n   - See [Azure AI Search Setup Guide](docs/azure-ai-search-setup.md)\n4. **Test with sample queries** about revenue sharing, compliance, or termination procedures\n5. **Explore the citation responses** to see precise document references\n6. **Try the console app** for interactive testing with persistent chat history\n\n## 🤝 Contributing\n\nWhen contributing to this project:\n- Use the **cross-platform .NET setup** for consistency\n- Run the citation tests to ensure functionality\n- Follow the existing code patterns for citation extraction\n- Update documentation for any new citation features\n\n## 📄 License\n\nThis project is provided as sample code for educational and demonstration purposes.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbobjac%2Fpartnership-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbobjac%2Fpartnership-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbobjac%2Fpartnership-agent/lists"}