Enable smolagent tools in Hugging Chat! 🚀 (#132)
* Add correct signature, api_name, and description
This commit is contained in:
		
							parent
							
								
									067ae9bc90
								
							
						
					
					
						commit
						cf04285cc1
					
				
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							|  | @ -779,8 +779,10 @@ def launch_gradio_demo(tool: Tool): | ||||||
|         "number": gr.Textbox, |         "number": gr.Textbox, | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     def fn(*args, **kwargs): |     def tool_forward(*args, **kwargs): | ||||||
|         return tool(*args, **kwargs, sanitize_inputs_outputs=True) |         return tool(*args, sanitize_inputs_outputs=True, **kwargs) | ||||||
|  | 
 | ||||||
|  |     tool_forward.__signature__ = inspect.signature(tool.forward) | ||||||
| 
 | 
 | ||||||
|     gradio_inputs = [] |     gradio_inputs = [] | ||||||
|     for input_name, input_details in tool.inputs.items(): |     for input_name, input_details in tool.inputs.items(): | ||||||
|  | @ -794,11 +796,13 @@ def launch_gradio_demo(tool: Tool): | ||||||
|     gradio_output = output_gradio_componentclass(label="Output") |     gradio_output = output_gradio_componentclass(label="Output") | ||||||
| 
 | 
 | ||||||
|     gr.Interface( |     gr.Interface( | ||||||
|         fn=fn, |         fn=tool_forward, | ||||||
|         inputs=gradio_inputs, |         inputs=gradio_inputs, | ||||||
|         outputs=gradio_output, |         outputs=gradio_output, | ||||||
|         title=tool.name, |         title=tool.name, | ||||||
|         article=tool.description, |         article=tool.description, | ||||||
|  |         description=tool.description, | ||||||
|  |         api_name=tool.name, | ||||||
|     ).launch() |     ).launch() | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue