timbmg commited on
Commit
2d58484
·
unverified ·
1 Parent(s): 382ff93

disable local models for now

Browse files
Files changed (2) hide show
  1. app.py +115 -113
  2. 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, local, or premium models)
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)", "Local Model (Ollama/vLLM)", "Provider (OpenAI, Anthropic, Gemini, etc.)"],
444
- help="Select free models (no API key), local models (Ollama/vLLM), or provider models (requires API key)",
 
 
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 Local or Provider models with your own API keys."
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
- elif model_type == "Local Model (Ollama/vLLM)":
498
- st.info("🖥️ **Local Model**: Use models running locally via Ollama or vLLM (OpenAI-compatible server).")
499
-
500
- local_model_type = st.radio(
501
- "Local Server Type",
502
- options=["Ollama", "vLLM (OpenAI-compatible)"],
503
- help="Select the type of local server",
504
- key="local_server_type",
505
- )
506
-
507
- if local_model_type == "Ollama":
508
- # API Base URL comes first
509
- api_base = st.text_input(
510
- "API Base URL",
511
- value="http://localhost:11434",
512
- help="Ollama API base URL",
513
- key="ollama_api_base",
514
- )
515
-
516
- # Query Ollama for available models if API base is provided
517
- model_input = None
518
- if api_base and api_base.strip():
519
- try:
520
- with st.spinner("Fetching available models from Ollama..."):
521
- available_models = fetch_ollama_models(api_base.strip())
522
-
523
- if available_models:
524
- model_input = st.selectbox(
525
- "Select Model",
526
- options=available_models,
527
- help="Select a model from your Ollama server",
528
- key="ollama_model_select",
529
- )
530
- else:
531
- st.warning("⚠️ No models found or unable to connect to Ollama. You can still enter a model name manually.")
532
- model_input = st.text_input(
533
- "Model Name (manual entry)",
534
- placeholder="e.g., llama2, mistral, codellama",
535
- help="Enter the Ollama model name manually (without 'ollama/' prefix)",
536
- key="ollama_model_input_manual",
537
- )
538
- except Exception as e:
539
- logger.error(f"Error fetching Ollama models: {e}")
540
- st.warning(f"⚠️ Could not fetch models from Ollama: {str(e)}. You can still enter a model name manually.")
541
- model_input = st.text_input(
542
- "Model Name (manual entry)",
543
- placeholder="e.g., llama2, mistral, codellama",
544
- help="Enter the Ollama model name manually (without 'ollama/' prefix)",
545
- key="ollama_model_input_manual",
546
- )
547
- else:
548
- st.info("💡 Enter the API Base URL above to see available models, or enter a model name manually below.")
549
- model_input = st.text_input(
550
- "Model Name",
551
- placeholder="e.g., llama2, mistral, codellama",
552
- help="Enter the Ollama model name (without 'ollama/' prefix)",
553
- key="ollama_model_input",
554
- )
555
-
556
- max_context = st.number_input(
557
- "Max Context (tokens)",
558
- min_value=1000,
559
- max_value=1000000,
560
- value=131072,
561
- step=1000,
562
- help="Maximum context window size in tokens",
563
- key="ollama_max_context",
564
- )
565
-
566
- if model_input and api_base:
567
- model_name = f"ollama/{model_input}"
568
- model_config = create_local_model_config(
569
- model=model_name,
570
- api_base=api_base.strip(),
571
- max_context=max_context,
572
- )
573
- else: # vLLM
574
- model_input = st.text_input(
575
- "Model Name",
576
- placeholder="e.g., gpt-3.5-turbo, mistralai/Mistral-7B-Instruct-v0.1",
577
- help="Enter the model name for vLLM",
578
- key="vllm_model_input",
579
- )
580
- api_base = st.text_input(
581
- "API Base URL",
582
- value="http://localhost:8000/v1",
583
- help="vLLM API base URL (OpenAI-compatible endpoint)",
584
- key="vllm_api_base",
585
- )
586
- max_context = st.number_input(
587
- "Max Context (tokens)",
588
- min_value=1000,
589
- max_value=1000000,
590
- value=131072,
591
- step=1000,
592
- help="Maximum context window size in tokens",
593
- key="vllm_max_context",
594
- )
595
-
596
- if model_input:
597
- model_name = model_input
598
- model_config = create_local_model_config(
599
- model=model_name,
600
- api_base=api_base,
601
- max_context=max_context,
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=5)
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()