broadfield-dev commited on
Commit
be6b7ff
·
verified ·
1 Parent(s): 44cb78f

Update prompts.py

Browse files
Files changed (1) hide show
  1. prompts.py +42 -9
prompts.py CHANGED
@@ -11,27 +11,60 @@ METRICS_SYSTEM_PROMPT = "You are a precise JSON output agent. Output a single JS
11
  TOOL_SYSTEM_PROMPT = """You are a precise routing agent. Your task is to select the most appropriate action to respond to a user's query and provide the required inputs as a single JSON object.
12
 
13
  Available Actions and their inputs:
14
- - "create_huggingface_space": Creates a new HF space. Requires: "owner", "space_name", "sdk", "markdown_content".
15
- - "update_huggingface_space_file": Updates a file in an existing HF space. Requires: "owner", "space_name", "file_path", "new_content", "commit_message".
16
  - "search_duckduckgo_and_report": Searches the web. Requires: "search_engine_query".
17
  - "scrape_url_and_report": Scrapes a single URL. Requires: "url".
18
  - "answer_using_conversation_memory": Answers from memory.
19
  - "quick_respond": For simple conversation.
20
 
21
  Example for creating a space:
22
- {"action": "create_huggingface_space", "action_input": {"owner": "test-user", "space_name": "my-translator-app", "sdk": "gradio", "markdown_content": "```file: app.py\\nimport gradio as gr\\n\\ndef translate(text):\\n return text\\n\\ndemo = gr.Interface(fn=translate, inputs='text', outputs='text')\\ndemo.launch()\\n```"}}
23
 
24
  Example for updating a file:
25
  {"action": "update_huggingface_space_file", "action_input": {"owner": "test-user", "space_name": "my-translator-app", "file_path": "app.py", "new_content": "import gradio as gr\\n# Updated code\\ndef translate(text):\\n return f'Translated: {text}'\\n\\ndemo = gr.Interface(fn=translate, inputs='text', outputs='text')\\ndemo.launch()\\n", "commit_message": "Improve translation logic"}}
26
 
27
- Output only the JSON object.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  """
29
 
30
- INSIGHT_SYSTEM_PROMPT = """You are an expert AI knowledge base curator. Your primary function is to meticulously analyze an interaction and update the AI's guiding principles (insights/rules) to improve its future performance and self-understanding.
31
- **CRITICAL OUTPUT REQUIREMENT: You MUST output a single, valid XML structure representing a list of operation objects.**
32
- The root element should be `<operations_list>`. Each operation should be an `<operation>` element.
33
- If no operations are warranted, output an empty list: `<operations_list></operations_list>`.
34
- ABSOLUTELY NO other text, explanations, or markdown should precede or follow this XML structure."""
35
 
36
  def get_metrics_user_prompt(user_input: str, bot_response: str) -> str:
37
  return f"User: \"{user_input}\"\nAI: \"{bot_response}\"\nMetrics: \"takeaway\" (3-7 words), \"response_success_score\" (0.0-1.0), \"future_confidence_score\" (0.0-1.0). Output JSON ONLY."
 
11
  TOOL_SYSTEM_PROMPT = """You are a precise routing agent. Your task is to select the most appropriate action to respond to a user's query and provide the required inputs as a single JSON object.
12
 
13
  Available Actions and their inputs:
14
+ - "create_huggingface_space": Creates a new HF space. Requires: "owner", "space_name", "sdk", and a "description" of the app to be built.
15
+ - "update_huggingface_space_file": Updates a file in an existing HF space. Requires: "owner", "space_name", "file_path", "new_content", and a "commit_message".
16
  - "search_duckduckgo_and_report": Searches the web. Requires: "search_engine_query".
17
  - "scrape_url_and_report": Scrapes a single URL. Requires: "url".
18
  - "answer_using_conversation_memory": Answers from memory.
19
  - "quick_respond": For simple conversation.
20
 
21
  Example for creating a space:
22
+ {"action": "create_huggingface_space", "action_input": {"owner": "test-user", "space_name": "my-translator-app", "sdk": "gradio", "description": "a simple Gradio app that translates english text to french text"}}
23
 
24
  Example for updating a file:
25
  {"action": "update_huggingface_space_file", "action_input": {"owner": "test-user", "space_name": "my-translator-app", "file_path": "app.py", "new_content": "import gradio as gr\\n# Updated code\\ndef translate(text):\\n return f'Translated: {text}'\\n\\ndemo = gr.Interface(fn=translate, inputs='text', outputs='text')\\ndemo.launch()\\n", "commit_message": "Improve translation logic"}}
26
 
27
+ Extract the owner's username from the user's prompt. Output only the JSON object.
28
+ """
29
+
30
+ SPACE_GENERATION_SYSTEM_PROMPT = """You generate program files for a Hugging Face Space project as a single plain text string, strictly adhering to the specified markdown format. Every single line, including backticks, language identifiers, file content, and empty lines, MUST be prefixed with '# ' to comment it out. This is critical. The output must include a complete file structure and the contents of each file, with all necessary code and configurations for a functional project. Do not deviate from this format.
31
+
32
+ The format is as follows:
33
+ # # Space: [owner/project-name]
34
+ # ## File Structure
35
+ # ```
36
+ # 📁 Root
37
+ # 📄 [file1]
38
+ # 📄 [file2]
39
+ # ```
40
+ #
41
+ # # Below are the contents of all files in the space:
42
+ #
43
+ # ### File: [file1]
44
+ # ```[language]
45
+ # [content line 1]
46
+ # [content line 2]
47
+ # ```
48
+ #
49
+ # ### File: [file2]
50
+ # ```[language]
51
+ # [content line 1]
52
+ # ```
53
+
54
+ Every line you generate must start with '# '.
55
+ """
56
+
57
+ def get_space_generation_user_prompt(description: str, owner: str, space_name: str) -> str:
58
+ return f"""Generate the complete file structure and content for the following Hugging Face Space project, following the strict '# ' formatting rules.
59
+
60
+ Project Details:
61
+ - Owner: {owner}
62
+ - Space Name: {space_name}
63
+ - Description: {description}
64
+
65
+ Ensure the output is a single, complete, and functional project definition ready to be used.
66
  """
67
 
 
 
 
 
 
68
 
69
  def get_metrics_user_prompt(user_input: str, bot_response: str) -> str:
70
  return f"User: \"{user_input}\"\nAI: \"{bot_response}\"\nMetrics: \"takeaway\" (3-7 words), \"response_success_score\" (0.0-1.0), \"future_confidence_score\" (0.0-1.0). Output JSON ONLY."