Spaces:
No application file
No application file
| from huggingface_hub import InferenceClient | |
| class GemmaHandler: | |
| def __init__(self, api_token): | |
| self.client = InferenceClient(token=api_token) | |
| self.model = "google/gemma-7b" | |
| def generate_response(self, prompt): | |
| response = self.client.text_generation( | |
| prompt, | |
| model=self.model, | |
| max_new_tokens=100, | |
| temperature=0.7, | |
| top_p=0.95, | |
| repetition_penalty=1.1 | |
| ) | |
| return response | |
| def generate_emotional_support(self, emotion, story): | |
| prompt = f""" | |
| As a supportive AI friend, respond to someone who is feeling {emotion}. | |
| Their story: {story} | |
| Provide empathetic support and encouragement while maintaining authenticity. | |
| """ | |
| return self.generate_response(prompt) | |