milwright commited on
Commit
fe0344d
·
verified ·
1 Parent(s): afc61f9

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +21 -15
  2. config.json +6 -6
app.py CHANGED
@@ -10,11 +10,11 @@ import urllib.parse
10
 
11
 
12
  # Configuration
13
- SPACE_NAME = "AI Assistant"
14
- SPACE_DESCRIPTION = "A customizable AI assistant"
15
 
16
  # Default configuration values
17
- DEFAULT_SYSTEM_PROMPT = """You are a research aid specializing in academic literature search and analysis. Your expertise spans discovering peer-reviewed sources, assessing research methodologies, synthesizing findings across studies, and delivering properly formatted citations. When responding, anchor claims in specific sources from provided URL contexts, differentiate between direct evidence and interpretive analysis, and note any limitations or contradictory results. Employ clear, accessible language that demystifies complex research, and propose connected research directions when appropriate. Your purpose is to serve as an informed research tool supporting users through initial concept development, exploratory investigation, information collection, and source compilation."""
18
  DEFAULT_TEMPERATURE = 0.7
19
  DEFAULT_MAX_TOKENS = 750
20
 
@@ -33,8 +33,8 @@ except:
33
  max_tokens = DEFAULT_MAX_TOKENS
34
  print("ℹ️ Using default configuration")
35
 
36
- MODEL = "google/gemini-2.0-flash-001"
37
- THEME = "Default" # Gradio theme name
38
  GROUNDING_URLS = []
39
  # Get access code from environment variable for security
40
  # If ACCESS_CODE is not set, no access control is applied
@@ -549,7 +549,7 @@ with gr.Blocks(title=SPACE_NAME, theme=theme_class()) as demo:
549
  fn=store_and_generate_response, # Use wrapper function to store history
550
  title="", # Title already shown above
551
  description="", # Description already shown above
552
- examples=['Hello! How can you help me?', 'Tell me something interesting', 'What can you do?'],
553
  type="messages" # Use modern message format for better compatibility
554
  )
555
 
@@ -736,7 +736,16 @@ with gr.Blocks(title=SPACE_NAME, theme=theme_class()) as demo:
736
  )
737
 
738
  # Save configuration function
739
- def save_configuration(new_name, new_description, new_prompt, new_model, new_examples, new_temp, new_tokens, *url_values, lock_config, is_authenticated):
 
 
 
 
 
 
 
 
 
740
  if not is_authenticated:
741
  return "❌ Not authenticated"
742
 
@@ -760,11 +769,8 @@ with gr.Blocks(title=SPACE_NAME, theme=theme_class()) as demo:
760
  # Process example prompts
761
  examples_list = [ex.strip() for ex in new_examples.split('\n') if ex.strip()]
762
 
763
- # Process URL values - lock_config is the last parameter
764
- urls = list(url_values[:-1]) # All but last are URLs
765
- lock_config_from_args = url_values[-1] # Last is lock_config
766
- # Filter out empty URLs
767
- grounding_urls = [url.strip() for url in urls if url.strip()]
768
 
769
  # Update all editable fields while preserving everything else
770
  current_full_config.update({
@@ -776,7 +782,7 @@ with gr.Blocks(title=SPACE_NAME, theme=theme_class()) as demo:
776
  'temperature': new_temp,
777
  'max_tokens': int(new_tokens),
778
  'grounding_urls': grounding_urls,
779
- 'locked': lock_config_from_args,
780
  'last_modified': datetime.now().isoformat(),
781
  'last_modified_by': 'faculty'
782
  })
@@ -832,7 +838,7 @@ with gr.Blocks(title=SPACE_NAME, theme=theme_class()) as demo:
832
  # Reset configuration function
833
  def reset_configuration(is_authenticated):
834
  if not is_authenticated:
835
- updates = ["❌ Not authenticated"] + [gr.update() for _ in range(16)] # 1 status + 16 fields
836
  return tuple(updates)
837
 
838
  # Check if locked
@@ -840,7 +846,7 @@ with gr.Blocks(title=SPACE_NAME, theme=theme_class()) as demo:
840
  with open('config.json', 'r') as f:
841
  existing_config = json.load(f)
842
  if existing_config.get('locked', False):
843
- updates = ["🔒 Configuration is locked"] + [gr.update() for _ in range(16)]
844
  return tuple(updates)
845
  except:
846
  pass
 
10
 
11
 
12
  # Configuration
13
+ SPACE_NAME = "CUNY Virgil"
14
+ SPACE_DESCRIPTION = "An AI reading and research guide, with a twist"
15
 
16
  # Default configuration values
17
+ DEFAULT_SYSTEM_PROMPT = """You are Virgil, a college-level research assistant specializing in academic literature search and analysis, with critical pedagogical values and subtle brevity in your responses. Employ clear, accessible language that demystifies complex research, and propose connected research directions when appropriate. Your purpose is to serve as an informed research tool supporting users through initial concept development, exploratory investigation, information collection, and source compilation."""
18
  DEFAULT_TEMPERATURE = 0.7
19
  DEFAULT_MAX_TOKENS = 750
20
 
 
33
  max_tokens = DEFAULT_MAX_TOKENS
34
  print("ℹ️ Using default configuration")
35
 
36
+ MODEL = "nvidia/llama-3.1-nemotron-70b-instruct"
37
+ THEME = "Glass" # Gradio theme name
38
  GROUNDING_URLS = []
39
  # Get access code from environment variable for security
40
  # If ACCESS_CODE is not set, no access control is applied
 
549
  fn=store_and_generate_response, # Use wrapper function to store history
550
  title="", # Title already shown above
551
  description="", # Description already shown above
552
+ examples=['What can you help me research?', 'Why is your name Virgil?'],
553
  type="messages" # Use modern message format for better compatibility
554
  )
555
 
 
736
  )
737
 
738
  # Save configuration function
739
+ def save_configuration(new_name, new_description, new_prompt, new_model, new_examples, new_temp, new_tokens, *args):
740
+ # Extract URL values, lock_config, and is_authenticated from args
741
+ # args should contain: url1, url2, ..., url10, lock_config, is_authenticated
742
+ if len(args) < 12: # Need at least 10 URLs + lock_config + is_authenticated
743
+ return "❌ Invalid number of parameters"
744
+
745
+ url_values = args[:10] # First 10 are URLs
746
+ lock_config = args[10] # 11th is lock_config
747
+ is_authenticated = args[11] # 12th is is_authenticated
748
+
749
  if not is_authenticated:
750
  return "❌ Not authenticated"
751
 
 
769
  # Process example prompts
770
  examples_list = [ex.strip() for ex in new_examples.split('\n') if ex.strip()]
771
 
772
+ # Process URL values
773
+ grounding_urls = [url.strip() for url in url_values if url and url.strip()]
 
 
 
774
 
775
  # Update all editable fields while preserving everything else
776
  current_full_config.update({
 
782
  'temperature': new_temp,
783
  'max_tokens': int(new_tokens),
784
  'grounding_urls': grounding_urls,
785
+ 'locked': lock_config,
786
  'last_modified': datetime.now().isoformat(),
787
  'last_modified_by': 'faculty'
788
  })
 
838
  # Reset configuration function
839
  def reset_configuration(is_authenticated):
840
  if not is_authenticated:
841
+ updates = ["❌ Not authenticated"] + [gr.update() for _ in range(17)] # 1 status + 7 main fields + 10 URLs
842
  return tuple(updates)
843
 
844
  # Check if locked
 
846
  with open('config.json', 'r') as f:
847
  existing_config = json.load(f)
848
  if existing_config.get('locked', False):
849
+ updates = ["🔒 Configuration is locked"] + [gr.update() for _ in range(17)]
850
  return tuple(updates)
851
  except:
852
  pass
config.json CHANGED
@@ -1,13 +1,13 @@
1
  {
2
- "name": "AI Assistant",
3
- "description": "A customizable AI assistant",
4
- "system_prompt": "You are a research aid specializing in academic literature search and analysis. Your expertise spans discovering peer-reviewed sources, assessing research methodologies, synthesizing findings across studies, and delivering properly formatted citations. When responding, anchor claims in specific sources from provided URL contexts, differentiate between direct evidence and interpretive analysis, and note any limitations or contradictory results. Employ clear, accessible language that demystifies complex research, and propose connected research directions when appropriate. Your purpose is to serve as an informed research tool supporting users through initial concept development, exploratory investigation, information collection, and source compilation.",
5
- "model": "google/gemini-2.0-flash-001",
6
  "api_key_var": "API_KEY",
7
  "temperature": 0.7,
8
  "max_tokens": 750,
9
- "examples": "['Hello! How can you help me?', 'Tell me something interesting', 'What can you do?']",
10
  "grounding_urls": "[]",
11
  "enable_dynamic_urls": true,
12
- "theme": "Default"
13
  }
 
1
  {
2
+ "name": "CUNY Virgil",
3
+ "description": "An AI reading and research guide, with a twist",
4
+ "system_prompt": "You are Virgil, a college-level research assistant specializing in academic literature search and analysis, with critical pedagogical values and subtle brevity in your responses. Employ clear, accessible language that demystifies complex research, and propose connected research directions when appropriate. Your purpose is to serve as an informed research tool supporting users through initial concept development, exploratory investigation, information collection, and source compilation.",
5
+ "model": "nvidia/llama-3.1-nemotron-70b-instruct",
6
  "api_key_var": "API_KEY",
7
  "temperature": 0.7,
8
  "max_tokens": 750,
9
+ "examples": "['What can you help me research?', 'Why is your name Virgil?']",
10
  "grounding_urls": "[]",
11
  "enable_dynamic_urls": true,
12
+ "theme": "Glass"
13
  }