Spaces:
Runtime error
Runtime error
| from typing import Optional | |
| from src.pipeline import pipeline | |
| # Define the clear function dynamically based on the number of inputs | |
| def clear(*args): | |
| return tuple([None] * len(args)) # Return None for each input/output component dynamically | |
| def generate_text( | |
| country: Optional[str], | |
| starting_point: Optional[str], | |
| query_text: str, | |
| is_sustainable: Optional[bool] = True, | |
| model: Optional[str] = "Gemini-1.5-Pro", | |
| max_tokens: Optional[int] = 1024, | |
| temp: Optional[float] = 0.49, | |
| ): | |
| model_params = { | |
| 'max_tokens': max_tokens, | |
| 'temperature': temp | |
| } | |
| pipeline_response = pipeline( | |
| query=query_text, | |
| model_name=model, | |
| sustainability=is_sustainable, | |
| starting_point=starting_point, | |
| **model_params | |
| ) | |
| if pipeline_response is None: | |
| return "Error while generating response! Please try again." | |
| return pipeline_response | |