disable local models for now
Browse files- app.py +115 -113
- core/ollama_models.py +1 -1
app.py
CHANGED
|
@@ -13,12 +13,12 @@ from core.code_loader_demo import CodeLoader
|
|
| 13 |
from core.llm_demo import LLM
|
| 14 |
from core.model_config import (
|
| 15 |
PROVIDER_PRESETS,
|
| 16 |
-
create_local_model_config,
|
| 17 |
create_provider_model_config,
|
| 18 |
get_api_key_env_name,
|
| 19 |
get_provider_from_model,
|
| 20 |
)
|
| 21 |
-
from core.ollama_models import fetch_ollama_models
|
| 22 |
from core.openrouter_models import fetch_free_models, get_model_config
|
| 23 |
from core.prompt_demo import Prompt
|
| 24 |
from core.token_counter_demo import TokenCounter
|
|
@@ -392,11 +392,10 @@ def main():
|
|
| 392 |
|
| 393 |
**LLM Provider Recommendations:**
|
| 394 |
- **Free Models (OpenRouter)**: Best for quick checks of already public paper+code combinations
|
| 395 |
-
- **Local Models (Ollama/vLLM)**: Best for privacy-sensitive content, e.g. for unpublished papers or code
|
| 396 |
- **Provider Models (OpenAI, Anthropic, etc.)**: Best for high precision and best recall
|
| 397 |
|
| 398 |
**Features:**
|
| 399 |
-
- Support for multiple LLM providers (free
|
| 400 |
- Automatic content fetching from arXiv and GitHub
|
| 401 |
- File upload support for custom papers and repositories
|
| 402 |
- Secure API key handling (keys never stored or logged)
|
|
@@ -440,8 +439,10 @@ def main():
|
|
| 440 |
# Model type selection
|
| 441 |
model_type = st.radio(
|
| 442 |
"Model Type",
|
| 443 |
-
options=["Free Models (OpenRouter)", "
|
| 444 |
-
|
|
|
|
|
|
|
| 445 |
key="model_type_radio",
|
| 446 |
index=0, # Default to Free Models
|
| 447 |
)
|
|
@@ -467,7 +468,7 @@ def main():
|
|
| 467 |
# Show privacy warning
|
| 468 |
st.warning(
|
| 469 |
"⚠️ **Privacy Notice**: Free models are provided via [OpenRouter](https://openrouter.ai). "
|
| 470 |
-
"The model provider may log your prompts and outputs. For enhanced privacy, consider using
|
| 471 |
)
|
| 472 |
# Create model options from fetched models
|
| 473 |
model_options = {get_model_config(m)["name"]: get_model_config(m) for m in free_models_raw}
|
|
@@ -494,112 +495,113 @@ def main():
|
|
| 494 |
st.error("⚠️ No free models available. Please try again later or use a different model type.")
|
| 495 |
model_config = None
|
| 496 |
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
|
| 567 |
-
|
| 568 |
-
|
| 569 |
-
|
| 570 |
-
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
|
|
|
| 603 |
|
| 604 |
else: # Provider Model
|
| 605 |
st.info("🔑 **Provider Model**: Use your own API keys to access premium models. Your keys are never stored, logged, or displayed.")
|
|
|
|
| 13 |
from core.llm_demo import LLM
|
| 14 |
from core.model_config import (
|
| 15 |
PROVIDER_PRESETS,
|
| 16 |
+
# create_local_model_config, # TODO: Re-enable when local models are fixed
|
| 17 |
create_provider_model_config,
|
| 18 |
get_api_key_env_name,
|
| 19 |
get_provider_from_model,
|
| 20 |
)
|
| 21 |
+
# from core.ollama_models import fetch_ollama_models # TODO: Re-enable when local models are fixed
|
| 22 |
from core.openrouter_models import fetch_free_models, get_model_config
|
| 23 |
from core.prompt_demo import Prompt
|
| 24 |
from core.token_counter_demo import TokenCounter
|
|
|
|
| 392 |
|
| 393 |
**LLM Provider Recommendations:**
|
| 394 |
- **Free Models (OpenRouter)**: Best for quick checks of already public paper+code combinations
|
|
|
|
| 395 |
- **Provider Models (OpenAI, Anthropic, etc.)**: Best for high precision and best recall
|
| 396 |
|
| 397 |
**Features:**
|
| 398 |
+
- Support for multiple LLM providers (free or premium models)
|
| 399 |
- Automatic content fetching from arXiv and GitHub
|
| 400 |
- File upload support for custom papers and repositories
|
| 401 |
- Secure API key handling (keys never stored or logged)
|
|
|
|
| 439 |
# Model type selection
|
| 440 |
model_type = st.radio(
|
| 441 |
"Model Type",
|
| 442 |
+
options=["Free Models (OpenRouter)", "Provider (OpenAI, Anthropic, Gemini, etc.)"],
|
| 443 |
+
# options=["Free Models (OpenRouter)", "Local Model (Ollama/vLLM)", "Provider (OpenAI, Anthropic, Gemini, etc.)"], # TODO: Re-enable Local Model option when fixed
|
| 444 |
+
help="Select free models (no API key) or provider models (requires API key)",
|
| 445 |
+
# help="Select free models (no API key), local models (Ollama/vLLM), or provider models (requires API key)", # TODO: Re-enable when local models are fixed
|
| 446 |
key="model_type_radio",
|
| 447 |
index=0, # Default to Free Models
|
| 448 |
)
|
|
|
|
| 468 |
# Show privacy warning
|
| 469 |
st.warning(
|
| 470 |
"⚠️ **Privacy Notice**: Free models are provided via [OpenRouter](https://openrouter.ai). "
|
| 471 |
+
"The model provider may log your prompts and outputs. For enhanced privacy, consider using Provider models with your own API keys."
|
| 472 |
)
|
| 473 |
# Create model options from fetched models
|
| 474 |
model_options = {get_model_config(m)["name"]: get_model_config(m) for m in free_models_raw}
|
|
|
|
| 495 |
st.error("⚠️ No free models available. Please try again later or use a different model type.")
|
| 496 |
model_config = None
|
| 497 |
|
| 498 |
+
# TODO: Re-enable when local models are fixed
|
| 499 |
+
# elif model_type == "Local Model (Ollama/vLLM)":
|
| 500 |
+
# st.info("🖥️ **Local Model**: Use models running locally via Ollama or vLLM (OpenAI-compatible server).")
|
| 501 |
+
#
|
| 502 |
+
# local_model_type = st.radio(
|
| 503 |
+
# "Local Server Type",
|
| 504 |
+
# options=["Ollama", "vLLM (OpenAI-compatible)"],
|
| 505 |
+
# help="Select the type of local server",
|
| 506 |
+
# key="local_server_type",
|
| 507 |
+
# )
|
| 508 |
+
#
|
| 509 |
+
# if local_model_type == "Ollama":
|
| 510 |
+
# # API Base URL comes first
|
| 511 |
+
# api_base = st.text_input(
|
| 512 |
+
# "API Base URL",
|
| 513 |
+
# value="http://localhost:11434",
|
| 514 |
+
# help="Ollama API base URL",
|
| 515 |
+
# key="ollama_api_base",
|
| 516 |
+
# )
|
| 517 |
+
#
|
| 518 |
+
# # Query Ollama for available models if API base is provided
|
| 519 |
+
# model_input = None
|
| 520 |
+
# if api_base and api_base.strip():
|
| 521 |
+
# try:
|
| 522 |
+
# with st.spinner("Fetching available models from Ollama..."):
|
| 523 |
+
# available_models = fetch_ollama_models(api_base.strip())
|
| 524 |
+
#
|
| 525 |
+
# if available_models:
|
| 526 |
+
# model_input = st.selectbox(
|
| 527 |
+
# "Select Model",
|
| 528 |
+
# options=available_models,
|
| 529 |
+
# help="Select a model from your Ollama server",
|
| 530 |
+
# key="ollama_model_select",
|
| 531 |
+
# )
|
| 532 |
+
# else:
|
| 533 |
+
# st.warning("⚠️ No models found or unable to connect to Ollama. You can still enter a model name manually.")
|
| 534 |
+
# model_input = st.text_input(
|
| 535 |
+
# "Model Name (manual entry)",
|
| 536 |
+
# placeholder="e.g., llama2, mistral, codellama",
|
| 537 |
+
# help="Enter the Ollama model name manually (without 'ollama/' prefix)",
|
| 538 |
+
# key="ollama_model_input_manual",
|
| 539 |
+
# )
|
| 540 |
+
# except Exception as e:
|
| 541 |
+
# logger.error(f"Error fetching Ollama models: {e}")
|
| 542 |
+
# st.warning(f"⚠️ Could not fetch models from Ollama: {str(e)}. You can still enter a model name manually.")
|
| 543 |
+
# model_input = st.text_input(
|
| 544 |
+
# "Model Name (manual entry)",
|
| 545 |
+
# placeholder="e.g., llama2, mistral, codellama",
|
| 546 |
+
# help="Enter the Ollama model name manually (without 'ollama/' prefix)",
|
| 547 |
+
# key="ollama_model_input_manual",
|
| 548 |
+
# )
|
| 549 |
+
# else:
|
| 550 |
+
# st.info("💡 Enter the API Base URL above to see available models, or enter a model name manually below.")
|
| 551 |
+
# model_input = st.text_input(
|
| 552 |
+
# "Model Name",
|
| 553 |
+
# placeholder="e.g., llama2, mistral, codellama",
|
| 554 |
+
# help="Enter the Ollama model name (without 'ollama/' prefix)",
|
| 555 |
+
# key="ollama_model_input",
|
| 556 |
+
# )
|
| 557 |
+
#
|
| 558 |
+
# max_context = st.number_input(
|
| 559 |
+
# "Max Context (tokens)",
|
| 560 |
+
# min_value=1000,
|
| 561 |
+
# max_value=1000000,
|
| 562 |
+
# value=131072,
|
| 563 |
+
# step=1000,
|
| 564 |
+
# help="Maximum context window size in tokens",
|
| 565 |
+
# key="ollama_max_context",
|
| 566 |
+
# )
|
| 567 |
+
#
|
| 568 |
+
# if model_input and api_base:
|
| 569 |
+
# model_name = f"ollama/{model_input}"
|
| 570 |
+
# model_config = create_local_model_config(
|
| 571 |
+
# model=model_name,
|
| 572 |
+
# api_base=api_base.strip(),
|
| 573 |
+
# max_context=max_context,
|
| 574 |
+
# )
|
| 575 |
+
# else: # vLLM
|
| 576 |
+
# model_input = st.text_input(
|
| 577 |
+
# "Model Name",
|
| 578 |
+
# placeholder="e.g., gpt-3.5-turbo, mistralai/Mistral-7B-Instruct-v0.1",
|
| 579 |
+
# help="Enter the model name for vLLM",
|
| 580 |
+
# key="vllm_model_input",
|
| 581 |
+
# )
|
| 582 |
+
# api_base = st.text_input(
|
| 583 |
+
# "API Base URL",
|
| 584 |
+
# value="http://localhost:8000/v1",
|
| 585 |
+
# help="vLLM API base URL (OpenAI-compatible endpoint)",
|
| 586 |
+
# key="vllm_api_base",
|
| 587 |
+
# )
|
| 588 |
+
# max_context = st.number_input(
|
| 589 |
+
# "Max Context (tokens)",
|
| 590 |
+
# min_value=1000,
|
| 591 |
+
# max_value=1000000,
|
| 592 |
+
# value=131072,
|
| 593 |
+
# step=1000,
|
| 594 |
+
# help="Maximum context window size in tokens",
|
| 595 |
+
# key="vllm_max_context",
|
| 596 |
+
# )
|
| 597 |
+
#
|
| 598 |
+
# if model_input:
|
| 599 |
+
# model_name = model_input
|
| 600 |
+
# model_config = create_local_model_config(
|
| 601 |
+
# model=model_name,
|
| 602 |
+
# api_base=api_base,
|
| 603 |
+
# max_context=max_context,
|
| 604 |
+
# )
|
| 605 |
|
| 606 |
else: # Provider Model
|
| 607 |
st.info("🔑 **Provider Model**: Use your own API keys to access premium models. Your keys are never stored, logged, or displayed.")
|
core/ollama_models.py
CHANGED
|
@@ -21,7 +21,7 @@ def fetch_ollama_models(api_base: str) -> list[str]:
|
|
| 21 |
try:
|
| 22 |
# Ollama API endpoint for listing models
|
| 23 |
url = f"{api_base.rstrip('/')}/api/tags"
|
| 24 |
-
response = requests.get(url, timeout=
|
| 25 |
response.raise_for_status()
|
| 26 |
|
| 27 |
data = response.json()
|
|
|
|
| 21 |
try:
|
| 22 |
# Ollama API endpoint for listing models
|
| 23 |
url = f"{api_base.rstrip('/')}/api/tags"
|
| 24 |
+
response = requests.get(url, timeout=10)
|
| 25 |
response.raise_for_status()
|
| 26 |
|
| 27 |
data = response.json()
|