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

Update tools/orchestrator.py

Browse files
Files changed (1) hide show
  1. tools/orchestrator.py +25 -3
tools/orchestrator.py CHANGED
@@ -68,10 +68,32 @@ def orchestrate_and_respond(user_input: str, provider_name: str, model_display_n
68
  context_str = None
69
 
70
  if action_type == "create_huggingface_space":
71
- yield "status", "[Tool: Creating Space...]"
72
- params = ["owner", "space_name", "sdk", "markdown_content"]
73
  if all(p in action_input for p in params):
74
- result = create_huggingface_space(**action_input)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  context_str = f"Tool Result (Create Space): {result.get('result') or result.get('error', 'Unknown outcome from tool.')}"
76
  else:
77
  context_str = "Tool Failed: Missing required parameters for create_huggingface_space. Required: " + ", ".join(params)
 
68
  context_str = None
69
 
70
  if action_type == "create_huggingface_space":
71
+ params = ["owner", "space_name", "sdk", "description"]
 
72
  if all(p in action_input for p in params):
73
+ yield "status", "[Tool: Generating space content...]"
74
+ description = action_input["description"]
75
+ owner = action_input["owner"]
76
+ space_name = action_input["space_name"]
77
+ sdk = action_input["sdk"]
78
+
79
+ space_gen_user_prompt = prompts.get_space_generation_user_prompt(description, owner, space_name)
80
+ space_gen_messages = [
81
+ {"role": "system", "content": prompts.SPACE_GENERATION_SYSTEM_PROMPT},
82
+ {"role": "user", "content": space_gen_user_prompt}
83
+ ]
84
+
85
+ markdown_content = "".join(list(call_model_stream(
86
+ provider=provider_name, model_display_name=model_display_name,
87
+ messages=space_gen_messages, api_key_override=ui_api_key_override,
88
+ temperature=0.1, max_tokens=4096
89
+ )))
90
+
91
+ yield "status", "[Tool: Creating Space with generated content...]"
92
+
93
+ result = create_huggingface_space(
94
+ owner=owner, space_name=space_name, sdk=sdk,
95
+ markdown_content=markdown_content.strip()
96
+ )
97
  context_str = f"Tool Result (Create Space): {result.get('result') or result.get('error', 'Unknown outcome from tool.')}"
98
  else:
99
  context_str = "Tool Failed: Missing required parameters for create_huggingface_space. Required: " + ", ".join(params)