Spaces:
Running
Running
Upload 6 files
Browse files- .gitignore +42 -0
- README.md +86 -12
- app_py.py +8 -0
- env_example.txt +8 -0
- ocs4dev.py +946 -0
- requirements.txt +34 -0
.gitignore
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
__pycache__/
|
| 2 |
+
*.py[cod]
|
| 3 |
+
*$py.class
|
| 4 |
+
*.so
|
| 5 |
+
.Python
|
| 6 |
+
build/
|
| 7 |
+
develop-eggs/
|
| 8 |
+
dist/
|
| 9 |
+
downloads/
|
| 10 |
+
eggs/
|
| 11 |
+
.eggs/
|
| 12 |
+
lib/
|
| 13 |
+
lib64/
|
| 14 |
+
parts/
|
| 15 |
+
sdist/
|
| 16 |
+
var/
|
| 17 |
+
wheels/
|
| 18 |
+
*.egg-info/
|
| 19 |
+
.installed.cfg
|
| 20 |
+
*.egg
|
| 21 |
+
|
| 22 |
+
# Environment
|
| 23 |
+
.env
|
| 24 |
+
.venv
|
| 25 |
+
env/
|
| 26 |
+
venv/
|
| 27 |
+
ENV/
|
| 28 |
+
env.bak/
|
| 29 |
+
venv.bak/
|
| 30 |
+
|
| 31 |
+
# IDE
|
| 32 |
+
.vscode/
|
| 33 |
+
.idea/
|
| 34 |
+
*.swp
|
| 35 |
+
*.swo
|
| 36 |
+
*~
|
| 37 |
+
|
| 38 |
+
# Logs
|
| 39 |
+
*.log
|
| 40 |
+
|
| 41 |
+
# Model cache
|
| 42 |
+
.cache/
|
README.md
CHANGED
|
@@ -1,14 +1,88 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
---
|
| 13 |
|
| 14 |
-
|
|
|
|
| 1 |
+
# π¦ ocs4dev - Fintech API Integration Assistant
|
| 2 |
+
|
| 3 |
+
## Overview
|
| 4 |
+
|
| 5 |
+
ocs4dev is a specialized AI assistant designed to help developers integrate fintech APIs including MTN MoMo, Pesapal, Airtel,Sentezo etc. It provides code examples, implementation guidance, and best practices for payment gateway integration.
|
| 6 |
+
|
| 7 |
+
## Features
|
| 8 |
+
|
| 9 |
+
- π§ **Code-Focused**: Optimized for API integration tasks with practical examples
|
| 10 |
+
- π€ **Multi-Model Support**: Choose between local Qwen2.5-Coder or API models (OpenAI, Anthropic, Google)
|
| 11 |
+
- π **Secure**: No API keys stored permanently
|
| 12 |
+
- π **Copy-Friendly**: Built-in code copying functionality
|
| 13 |
+
- π **Fast**: Multiple model options for optimal performance
|
| 14 |
+
- π **RAG-Powered**: Retrieves relevant documentation from vector database
|
| 15 |
+
|
| 16 |
+
## Supported APIs
|
| 17 |
+
|
| 18 |
+
- **MTN MoMo**: Mobile money integration
|
| 19 |
+
- **Airtel API**: Airtel api integration
|
| 20 |
+
- **Pesapal**: Payment gateway services
|
| 21 |
+
- **Sentezo**: Mobile payment platform
|
| 22 |
+
- And more fintech APIs...
|
| 23 |
+
|
| 24 |
+
## Model Options
|
| 25 |
+
|
| 26 |
+
### Local Model (Free)
|
| 27 |
+
- **Qwen2.5-Coder-7B-Instruct-AWQ**: Quantized model optimized for code generation
|
| 28 |
+
- Requires GPU for best performance
|
| 29 |
+
- No API key needed
|
| 30 |
+
|
| 31 |
+
### API Models
|
| 32 |
+
- **OpenAI**: GPT-4o-mini (budget) / O4-mini (premium)
|
| 33 |
+
- **Anthropic**: Claude-3.5-Sonnet / Claude-4-Sonnet
|
| 34 |
+
- **Google**: Gemini-2.0-Flash / Gemini-2.0-Flash-Thinking
|
| 35 |
+
|
| 36 |
+
## Quick Start
|
| 37 |
+
|
| 38 |
+
1. Visit the [Space URL](https://huggingface.co/spaces/YOUR_USERNAME/ocs4dev)
|
| 39 |
+
2. Choose your preferred model provider
|
| 40 |
+
3. Add API keys if using cloud models
|
| 41 |
+
4. Start asking questions about fintech API integration!
|
| 42 |
+
|
| 43 |
+
## Example Questions
|
| 44 |
+
|
| 45 |
+
- "How do I authenticate with MTN MoMo API?"
|
| 46 |
+
- "Show me a Pesapal payment integration example"
|
| 47 |
+
- "What are the required headers for Sentezo API?"
|
| 48 |
+
- "How do I handle payment webhooks?"
|
| 49 |
+
- "Best practices for API error handling"
|
| 50 |
+
|
| 51 |
+
## Environment Variables
|
| 52 |
+
|
| 53 |
+
For self-hosting, set these environment variables:
|
| 54 |
+
|
| 55 |
+
```bash
|
| 56 |
+
# Supabase (for vector store)
|
| 57 |
+
SUPABASE_URL=your-supabase-url
|
| 58 |
+
SUPABASE_SERVICE_KEY=your-service-key
|
| 59 |
+
|
| 60 |
+
# API Keys (optional)
|
| 61 |
+
OPENAI_API_KEY=your-openai-key
|
| 62 |
+
ANTHROPIC_API_KEY=your-anthropic-key
|
| 63 |
+
GOOGLE_API_KEY=your-google-key
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
## Technical Stack
|
| 67 |
+
|
| 68 |
+
- **Frontend**: Gradio
|
| 69 |
+
- **LLM Framework**: LangChain
|
| 70 |
+
- **Vector Store**: Supabase
|
| 71 |
+
- **Models**: Qwen2.5-Coder, OpenAI, Anthropic, Google
|
| 72 |
+
- **Embeddings**: OpenAI text-embedding-3-small
|
| 73 |
+
|
| 74 |
+
## Contributing
|
| 75 |
+
|
| 76 |
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
| 77 |
+
|
| 78 |
+
## License
|
| 79 |
+
|
| 80 |
+
This project is licensed under the MIT License.
|
| 81 |
+
|
| 82 |
+
## Support
|
| 83 |
+
|
| 84 |
+
For issues or questions, please open an issue on GitHub or contact me.
|
| 85 |
+
|
| 86 |
---
|
| 87 |
|
| 88 |
+
Built with β€οΈ using Qwen2.5-Coder, LangChain, and Gradio
|
app_py.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# app.py - Entry point for Hugging Face Spaces
|
| 2 |
+
# This file is required and must be named app.py for HF Spaces
|
| 3 |
+
|
| 4 |
+
# Import your main script
|
| 5 |
+
from ocs4dev import main
|
| 6 |
+
|
| 7 |
+
if __name__ == "__main__":
|
| 8 |
+
main()
|
env_example.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Supabase Configuration (Required for vector store)
|
| 2 |
+
SUPABASE_URL=your-supabase-project-url
|
| 3 |
+
SUPABASE_SERVICE_KEY=your-supabase-service-key
|
| 4 |
+
|
| 5 |
+
# API Keys (Optional - users can add via UI)
|
| 6 |
+
OPENAI_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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import glob
|
| 3 |
+
import gradio as gr
|
| 4 |
+
from dotenv import load_dotenv
|
| 5 |
+
from typing import List, Dict, Any, Tuple, Optional
|
| 6 |
+
import uuid
|
| 7 |
+
import torch
|
| 8 |
+
from huggingface_hub import hf_hub_download
|
| 9 |
+
import warnings
|
| 10 |
+
warnings.filterwarnings("ignore")
|
| 11 |
+
|
| 12 |
+
# Updated imports to avoid deprecation warnings
|
| 13 |
+
from langchain_community.document_loaders import DirectoryLoader, TextLoader
|
| 14 |
+
from langchain_text_splitters import CharacterTextSplitter
|
| 15 |
+
from langchain_core.documents import Document
|
| 16 |
+
from langchain_core.messages import HumanMessage, AIMessage
|
| 17 |
+
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
| 18 |
+
from langchain_core.runnables import RunnablePassthrough
|
| 19 |
+
from langchain_core.output_parsers import StrOutputParser
|
| 20 |
+
|
| 21 |
+
# Modern LangChain chains (replacing deprecated ConversationalRetrievalChain)
|
| 22 |
+
from langchain.chains import create_history_aware_retriever, create_retrieval_chain
|
| 23 |
+
from langchain.chains.combine_documents import create_stuff_documents_chain
|
| 24 |
+
|
| 25 |
+
# Multi-provider LLM support
|
| 26 |
+
from langchain_openai import OpenAIEmbeddings, ChatOpenAI
|
| 27 |
+
from langchain_anthropic import ChatAnthropic
|
| 28 |
+
from langchain_google_genai import ChatGoogleGenerativeAI
|
| 29 |
+
|
| 30 |
+
# Supabase integration (pre-configured by admin)
|
| 31 |
+
from langchain_community.vectorstores import SupabaseVectorStore
|
| 32 |
+
from supabase.client import Client, create_client
|
| 33 |
+
|
| 34 |
+
# Hugging Face Transformers for local Qwen model
|
| 35 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
| 36 |
+
import accelerate
|
| 37 |
+
|
| 38 |
+
# Configuration
|
| 39 |
+
DEFAULT_MODEL = "Qwen/Qwen2.5-Coder-7B-Instruct-AWQ" # Quantized version for better performance
|
| 40 |
+
TOP_K_DOCUMENTS = 5
|
| 41 |
+
|
| 42 |
+
# Model configurations for each provider
|
| 43 |
+
MODEL_CONFIGS = {
|
| 44 |
+
"openai": {
|
| 45 |
+
"budget": "gpt-4o-mini",
|
| 46 |
+
"premium": "o4-mini"
|
| 47 |
+
},
|
| 48 |
+
"anthropic": {
|
| 49 |
+
"budget": "claude-3-5-sonnet-20241022",
|
| 50 |
+
"premium": "claude-4-sonnet-20250109"
|
| 51 |
+
},
|
| 52 |
+
"google": {
|
| 53 |
+
"budget": "gemini-2.0-flash-exp",
|
| 54 |
+
"premium": "gemini-2.0-flash-thinking-exp-1219"
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
# Load environment variables
|
| 59 |
+
load_dotenv(override=True)
|
| 60 |
+
|
| 61 |
+
class OCS4DevAssistant:
|
| 62 |
+
def __init__(self):
|
| 63 |
+
self.setup_environment()
|
| 64 |
+
self.setup_local_model()
|
| 65 |
+
self.setup_vector_store()
|
| 66 |
+
self.chat_history = []
|
| 67 |
+
self.current_provider = "local"
|
| 68 |
+
self.current_model_tier = "budget"
|
| 69 |
+
|
| 70 |
+
def setup_environment(self):
|
| 71 |
+
"""Setup environment variables - only Supabase required for vector store"""
|
| 72 |
+
# Supabase credentials (pre-configured by admin)
|
| 73 |
+
self.supabase_url = os.getenv('SUPABASE_URL')
|
| 74 |
+
self.supabase_key = os.getenv('SUPABASE_SERVICE_KEY')
|
| 75 |
+
|
| 76 |
+
if not self.supabase_url or not self.supabase_key:
|
| 77 |
+
print("β οΈ Supabase not configured. Vector search will be disabled.")
|
| 78 |
+
self.supabase_url = None
|
| 79 |
+
self.supabase_key = None
|
| 80 |
+
|
| 81 |
+
# API keys (provided by users in UI)
|
| 82 |
+
self.openai_api_key = os.getenv('OPENAI_API_KEY')
|
| 83 |
+
self.anthropic_api_key = os.getenv('ANTHROPIC_API_KEY')
|
| 84 |
+
self.google_api_key = os.getenv('GOOGLE_API_KEY')
|
| 85 |
+
|
| 86 |
+
def setup_local_model(self):
|
| 87 |
+
"""Initialize the local Qwen2.5-Coder model"""
|
| 88 |
+
print("π Loading Qwen2.5-Coder-7B-Instruct (AWQ quantized)...")
|
| 89 |
+
|
| 90 |
+
try:
|
| 91 |
+
# Check if CUDA is available
|
| 92 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 93 |
+
print(f"Using device: {device}")
|
| 94 |
+
|
| 95 |
+
# Load tokenizer
|
| 96 |
+
self.tokenizer = AutoTokenizer.from_pretrained(
|
| 97 |
+
DEFAULT_MODEL,
|
| 98 |
+
trust_remote_code=True
|
| 99 |
+
)
|
| 100 |
+
|
| 101 |
+
# Load quantized model
|
| 102 |
+
self.local_model = AutoModelForCausalLM.from_pretrained(
|
| 103 |
+
DEFAULT_MODEL,
|
| 104 |
+
torch_dtype=torch.float16 if device == "cuda" else torch.float32,
|
| 105 |
+
device_map="auto" if device == "cuda" else None,
|
| 106 |
+
trust_remote_code=True,
|
| 107 |
+
low_cpu_mem_usage=True
|
| 108 |
+
)
|
| 109 |
+
|
| 110 |
+
# Create pipeline for easier inference
|
| 111 |
+
self.local_pipeline = pipeline(
|
| 112 |
+
"text-generation",
|
| 113 |
+
model=self.local_model,
|
| 114 |
+
tokenizer=self.tokenizer,
|
| 115 |
+
torch_dtype=torch.float16 if device == "cuda" else torch.float32,
|
| 116 |
+
device_map="auto" if device == "cuda" else None,
|
| 117 |
+
max_new_tokens=1024,
|
| 118 |
+
temperature=0.3,
|
| 119 |
+
do_sample=True,
|
| 120 |
+
pad_token_id=self.tokenizer.eos_token_id
|
| 121 |
+
)
|
| 122 |
+
|
| 123 |
+
print("β
Local Qwen2.5-Coder model loaded successfully!")
|
| 124 |
+
|
| 125 |
+
except Exception as e:
|
| 126 |
+
print(f"β Error loading local model: {e}")
|
| 127 |
+
print("Model will be downloaded on first use...")
|
| 128 |
+
self.local_model = None
|
| 129 |
+
self.local_pipeline = None
|
| 130 |
+
self.tokenizer = None
|
| 131 |
+
|
| 132 |
+
def setup_vector_store(self):
|
| 133 |
+
"""Initialize vector store for retrieval only"""
|
| 134 |
+
if not self.supabase_url or not self.supabase_key:
|
| 135 |
+
self.vector_store = None
|
| 136 |
+
print("β οΈ Supabase credentials not found. Vector store disabled.")
|
| 137 |
+
print(" To enable, set SUPABASE_URL and SUPABASE_SERVICE_KEY environment variables.")
|
| 138 |
+
return
|
| 139 |
+
|
| 140 |
+
try:
|
| 141 |
+
self.supabase_client = create_client(self.supabase_url, self.supabase_key)
|
| 142 |
+
|
| 143 |
+
# Test connection and check if data exists
|
| 144 |
+
response = self.supabase_client.table("fintech_api_docs").select("count").execute()
|
| 145 |
+
doc_count = len(response.data) if response.data else 0
|
| 146 |
+
|
| 147 |
+
if doc_count == 0:
|
| 148 |
+
print("β οΈ Supabase connected but no documents found in the database.")
|
| 149 |
+
print(" Run the populate_supabase.py tool to add documents first.")
|
| 150 |
+
else:
|
| 151 |
+
print(f"β
Supabase connected! Documents available: {doc_count}")
|
| 152 |
+
|
| 153 |
+
# Use OpenAI embeddings for retrieval
|
| 154 |
+
# Note: This requires a valid OpenAI API key for similarity search
|
| 155 |
+
if self.openai_api_key:
|
| 156 |
+
self.embeddings = OpenAIEmbeddings(
|
| 157 |
+
model="text-embedding-3-small",
|
| 158 |
+
openai_api_key=self.openai_api_key
|
| 159 |
+
)
|
| 160 |
+
else:
|
| 161 |
+
print("β οΈ No OpenAI API key found. Using fallback embeddings.")
|
| 162 |
+
print(" For best results, provide an OpenAI API key.")
|
| 163 |
+
# Fallback: still create embeddings object but searches may not work properly
|
| 164 |
+
self.embeddings = OpenAIEmbeddings(
|
| 165 |
+
model="text-embedding-3-small",
|
| 166 |
+
openai_api_key="dummy-key"
|
| 167 |
+
)
|
| 168 |
+
|
| 169 |
+
# Initialize vector store as retriever only
|
| 170 |
+
self.vector_store = SupabaseVectorStore(
|
| 171 |
+
client=self.supabase_client,
|
| 172 |
+
embedding=self.embeddings,
|
| 173 |
+
table_name="fintech_api_docs",
|
| 174 |
+
query_name="match_documents"
|
| 175 |
+
)
|
| 176 |
+
|
| 177 |
+
print("β
Vector store initialized as retriever!")
|
| 178 |
+
|
| 179 |
+
except Exception as e:
|
| 180 |
+
print(f"β Vector store setup failed: {e}")
|
| 181 |
+
print(" Ensure your Supabase table 'fintech_api_docs' exists with proper schema.")
|
| 182 |
+
print(" Run the populate_supabase.py tool to set up the database.")
|
| 183 |
+
self.vector_store = None
|
| 184 |
+
|
| 185 |
+
def get_llm_instance(self, provider: str, tier: str, api_key: Optional[str] = None):
|
| 186 |
+
"""Get LLM instance based on provider and tier"""
|
| 187 |
+
if provider == "local":
|
| 188 |
+
return self.local_pipeline
|
| 189 |
+
|
| 190 |
+
if not api_key:
|
| 191 |
+
raise ValueError(f"API key required for {provider}")
|
| 192 |
+
|
| 193 |
+
model_name = MODEL_CONFIGS[provider][tier]
|
| 194 |
+
|
| 195 |
+
if provider == "openai":
|
| 196 |
+
return ChatOpenAI(
|
| 197 |
+
model=model_name,
|
| 198 |
+
temperature=0.3,
|
| 199 |
+
max_tokens=1000,
|
| 200 |
+
openai_api_key=api_key
|
| 201 |
+
)
|
| 202 |
+
elif provider == "anthropic":
|
| 203 |
+
return ChatAnthropic(
|
| 204 |
+
model=model_name,
|
| 205 |
+
temperature=0.3,
|
| 206 |
+
max_tokens=1000,
|
| 207 |
+
anthropic_api_key=api_key
|
| 208 |
+
)
|
| 209 |
+
elif provider == "google":
|
| 210 |
+
return ChatGoogleGenerativeAI(
|
| 211 |
+
model=model_name,
|
| 212 |
+
temperature=0.3,
|
| 213 |
+
max_output_tokens=1000,
|
| 214 |
+
google_api_key=api_key
|
| 215 |
+
)
|
| 216 |
+
else:
|
| 217 |
+
raise ValueError(f"Unsupported provider: {provider}")
|
| 218 |
+
|
| 219 |
+
def generate_local_response(self, prompt: str, context: str = "") -> str:
|
| 220 |
+
"""Generate response using local Qwen model"""
|
| 221 |
+
if not self.local_pipeline or not self.tokenizer:
|
| 222 |
+
# Try to load model if not loaded
|
| 223 |
+
self.setup_local_model()
|
| 224 |
+
|
| 225 |
+
if not self.local_pipeline or not self.tokenizer:
|
| 226 |
+
return "β Local model not available. Please use API providers or check your setup."
|
| 227 |
+
|
| 228 |
+
# Format prompt for Qwen2.5-Coder
|
| 229 |
+
system_prompt = f"""You are ocs4dev, a specialized fintech API integration assistant. You help developers integrate fintech APIs including MTN MoMo, Pesapal, and Sentezo.
|
| 230 |
+
|
| 231 |
+
Your expertise includes:
|
| 232 |
+
- API authentication and security
|
| 233 |
+
- Code examples and implementation
|
| 234 |
+
- Error handling and debugging
|
| 235 |
+
- Testing and best practices
|
| 236 |
+
- Payment gateway integration
|
| 237 |
+
|
| 238 |
+
Always provide practical, code-focused responses with examples.
|
| 239 |
+
|
| 240 |
+
Context: {context}"""
|
| 241 |
+
|
| 242 |
+
messages = [
|
| 243 |
+
{"role": "system", "content": system_prompt},
|
| 244 |
+
{"role": "user", "content": prompt}
|
| 245 |
+
]
|
| 246 |
+
|
| 247 |
+
# Apply chat template
|
| 248 |
+
formatted_prompt = self.tokenizer.apply_chat_template(
|
| 249 |
+
messages,
|
| 250 |
+
tokenize=False,
|
| 251 |
+
add_generation_prompt=True
|
| 252 |
+
)
|
| 253 |
+
|
| 254 |
+
try:
|
| 255 |
+
# Generate response
|
| 256 |
+
outputs = self.local_pipeline(
|
| 257 |
+
formatted_prompt,
|
| 258 |
+
max_new_tokens=1024,
|
| 259 |
+
temperature=0.3,
|
| 260 |
+
do_sample=True,
|
| 261 |
+
pad_token_id=self.tokenizer.eos_token_id
|
| 262 |
+
)
|
| 263 |
+
|
| 264 |
+
# Extract generated text
|
| 265 |
+
response = outputs[0]["generated_text"]
|
| 266 |
+
|
| 267 |
+
# Remove the input prompt from response
|
| 268 |
+
if formatted_prompt in response:
|
| 269 |
+
response = response.replace(formatted_prompt, "").strip()
|
| 270 |
+
|
| 271 |
+
return response
|
| 272 |
+
|
| 273 |
+
except Exception as e:
|
| 274 |
+
return f"β Error generating response: {str(e)}"
|
| 275 |
+
|
| 276 |
+
def get_retrieval_context(self, query: str) -> str:
|
| 277 |
+
"""Get relevant context from vector store"""
|
| 278 |
+
if not self.vector_store:
|
| 279 |
+
return ""
|
| 280 |
+
|
| 281 |
+
try:
|
| 282 |
+
docs = self.vector_store.similarity_search(query, k=TOP_K_DOCUMENTS)
|
| 283 |
+
context = "\n\n".join([doc.page_content for doc in docs])
|
| 284 |
+
return context
|
| 285 |
+
except Exception as e:
|
| 286 |
+
print(f"Error retrieving context: {e}")
|
| 287 |
+
return ""
|
| 288 |
+
|
| 289 |
+
def create_retrieval_chain(self, llm, provider: str):
|
| 290 |
+
"""Create retrieval chain for API models"""
|
| 291 |
+
if not self.vector_store:
|
| 292 |
+
return None
|
| 293 |
+
|
| 294 |
+
# Create retriever
|
| 295 |
+
retriever = self.vector_store.as_retriever(
|
| 296 |
+
search_type="similarity",
|
| 297 |
+
search_kwargs={"k": TOP_K_DOCUMENTS}
|
| 298 |
+
)
|
| 299 |
+
|
| 300 |
+
# Contextualize question prompt
|
| 301 |
+
contextualize_q_system_prompt = """
|
| 302 |
+
You are ocs4dev, a fintech API integration expert. Given a chat history and the latest user question
|
| 303 |
+
which might reference context in the chat history, formulate a standalone question
|
| 304 |
+
which can be understood without the chat history. Focus on fintech API integration.
|
| 305 |
+
|
| 306 |
+
Do NOT answer the question, just reformulate it if needed and otherwise return it as is.
|
| 307 |
+
"""
|
| 308 |
+
|
| 309 |
+
contextualize_q_prompt = ChatPromptTemplate.from_messages([
|
| 310 |
+
("system", contextualize_q_system_prompt),
|
| 311 |
+
MessagesPlaceholder("chat_history"),
|
| 312 |
+
("human", "{input}"),
|
| 313 |
+
])
|
| 314 |
+
|
| 315 |
+
# Create history-aware retriever
|
| 316 |
+
history_aware_retriever = create_history_aware_retriever(
|
| 317 |
+
llm, retriever, contextualize_q_prompt
|
| 318 |
+
)
|
| 319 |
+
|
| 320 |
+
# Question answering prompt
|
| 321 |
+
qa_system_prompt = """
|
| 322 |
+
You are ocs4dev, a specialized fintech API integration assistant. Use the following context
|
| 323 |
+
to help developers integrate fintech APIs (MTN MoMo, Pesapal, Sentezo, etc.).
|
| 324 |
+
|
| 325 |
+
Your responses should:
|
| 326 |
+
1. Be technically accurate and detailed
|
| 327 |
+
2. Include relevant code examples and snippets
|
| 328 |
+
3. Provide step-by-step implementation guidance
|
| 329 |
+
4. Include error handling best practices
|
| 330 |
+
5. Reference specific API endpoints and parameters
|
| 331 |
+
6. Suggest testing approaches
|
| 332 |
+
|
| 333 |
+
Format code blocks properly with language specification for syntax highlighting.
|
| 334 |
+
Always provide practical, actionable advice.
|
| 335 |
+
|
| 336 |
+
Context: {context}
|
| 337 |
+
"""
|
| 338 |
+
|
| 339 |
+
qa_prompt = ChatPromptTemplate.from_messages([
|
| 340 |
+
("system", qa_system_prompt),
|
| 341 |
+
MessagesPlaceholder("chat_history"),
|
| 342 |
+
("human", "{input}"),
|
| 343 |
+
])
|
| 344 |
+
|
| 345 |
+
# Create document chain
|
| 346 |
+
question_answer_chain = create_stuff_documents_chain(llm, qa_prompt)
|
| 347 |
+
|
| 348 |
+
# Create final RAG chain
|
| 349 |
+
rag_chain = create_retrieval_chain(history_aware_retriever, question_answer_chain)
|
| 350 |
+
|
| 351 |
+
return rag_chain
|
| 352 |
+
|
| 353 |
+
def update_model_config(self, provider: str, tier: str, api_key: str = None):
|
| 354 |
+
"""Update current model configuration"""
|
| 355 |
+
self.current_provider = provider
|
| 356 |
+
self.current_model_tier = tier
|
| 357 |
+
|
| 358 |
+
if provider != "local" and api_key:
|
| 359 |
+
if provider == "openai":
|
| 360 |
+
self.openai_api_key = api_key
|
| 361 |
+
elif provider == "anthropic":
|
| 362 |
+
self.anthropic_api_key = api_key
|
| 363 |
+
elif provider == "google":
|
| 364 |
+
self.google_api_key = api_key
|
| 365 |
+
|
| 366 |
+
def chat(self, message: str, history: List[Tuple[str, str]], provider: str, tier: str, api_key: str = None) -> str:
|
| 367 |
+
"""Main chat function - returns full response (streaming handled by Gradio)"""
|
| 368 |
+
try:
|
| 369 |
+
# Update model configuration
|
| 370 |
+
self.update_model_config(provider, tier, api_key)
|
| 371 |
+
|
| 372 |
+
if provider == "local":
|
| 373 |
+
# Use local model with context
|
| 374 |
+
context = self.get_retrieval_context(message)
|
| 375 |
+
return self.generate_local_response(message, context)
|
| 376 |
+
else:
|
| 377 |
+
# Use API model
|
| 378 |
+
api_key_map = {
|
| 379 |
+
"openai": self.openai_api_key,
|
| 380 |
+
"anthropic": self.anthropic_api_key,
|
| 381 |
+
"google": self.google_api_key
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
+
current_api_key = api_key or api_key_map.get(provider)
|
| 385 |
+
if not current_api_key:
|
| 386 |
+
return f"β No API key provided for {provider}. Please enter your API key in the settings."
|
| 387 |
+
|
| 388 |
+
# Get LLM instance
|
| 389 |
+
llm = self.get_llm_instance(provider, tier, current_api_key)
|
| 390 |
+
|
| 391 |
+
# Create retrieval chain
|
| 392 |
+
rag_chain = self.create_retrieval_chain(llm, provider)
|
| 393 |
+
|
| 394 |
+
if not rag_chain:
|
| 395 |
+
# Fallback to simple context if no vector store
|
| 396 |
+
context = self.get_retrieval_context(message)
|
| 397 |
+
simple_prompt = f"Context: {context}\n\nQuestion: {message}\n\nProvide a detailed response about fintech API integration."
|
| 398 |
+
return llm.invoke(simple_prompt).content
|
| 399 |
+
|
| 400 |
+
# Convert Gradio history to LangChain format
|
| 401 |
+
chat_history = []
|
| 402 |
+
for human, assistant in history:
|
| 403 |
+
chat_history.append(HumanMessage(content=human))
|
| 404 |
+
chat_history.append(AIMessage(content=assistant))
|
| 405 |
+
|
| 406 |
+
# Invoke RAG chain
|
| 407 |
+
response = rag_chain.invoke({
|
| 408 |
+
"input": message,
|
| 409 |
+
"chat_history": chat_history
|
| 410 |
+
})
|
| 411 |
+
|
| 412 |
+
return response["answer"]
|
| 413 |
+
|
| 414 |
+
except Exception as e:
|
| 415 |
+
return f"β Error processing request: {str(e)}"
|
| 416 |
+
|
| 417 |
+
def create_gradio_interface():
|
| 418 |
+
"""Create the Gradio interface optimized for HuggingFace Spaces"""
|
| 419 |
+
print("π Starting ocs4dev - Your Fintech API Integration Assistant")
|
| 420 |
+
|
| 421 |
+
# Initialize assistant
|
| 422 |
+
try:
|
| 423 |
+
assistant = OCS4DevAssistant()
|
| 424 |
+
print("β
ocs4dev initialized successfully!")
|
| 425 |
+
except Exception as e:
|
| 426 |
+
print(f"β Failed to initialize ocs4dev: {e}")
|
| 427 |
+
return None
|
| 428 |
+
|
| 429 |
+
# Custom CSS for better styling and copy buttons
|
| 430 |
+
custom_css = """
|
| 431 |
+
.warning-box {
|
| 432 |
+
background-color: #fff3cd;
|
| 433 |
+
border: 1px solid #ffeaa7;
|
| 434 |
+
border-radius: 8px;
|
| 435 |
+
padding: 12px;
|
| 436 |
+
margin: 10px 0;
|
| 437 |
+
font-size: 14px;
|
| 438 |
+
color: #856404 !important;
|
| 439 |
+
}
|
| 440 |
+
.model-info {
|
| 441 |
+
background-color: #e3f2fd;
|
| 442 |
+
border-left: 4px solid #2196f3;
|
| 443 |
+
padding: 12px;
|
| 444 |
+
margin: 10px 0;
|
| 445 |
+
border-radius: 4px;
|
| 446 |
+
color: #1565c0 !important;
|
| 447 |
+
}
|
| 448 |
+
.feature-box {
|
| 449 |
+
background-color: #f8f9fa;
|
| 450 |
+
border: 1px solid #dee2e6;
|
| 451 |
+
border-radius: 8px;
|
| 452 |
+
padding: 15px;
|
| 453 |
+
margin: 10px 0;
|
| 454 |
+
color: #212529 !important;
|
| 455 |
+
}
|
| 456 |
+
.code-block {
|
| 457 |
+
background-color: #f8f9fa;
|
| 458 |
+
border: 1px solid #e9ecef;
|
| 459 |
+
border-radius: 6px;
|
| 460 |
+
padding: 12px;
|
| 461 |
+
margin: 8px 0;
|
| 462 |
+
position: relative;
|
| 463 |
+
font-family: 'Courier New', monospace;
|
| 464 |
+
color: #212529 !important;
|
| 465 |
+
}
|
| 466 |
+
.copy-button {
|
| 467 |
+
position: absolute;
|
| 468 |
+
top: 8px;
|
| 469 |
+
right: 8px;
|
| 470 |
+
background: #007bff;
|
| 471 |
+
color: white;
|
| 472 |
+
border: none;
|
| 473 |
+
padding: 4px 8px;
|
| 474 |
+
border-radius: 4px;
|
| 475 |
+
cursor: pointer;
|
| 476 |
+
font-size: 12px;
|
| 477 |
+
}
|
| 478 |
+
.copy-button:hover {
|
| 479 |
+
background: #0056b3;
|
| 480 |
+
}
|
| 481 |
+
/* Hide Gradio footer */
|
| 482 |
+
.footer {
|
| 483 |
+
display: none !important;
|
| 484 |
+
}
|
| 485 |
+
|
| 486 |
+
/* Overlay backdrop */
|
| 487 |
+
.sidebar-backdrop {
|
| 488 |
+
position: fixed;
|
| 489 |
+
top: 0;
|
| 490 |
+
left: 0;
|
| 491 |
+
width: 100%;
|
| 492 |
+
height: 100%;
|
| 493 |
+
background: rgba(0, 0, 0, 0.5);
|
| 494 |
+
z-index: 999;
|
| 495 |
+
display: none;
|
| 496 |
+
}
|
| 497 |
+
|
| 498 |
+
.sidebar-backdrop.show {
|
| 499 |
+
display: block;
|
| 500 |
+
}
|
| 501 |
+
|
| 502 |
+
/* Sidebar as overlay */
|
| 503 |
+
.sidebar-container {
|
| 504 |
+
position: fixed;
|
| 505 |
+
left: 0;
|
| 506 |
+
top: 0;
|
| 507 |
+
height: 100vh;
|
| 508 |
+
width: 400px; /* Wider sidebar for better text display */
|
| 509 |
+
max-width: 90vw; /* Responsive on mobile */
|
| 510 |
+
background: var(--background-fill-primary);
|
| 511 |
+
border-right: 1px solid var(--border-color-primary);
|
| 512 |
+
transform: translateX(-100%);
|
| 513 |
+
transition: transform 0.3s ease;
|
| 514 |
+
z-index: 1000;
|
| 515 |
+
overflow-y: auto;
|
| 516 |
+
overflow-x: hidden;
|
| 517 |
+
padding: 20px;
|
| 518 |
+
padding-top: 60px; /* Space for close button */
|
| 519 |
+
box-sizing: border-box;
|
| 520 |
+
box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
|
| 521 |
+
}
|
| 522 |
+
|
| 523 |
+
.sidebar-container.open {
|
| 524 |
+
transform: translateX(0);
|
| 525 |
+
}
|
| 526 |
+
|
| 527 |
+
/* Fix white spaces in sidebar */
|
| 528 |
+
.sidebar-container .gr-form {
|
| 529 |
+
gap: 0 !important;
|
| 530 |
+
}
|
| 531 |
+
|
| 532 |
+
.sidebar-container .gr-box {
|
| 533 |
+
border: none !important;
|
| 534 |
+
background: transparent !important;
|
| 535 |
+
}
|
| 536 |
+
|
| 537 |
+
.sidebar-container .gr-padded {
|
| 538 |
+
padding: 8px !important;
|
| 539 |
+
}
|
| 540 |
+
|
| 541 |
+
.sidebar-container .gr-panel {
|
| 542 |
+
background: var(--background-fill-secondary) !important;
|
| 543 |
+
padding: 12px !important;
|
| 544 |
+
border-radius: 8px;
|
| 545 |
+
margin-bottom: 12px;
|
| 546 |
+
}
|
| 547 |
+
|
| 548 |
+
/* Style sidebar content */
|
| 549 |
+
.sidebar-container h2 {
|
| 550 |
+
color: var(--body-text-color) !important;
|
| 551 |
+
margin-bottom: 20px;
|
| 552 |
+
font-size: 1.5rem;
|
| 553 |
+
}
|
| 554 |
+
|
| 555 |
+
.sidebar-container .gr-markdown h2 {
|
| 556 |
+
color: var(--body-text-color) !important;
|
| 557 |
+
margin-top: 0;
|
| 558 |
+
}
|
| 559 |
+
|
| 560 |
+
/* Remove unwanted white borders and backgrounds */
|
| 561 |
+
.sidebar-container .gradio-container {
|
| 562 |
+
background: transparent !important;
|
| 563 |
+
border: none !important;
|
| 564 |
+
}
|
| 565 |
+
|
| 566 |
+
.sidebar-container .gr-form {
|
| 567 |
+
background: transparent !important;
|
| 568 |
+
border: none !important;
|
| 569 |
+
gap: 12px !important;
|
| 570 |
+
}
|
| 571 |
+
|
| 572 |
+
.sidebar-container .gr-input-wrapper {
|
| 573 |
+
margin: 0 !important;
|
| 574 |
+
}
|
| 575 |
+
|
| 576 |
+
.sidebar-container .gr-group {
|
| 577 |
+
background: var(--background-fill-secondary) !important;
|
| 578 |
+
border: 1px solid var(--border-color-primary) !important;
|
| 579 |
+
border-radius: 8px;
|
| 580 |
+
padding: 12px;
|
| 581 |
+
margin-bottom: 12px;
|
| 582 |
+
}
|
| 583 |
+
|
| 584 |
+
/* Ensure text visibility in sidebar */
|
| 585 |
+
.sidebar-container * {
|
| 586 |
+
color: var(--body-text-color) !important;
|
| 587 |
+
}
|
| 588 |
+
|
| 589 |
+
.sidebar-title {
|
| 590 |
+
font-size: 1.5rem !important;
|
| 591 |
+
font-weight: bold !important;
|
| 592 |
+
margin-bottom: 20px !important;
|
| 593 |
+
color: var(--body-text-color) !important;
|
| 594 |
+
}
|
| 595 |
+
|
| 596 |
+
.sidebar-toggle {
|
| 597 |
+
position: fixed;
|
| 598 |
+
left: 20px;
|
| 599 |
+
top: 20px;
|
| 600 |
+
z-index: 998;
|
| 601 |
+
background: var(--button-primary-background-fill);
|
| 602 |
+
color: var(--button-primary-text-color);
|
| 603 |
+
border: none;
|
| 604 |
+
padding: 12px 16px;
|
| 605 |
+
border-radius: 8px;
|
| 606 |
+
cursor: pointer;
|
| 607 |
+
font-size: 18px;
|
| 608 |
+
transition: all 0.3s ease;
|
| 609 |
+
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
| 610 |
+
}
|
| 611 |
+
|
| 612 |
+
.sidebar-toggle:hover {
|
| 613 |
+
background: var(--button-primary-background-fill-hover);
|
| 614 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
|
| 615 |
+
}
|
| 616 |
+
|
| 617 |
+
.sidebar-close {
|
| 618 |
+
position: absolute;
|
| 619 |
+
right: 20px;
|
| 620 |
+
top: 20px;
|
| 621 |
+
background: transparent;
|
| 622 |
+
border: none;
|
| 623 |
+
font-size: 24px;
|
| 624 |
+
cursor: pointer;
|
| 625 |
+
color: var(--body-text-color);
|
| 626 |
+
padding: 5px;
|
| 627 |
+
border-radius: 4px;
|
| 628 |
+
transition: background 0.2s ease;
|
| 629 |
+
z-index: 1001;
|
| 630 |
+
}
|
| 631 |
+
|
| 632 |
+
.sidebar-close:hover {
|
| 633 |
+
background: var(--background-fill-secondary);
|
| 634 |
+
}
|
| 635 |
+
|
| 636 |
+
/* Main content stays in place */
|
| 637 |
+
.main-content {
|
| 638 |
+
min-height: 100vh;
|
| 639 |
+
padding-left: 70px; /* Space for menu button */
|
| 640 |
+
}
|
| 641 |
+
|
| 642 |
+
/* Custom chat styling */
|
| 643 |
+
.chat-container {
|
| 644 |
+
max-width: 100%;
|
| 645 |
+
margin: 0 auto;
|
| 646 |
+
padding: 20px;
|
| 647 |
+
}
|
| 648 |
+
|
| 649 |
+
/* Dark mode specific fixes */
|
| 650 |
+
.dark .sidebar-container {
|
| 651 |
+
background: var(--background-fill-primary);
|
| 652 |
+
}
|
| 653 |
+
|
| 654 |
+
.dark .warning-box {
|
| 655 |
+
background-color: #2d2d2d;
|
| 656 |
+
border: 1px solid #ffc107;
|
| 657 |
+
color: #ffc107 !important;
|
| 658 |
+
}
|
| 659 |
+
.dark .model-info {
|
| 660 |
+
background-color: #1a1a1a;
|
| 661 |
+
border-left: 4px solid #64b5f6;
|
| 662 |
+
color: #64b5f6 !important;
|
| 663 |
+
}
|
| 664 |
+
.dark .feature-box {
|
| 665 |
+
background-color: #2d2d2d;
|
| 666 |
+
border: 1px solid #495057;
|
| 667 |
+
color: #e9ecef !important;
|
| 668 |
+
}
|
| 669 |
+
|
| 670 |
+
/* Responsive adjustments */
|
| 671 |
+
@media (max-width: 768px) {
|
| 672 |
+
.sidebar-container {
|
| 673 |
+
width: 85vw;
|
| 674 |
+
}
|
| 675 |
+
.main-content {
|
| 676 |
+
padding-left: 60px;
|
| 677 |
+
}
|
| 678 |
+
}
|
| 679 |
+
"""
|
| 680 |
+
|
| 681 |
+
# Create the interface
|
| 682 |
+
def chat_with_config(message, history, provider, tier, openai_key, anthropic_key, google_key):
|
| 683 |
+
"""Chat function with configuration"""
|
| 684 |
+
api_key = None
|
| 685 |
+
if provider == "openai":
|
| 686 |
+
api_key = openai_key
|
| 687 |
+
elif provider == "anthropic":
|
| 688 |
+
api_key = anthropic_key
|
| 689 |
+
elif provider == "google":
|
| 690 |
+
api_key = google_key
|
| 691 |
+
|
| 692 |
+
return assistant.chat(message, history, provider, tier, api_key)
|
| 693 |
+
|
| 694 |
+
# Create interface
|
| 695 |
+
with gr.Blocks(
|
| 696 |
+
title="ocs4dev - Fintech API Assistant",
|
| 697 |
+
theme=gr.themes.Soft(
|
| 698 |
+
primary_hue="blue",
|
| 699 |
+
secondary_hue="gray",
|
| 700 |
+
neutral_hue="slate",
|
| 701 |
+
),
|
| 702 |
+
css=custom_css,
|
| 703 |
+
fill_height=True,
|
| 704 |
+
js="""
|
| 705 |
+
function() {
|
| 706 |
+
// Add sidebar toggle functionality with backdrop
|
| 707 |
+
const backdrop = document.createElement('div');
|
| 708 |
+
backdrop.className = 'sidebar-backdrop';
|
| 709 |
+
document.body.appendChild(backdrop);
|
| 710 |
+
|
| 711 |
+
const toggleButton = document.createElement('button');
|
| 712 |
+
toggleButton.innerHTML = 'β°';
|
| 713 |
+
toggleButton.className = 'sidebar-toggle';
|
| 714 |
+
toggleButton.title = 'Open Settings';
|
| 715 |
+
|
| 716 |
+
const sidebar = document.querySelector('.sidebar-container');
|
| 717 |
+
|
| 718 |
+
// Add close button to sidebar
|
| 719 |
+
const closeButton = document.createElement('button');
|
| 720 |
+
closeButton.innerHTML = 'β';
|
| 721 |
+
closeButton.className = 'sidebar-close';
|
| 722 |
+
closeButton.title = 'Close Settings';
|
| 723 |
+
sidebar.insertBefore(closeButton, sidebar.firstChild);
|
| 724 |
+
|
| 725 |
+
function openSidebar() {
|
| 726 |
+
sidebar.classList.add('open');
|
| 727 |
+
backdrop.classList.add('show');
|
| 728 |
+
document.body.style.overflow = 'hidden';
|
| 729 |
+
}
|
| 730 |
+
|
| 731 |
+
function closeSidebar() {
|
| 732 |
+
sidebar.classList.remove('open');
|
| 733 |
+
backdrop.classList.remove('show');
|
| 734 |
+
document.body.style.overflow = '';
|
| 735 |
+
}
|
| 736 |
+
|
| 737 |
+
toggleButton.onclick = openSidebar;
|
| 738 |
+
closeButton.onclick = closeSidebar;
|
| 739 |
+
backdrop.onclick = closeSidebar;
|
| 740 |
+
|
| 741 |
+
// ESC key to close
|
| 742 |
+
document.addEventListener('keydown', (e) => {
|
| 743 |
+
if (e.key === 'Escape' && sidebar.classList.contains('open')) {
|
| 744 |
+
closeSidebar();
|
| 745 |
+
}
|
| 746 |
+
});
|
| 747 |
+
|
| 748 |
+
document.body.appendChild(toggleButton);
|
| 749 |
+
}
|
| 750 |
+
"""
|
| 751 |
+
) as interface:
|
| 752 |
+
|
| 753 |
+
# Header
|
| 754 |
+
with gr.Column(elem_classes="main-content"):
|
| 755 |
+
gr.Markdown("# π¦ ocs4dev - Your Fintech API Integration Assistant")
|
| 756 |
+
gr.Markdown("*Specialized AI assistant for integrating fintech APIs including MTN MoMo, Airtel, Pesapal, Sentezo, etc*")
|
| 757 |
+
|
| 758 |
+
# Main chat interface
|
| 759 |
+
chatbot = gr.Chatbot(
|
| 760 |
+
height=500,
|
| 761 |
+
placeholder="Ask me about fintech API integration, authentication, code examples, or best practices...",
|
| 762 |
+
label="ocs4dev Assistant",
|
| 763 |
+
show_copy_button=True, # Enable copy button for chat messages
|
| 764 |
+
render_markdown=True,
|
| 765 |
+
elem_classes="chat-container"
|
| 766 |
+
)
|
| 767 |
+
|
| 768 |
+
msg = gr.Textbox(
|
| 769 |
+
placeholder="How do I authenticate with MTN MoMo API?",
|
| 770 |
+
label="Your Question",
|
| 771 |
+
lines=2,
|
| 772 |
+
show_copy_button=True # Enable copy button for input
|
| 773 |
+
)
|
| 774 |
+
|
| 775 |
+
with gr.Row():
|
| 776 |
+
clear = gr.Button("Clear", variant="secondary")
|
| 777 |
+
submit = gr.Button("Send", variant="primary")
|
| 778 |
+
|
| 779 |
+
# Example questions
|
| 780 |
+
gr.Examples(
|
| 781 |
+
examples=[
|
| 782 |
+
"How do I authenticate with MTN MoMo API?",
|
| 783 |
+
"Show me a Pesapal payment integration example",
|
| 784 |
+
"What are the required headers for Sentezo API?",
|
| 785 |
+
"How do I handle payment webhooks?",
|
| 786 |
+
"Best practices for API error handling",
|
| 787 |
+
"How to test API integrations in sandbox mode?",
|
| 788 |
+
"Show me a complete payment flow implementation",
|
| 789 |
+
"How to secure API keys in production?",
|
| 790 |
+
"What's the difference between sandbox and production?",
|
| 791 |
+
"How do I implement payment status callbacks?"
|
| 792 |
+
],
|
| 793 |
+
inputs=msg,
|
| 794 |
+
label="π‘ Example Questions"
|
| 795 |
+
)
|
| 796 |
+
|
| 797 |
+
# Sidebar (hidden by default)
|
| 798 |
+
with gr.Column(elem_classes="sidebar-container", elem_id="settings-sidebar"):
|
| 799 |
+
gr.Markdown("## βοΈ Configuration", elem_classes="sidebar-title")
|
| 800 |
+
|
| 801 |
+
# Model provider selection
|
| 802 |
+
with gr.Group():
|
| 803 |
+
provider = gr.Radio(
|
| 804 |
+
choices=["local", "openai", "anthropic", "google"],
|
| 805 |
+
value="local",
|
| 806 |
+
label="Model Provider",
|
| 807 |
+
info="Local model is free but requires GPU. API models need keys.",
|
| 808 |
+
elem_classes="provider-selector"
|
| 809 |
+
)
|
| 810 |
+
|
| 811 |
+
tier = gr.Radio(
|
| 812 |
+
choices=["budget", "premium"],
|
| 813 |
+
value="budget",
|
| 814 |
+
label="Model Tier",
|
| 815 |
+
info="Budget models are faster/cheaper, Premium models are more capable",
|
| 816 |
+
elem_classes="tier-selector"
|
| 817 |
+
)
|
| 818 |
+
|
| 819 |
+
# API Keys Section
|
| 820 |
+
with gr.Accordion("π API Keys", open=True, elem_classes="api-keys-section"):
|
| 821 |
+
gr.HTML('<div class="warning-box">β οΈ <strong>Security Warning:</strong> Create test API keys for this app and delete them after use. Never share production keys.</div>')
|
| 822 |
+
|
| 823 |
+
with gr.Group():
|
| 824 |
+
openai_key = gr.Textbox(
|
| 825 |
+
placeholder="sk-...",
|
| 826 |
+
label="OpenAI API Key",
|
| 827 |
+
type="password",
|
| 828 |
+
info="Budget: gpt-4o-mini | Premium: o4-mini (advanced reasoning)",
|
| 829 |
+
elem_classes="api-key-input"
|
| 830 |
+
)
|
| 831 |
+
|
| 832 |
+
anthropic_key = gr.Textbox(
|
| 833 |
+
placeholder="sk-ant-...",
|
| 834 |
+
label="Anthropic API Key",
|
| 835 |
+
type="password",
|
| 836 |
+
info="Budget: claude-3.5-sonnet | Premium: claude-4-sonnet",
|
| 837 |
+
elem_classes="api-key-input"
|
| 838 |
+
)
|
| 839 |
+
|
| 840 |
+
google_key = gr.Textbox(
|
| 841 |
+
placeholder="AI...",
|
| 842 |
+
label="Google API Key",
|
| 843 |
+
type="password",
|
| 844 |
+
info="Budget: gemini-2.0-flash | Premium: gemini-2.0-flash-thinking",
|
| 845 |
+
elem_classes="api-key-input"
|
| 846 |
+
)
|
| 847 |
+
|
| 848 |
+
# Updated model information
|
| 849 |
+
gr.HTML('<div class="model-info">π <strong>Pro Tip:</strong> Add your API keys above for faster and better responses. Local model works but API models provide superior performance!</div>')
|
| 850 |
+
|
| 851 |
+
# Features
|
| 852 |
+
with gr.Accordion("β¨ Features", open=False, elem_classes="features-section"):
|
| 853 |
+
gr.HTML('''
|
| 854 |
+
<div class="feature-box">
|
| 855 |
+
<strong>π§ Code-Focused:</strong> Optimized for API integration tasks<br>
|
| 856 |
+
<strong>π Secure:</strong> No API keys stored permanently<br>
|
| 857 |
+
<strong>π Copy-Friendly:</strong> Easy code copying with built-in buttons<br>
|
| 858 |
+
<strong>π Fast:</strong> Multiple model options for best performance<br>
|
| 859 |
+
<strong>π Multi-Provider:</strong> Switch between AI models seamlessly
|
| 860 |
+
</div>
|
| 861 |
+
''')
|
| 862 |
+
|
| 863 |
+
# Chat functionality with simple response
|
| 864 |
+
def respond(message, history, provider, tier, openai_key, anthropic_key, google_key):
|
| 865 |
+
"""Handle chat responses with simulated streaming"""
|
| 866 |
+
if not message:
|
| 867 |
+
return history, ""
|
| 868 |
+
|
| 869 |
+
# Add user message to history
|
| 870 |
+
history = history or []
|
| 871 |
+
|
| 872 |
+
# Get the full response
|
| 873 |
+
bot_message = chat_with_config(message, history, provider, tier, openai_key, anthropic_key, google_key)
|
| 874 |
+
|
| 875 |
+
# Simulate streaming by yielding partial responses
|
| 876 |
+
partial = ""
|
| 877 |
+
words = bot_message.split(" ")
|
| 878 |
+
|
| 879 |
+
# Stream words in chunks for smooth appearance
|
| 880 |
+
chunk_size = 3 # Words per chunk
|
| 881 |
+
for i in range(0, len(words), chunk_size):
|
| 882 |
+
chunk = " ".join(words[i:i+chunk_size])
|
| 883 |
+
partial += chunk + " "
|
| 884 |
+
yield history + [(message, partial.strip())], ""
|
| 885 |
+
|
| 886 |
+
# Final update with complete response
|
| 887 |
+
yield history + [(message, bot_message)], ""
|
| 888 |
+
|
| 889 |
+
# Connect the interface
|
| 890 |
+
submit.click(
|
| 891 |
+
respond,
|
| 892 |
+
inputs=[msg, chatbot, provider, tier, openai_key, anthropic_key, google_key],
|
| 893 |
+
outputs=[chatbot, msg]
|
| 894 |
+
)
|
| 895 |
+
|
| 896 |
+
msg.submit(
|
| 897 |
+
respond,
|
| 898 |
+
inputs=[msg, chatbot, provider, tier, openai_key, anthropic_key, google_key],
|
| 899 |
+
outputs=[chatbot, msg]
|
| 900 |
+
)
|
| 901 |
+
|
| 902 |
+
clear.click(lambda: ([], ""), outputs=[chatbot, msg])
|
| 903 |
+
|
| 904 |
+
# Footer
|
| 905 |
+
gr.Markdown("---")
|
| 906 |
+
gr.Markdown("Built with β€οΈ by Aaron | Using Qwen2.5-Coder, LangChain, and Gradio | [GitHub](https://github.com/aaron-official/ocs4dev.git)")
|
| 907 |
+
|
| 908 |
+
return interface
|
| 909 |
+
|
| 910 |
+
def populate_knowledge_base_standalone():
|
| 911 |
+
"""[DEPRECATED] Use the separate populate_supabase.py tool instead"""
|
| 912 |
+
print("β οΈ This function is deprecated!")
|
| 913 |
+
print(" Please use the separate 'populate_supabase.py' tool to populate the vector database.")
|
| 914 |
+
print(" ")
|
| 915 |
+
print(" Usage:")
|
| 916 |
+
print(" $ python populate_supabase.py --knowledge-base ./knowledge-base")
|
| 917 |
+
print(" ")
|
| 918 |
+
print(" The tool will:")
|
| 919 |
+
print(" 1. Load all markdown files from your knowledge base directory")
|
| 920 |
+
print(" 2. Split them into chunks for better retrieval")
|
| 921 |
+
print(" 3. Generate embeddings using OpenAI")
|
| 922 |
+
print(" 4. Store everything in your Supabase vector database")
|
| 923 |
+
print(" ")
|
| 924 |
+
print(" Make sure you have set these environment variables:")
|
| 925 |
+
print(" - SUPABASE_URL")
|
| 926 |
+
print(" - SUPABASE_SERVICE_KEY")
|
| 927 |
+
print(" - OPENAI_API_KEY")
|
| 928 |
+
return False
|
| 929 |
+
|
| 930 |
+
def main():
|
| 931 |
+
"""Main function optimized for HuggingFace Spaces"""
|
| 932 |
+
interface = create_gradio_interface()
|
| 933 |
+
if interface:
|
| 934 |
+
# HuggingFace Spaces optimized launch
|
| 935 |
+
interface.launch(
|
| 936 |
+
server_name="0.0.0.0",
|
| 937 |
+
server_port=7860,
|
| 938 |
+
share=True, # Enable public URL for HF Spaces
|
| 939 |
+
inbrowser=False, # Don't open browser in server environment
|
| 940 |
+
show_error=True,
|
| 941 |
+
quiet=False,
|
| 942 |
+
max_threads=10 # Limit concurrent requests
|
| 943 |
+
)
|
| 944 |
+
|
| 945 |
+
if __name__ == "__main__":
|
| 946 |
+
main()
|
requirements.txt
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Core Dependencies (IMPORTANT: transformers>=4.37.0 required for Qwen2.5-Coder)
|
| 2 |
+
transformers==4.53.2
|
| 3 |
+
torch==2.6.0
|
| 4 |
+
accelerate==1.8.1
|
| 5 |
+
huggingface-hub==0.33.4
|
| 6 |
+
|
| 7 |
+
# LangChain (updated to avoid deprecation warnings)
|
| 8 |
+
langchain==0.3.26
|
| 9 |
+
langchain-community==0.3.27
|
| 10 |
+
langchain-core==0.3.69
|
| 11 |
+
langchain-text-splitters==0.3.8
|
| 12 |
+
|
| 13 |
+
# Multi-provider LLM support
|
| 14 |
+
langchain-openai==0.3.28
|
| 15 |
+
langchain-anthropic==0.3.17
|
| 16 |
+
langchain-google-genai==2.1.8
|
| 17 |
+
|
| 18 |
+
# Supabase
|
| 19 |
+
supabase==2.16.0
|
| 20 |
+
vecs==0.4.5
|
| 21 |
+
|
| 22 |
+
# UI Framework
|
| 23 |
+
gradio==5.31.0
|
| 24 |
+
|
| 25 |
+
# Utilities
|
| 26 |
+
python-dotenv==1.1.1
|
| 27 |
+
numpy==2.0.2
|
| 28 |
+
sentence-transformers==4.1.0
|
| 29 |
+
|
| 30 |
+
# Quantization and Performance
|
| 31 |
+
bitsandbytes==0.46.1 # For 8-bit quantization
|
| 32 |
+
auto-gptq==0.7.1 # For GPTQ quantization
|
| 33 |
+
autoawq==0.2.9 # For AWQ quantization
|
| 34 |
+
intel_extension_for_pytorch==2.7.0 # Intel optimization for PyTorch
|