4c084d76686a0bf7300faccfef853a078dc9fdf2
Implement AskSageAdapter using the official asksageclient SDK to support AskSage as an LLM provider option. This enables users to leverage AskSage's API with configurable email, API key, and model settings. - Add AskSageAdapter class with async support via thread pool - Update Settings to include asksage_email, asksage_api_key, asksage_model - Extend llm_mode literal to include "asksage" option - Update dependency injection to instantiate AskSageAdapter when configured - Remove completed OPENAI_INTEGRATION_PLAN.md - Update requirements.txt with full dependency list including asksageclient
Tyndale AI Service
LLM Chat Service for algorithmic trading support - codebase Q&A, P&L summarization, and strategy enhancement suggestions.
Quick Start
Local Development
# Install dependencies
pip install -r requirements.txt
# Run the server
uvicorn app.main:app --reload --port 8080
Docker
# Build
docker build -t tyndale-ai-service .
# Run
docker run -p 8080:8080 -e LLM_MODE=local tyndale-ai-service
API Endpoints
Health Check
curl http://localhost:8080/health
Response:
{"status": "ok"}
Chat
curl -X POST http://localhost:8080/chat \
-H "Content-Type: application/json" \
-d '{"message": "Hello, how are you?"}'
Response:
{
"conversation_id": "uuid-generated-if-not-provided",
"response": "...",
"mode": "local",
"sources": []
}
With conversation ID:
curl -X POST http://localhost:8080/chat \
-H "Content-Type: application/json" \
-d '{"message": "Follow up question", "conversation_id": "my-conversation-123"}'
Environment Variables
| Variable | Description | Default |
|---|---|---|
LLM_MODE |
local or remote |
local |
LLM_REMOTE_URL |
Remote LLM endpoint URL | (empty) |
LLM_REMOTE_TOKEN |
Bearer token for remote LLM | (empty) |
Remote Mode Setup
export LLM_MODE=remote
export LLM_REMOTE_URL=https://your-llm-service.com/generate
export LLM_REMOTE_TOKEN=your-api-token
uvicorn app.main:app --reload --port 8080
The remote adapter expects the LLM service to accept:
{"conversation_id": "...", "message": "..."}
And return:
{"response": "..."}
Project Structure
tyndale-ai-service/
├── app/
│ ├── __init__.py
│ ├── main.py # FastAPI app + routes
│ ├── schemas.py # Pydantic models
│ ├── config.py # Environment config
│ └── llm/
│ ├── __init__.py
│ └── adapter.py # LLM adapter interface + implementations
├── requirements.txt
├── Dockerfile
├── .env.example
└── README.md
Features
- Dual mode operation: Local stub or remote LLM
- Conversation tracking: UUID generation for new conversations
- Security: 10,000 character message limit, no content logging
- Cloud Run ready: Port 8080, stateless design
- Async: Full async/await support with httpx
Description
Languages
Python
99.3%
Dockerfile
0.7%