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, | ||||
|     } | ||||
| 
 | ||||
|     def fn(*args, **kwargs): | ||||
|         return tool(*args, **kwargs, sanitize_inputs_outputs=True) | ||||
|     def tool_forward(*args, **kwargs): | ||||
|         return tool(*args, sanitize_inputs_outputs=True, **kwargs) | ||||
| 
 | ||||
|     tool_forward.__signature__ = inspect.signature(tool.forward) | ||||
| 
 | ||||
|     gradio_inputs = [] | ||||
|     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") | ||||
| 
 | ||||
|     gr.Interface( | ||||
|         fn=fn, | ||||
|         fn=tool_forward, | ||||
|         inputs=gradio_inputs, | ||||
|         outputs=gradio_output, | ||||
|         title=tool.name, | ||||
|         article=tool.description, | ||||
|         description=tool.description, | ||||
|         api_name=tool.name, | ||||
|     ).launch() | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue