milwright commited on
Commit
0b0106d
·
verified ·
1 Parent(s): ea4e324

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -28
app.py CHANGED
@@ -302,31 +302,10 @@ def export_conversation_to_markdown(conversation_history):
302
  markdown_content = f"""# Conversation Export
303
  Generated on: {{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}}
304
 
305
- ## Configuration Information
306
-
307
- **Assistant Name:** {name}
308
- **Description:** {description}
309
- **Model:** {{MODEL}}
310
- **Temperature:** {temperature}
311
- **Max Tokens:** {max_tokens}
312
- **API Key Variable:** {api_key_var}
313
  """
314
 
315
- # Add URL grounding information
316
- if GROUNDING_URLS:
317
- markdown_content += f"\\n**URL Grounding ({{len(GROUNDING_URLS)}} URLs):**\\n"
318
- for i, url in enumerate(GROUNDING_URLS, 1):
319
- markdown_content += f"- URL {{i}}: {{url}}\\n"
320
-
321
- # Add feature flags
322
- if ENABLE_DYNAMIC_URLS:
323
- markdown_content += f"\\n**Dynamic URL Fetching:** Enabled\\n"
324
-
325
- # Add system prompt
326
- markdown_content += f"\\n**System Prompt:**\\n```\\n{{SYSTEM_PROMPT}}\\n```\\n"
327
-
328
- markdown_content += "\\n---\\n\\n"
329
-
330
  message_pair_count = 0
331
  for i, message in enumerate(conversation_history):
332
  if isinstance(message, dict):
@@ -661,7 +640,7 @@ with gr.Blocks(title=SPACE_NAME) as demo:
661
  fn=store_and_generate_response, # Use wrapper function to store history
662
  title="", # Title already shown above
663
  description="", # Description already shown above
664
- examples=None,
665
  type="messages" # Use modern message format for better compatibility
666
  )
667
 
@@ -850,9 +829,9 @@ def generate_zip(name, description, system_prompt, model, api_key_var, temperatu
850
  # Process examples
851
  if examples_text and examples_text.strip():
852
  examples_list = [ex.strip() for ex in examples_text.split('\n') if ex.strip()]
853
- examples_json = json.dumps(examples_list)
854
  else:
855
- examples_json = json.dumps([
856
  "Hello! How can you help me?",
857
  "Tell me something interesting",
858
  "What can you do?"
@@ -875,7 +854,7 @@ def generate_zip(name, description, system_prompt, model, api_key_var, temperatu
875
  'api_key_var': api_key_var,
876
  'temperature': temperature,
877
  'max_tokens': int(max_tokens),
878
- 'examples': examples_json,
879
  'grounding_urls': json.dumps(grounding_urls),
880
  'access_code': "", # Access code stored in environment variable for security
881
  'enable_dynamic_urls': enable_dynamic_urls
@@ -1958,7 +1937,7 @@ with gr.Blocks(
1958
 
1959
  preview_export_btn.click(
1960
  export_preview_conversation,
1961
- inputs=[preview_chatbot, preview_config_state],
1962
  outputs=[export_file]
1963
  )
1964
 
 
302
  markdown_content = f"""# Conversation Export
303
  Generated on: {{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}}
304
 
305
+ ---
306
+
 
 
 
 
 
 
307
  """
308
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
309
  message_pair_count = 0
310
  for i, message in enumerate(conversation_history):
311
  if isinstance(message, dict):
 
640
  fn=store_and_generate_response, # Use wrapper function to store history
641
  title="", # Title already shown above
642
  description="", # Description already shown above
643
+ examples={examples},
644
  type="messages" # Use modern message format for better compatibility
645
  )
646
 
 
829
  # Process examples
830
  if examples_text and examples_text.strip():
831
  examples_list = [ex.strip() for ex in examples_text.split('\n') if ex.strip()]
832
+ examples_python = repr(examples_list) # Convert to Python literal representation
833
  else:
834
+ examples_python = repr([
835
  "Hello! How can you help me?",
836
  "Tell me something interesting",
837
  "What can you do?"
 
854
  'api_key_var': api_key_var,
855
  'temperature': temperature,
856
  'max_tokens': int(max_tokens),
857
+ 'examples': examples_python,
858
  'grounding_urls': json.dumps(grounding_urls),
859
  'access_code': "", # Access code stored in environment variable for security
860
  'enable_dynamic_urls': enable_dynamic_urls
 
1937
 
1938
  preview_export_btn.click(
1939
  export_preview_conversation,
1940
+ inputs=[preview_chatbot],
1941
  outputs=[export_file]
1942
  )
1943