Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ This two-phase approach ensures that the solutions are not just generic LLM resp

- **140 Thinking Models**: A comprehensive library of thinking models, from SWOT analysis to second-order thinking.
- **Two-Phase Query Processing**: Enhances LLM responses with structured problem-solving methodologies.
- **OpenAI-Compatible API**: Integrates with any OpenAI-compatible LLM API.
- **Multi-LLM-Backend Support**: Integrates with multiple LLM providers, including OpenAI and Google Gemini.
- **CLI & Web Interfaces**: Access the system through a command-line interface or a modern web application.
- **Real-time Updates**: Get live feedback during query processing via WebSockets.
- **Model Browser**: Explore, search, and filter thinking models through the web UI.
Expand All @@ -60,7 +60,7 @@ This two-phase approach ensures that the solutions are not just generic LLM resp

- Python 3.8+
- `pip` for package management
- An OpenAI-compatible LLM API endpoint
- An API endpoint and key for an OpenAI-compatible service or Google Gemini.

### Installation

Expand All @@ -79,9 +79,13 @@ This two-phase approach ensures that the solutions are not just generic LLM resp

3. **Configure your LLM API:**

Create a `.env` file in the project root and add your API credentials:
Create a `.env` file in the project root. Below are examples for configuring OpenAI and Gemini providers.

**For OpenAI-Compatible APIs:**
```env
# Set the provider to openai (this is the default)
LLM_PROVIDER=openai

# Required
LLM_API_URL=https://your-llm-api-endpoint.com

Expand All @@ -90,6 +94,18 @@ This two-phase approach ensures that the solutions are not just generic LLM resp
LLM_MODEL_NAME=gpt-3.5-turbo
```

**For Google Gemini:**
```env
# Set the provider to gemini
LLM_PROVIDER=gemini

# Required - your Gemini API key
GEMINI_API_KEY=your-gemini-api-key

# Optional - specify a Gemini model
LLM_MODEL_NAME=gemini-1.5-flash
```

---

## Usage
Expand Down
4 changes: 4 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class Config:
# LLM API Settings
llm_api_url: Optional[str] = None
llm_api_key: Optional[str] = None
gemini_api_key: Optional[str] = None
llm_provider: str = "openai"
llm_model_name: str = "gpt-3.5-turbo"
llm_temperature: float = 0.7
llm_max_tokens: int = 2000
Expand Down Expand Up @@ -53,6 +55,8 @@ def from_env(cls) -> 'Config':
# LLM API Settings
llm_api_url=os.getenv('LLM_API_URL'),
llm_api_key=os.getenv('LLM_API_KEY'),
gemini_api_key=os.getenv('GEMINI_API_KEY'),
llm_provider=os.getenv('LLM_PROVIDER', 'openai'),
llm_model_name=os.getenv('LLM_MODEL_NAME', 'gpt-3.5-turbo'),
llm_temperature=float(os.getenv('LLM_TEMPERATURE', '0.7')),
llm_max_tokens=int(os.getenv('LLM_MAX_TOKENS', '2000')),
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Core dependencies
requests>=2.28.0
dataclasses-json>=0.5.7
google-generativeai>=0.8.5

# CLI dependencies
click>=8.0.0
Expand All @@ -9,7 +10,7 @@ rich>=13.0.0

# Web dependencies
fastapi>=0.100.0
uvicorn>=0.23.0
uvicorn[standard]>=0.23.0
jinja2>=3.0.0
python-multipart>=0.0.5

Expand Down
37 changes: 10 additions & 27 deletions src/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
sys.path.insert(0, str(Path(__file__).parent.parent))

from core.model_parser import ModelParser
from core.llm_client import LLMClient, LLMConfig
from core.llm_client import get_llm_client
from core.query_processor import QueryProcessor, QueryResult

# Initialize Rich console for pretty output
Expand Down Expand Up @@ -64,44 +64,27 @@ def from_env(cls):
def setup_processor(config: CLIConfig) -> Optional[QueryProcessor]:
"""Initialize the query processor with given configuration"""
try:
# Load models
if config.verbose:
console.print(f"[blue]Loading thinking models from {config.models_dir}...[/blue]")

model_parser = ModelParser(config.models_dir)
models = model_parser.load_all_models()

if config.verbose:
console.print(f"[green]✓ Loaded {len(models)} thinking models[/green]")

# Setup LLM client
if not config.api_url:
console.print("[red]Error: LLM_API_URL environment variable must be set[/red]")
return None

llm_config = LLMConfig(
api_url=config.api_url,
api_key=config.api_key,
model_name=config.model_name,
temperature=config.temperature,
max_tokens=config.max_tokens
)

llm_client = LLMClient(llm_config)

# Test connection if in verbose mode

# Get LLM client from factory
llm_client = get_llm_client()

if config.verbose:
console.print("[blue]Testing LLM connection...[/blue]")
if llm_client.test_connection():
console.print("[green]✓ LLM connection successful[/green]")
else:
console.print("[yellow]⚠ LLM connection test failed, but continuing anyway[/yellow]")

# Create query processor
processor = QueryProcessor(model_parser, llm_client)

return processor


return QueryProcessor(model_parser, llm_client)

except Exception as e:
console.print(f"[red]Error initializing processor: {str(e)}[/red]")
return None
Expand Down
Loading