Spaces:
Sleeping
Sleeping
| from flask import Flask, request, jsonify | |
| import google.generativeai as genai | |
| import os | |
| import os | |
| # api_key = os.getenv("api_key") | |
| # # Configure API key | |
| # GOOGLE_API_KEY = api_key # Or hardcode for testing | |
| # genai.configure(api_key=GOOGLE_API_KEY) | |
| # # Initialize model | |
| # model = genai.GenerativeModel('gemini-1.5-flash') | |
| # Medical_prompt = """you are sahha chatbot ,You are a knowledgeable medical expert. Analyze the provided medical input and generate a comprehensive, informative response that addresses the patient's query or medical scenario and give me brief answer in short . | |
| # ### Input: | |
| # {input_text} | |
| # ### Response: | |
| # """ | |
| # def generate_response(input_text): | |
| # prompt = Medical_prompt.format(input_text=input_text) | |
| # try: | |
| # response = model.generate_content(prompt) | |
| # return response.text.strip() | |
| # except Exception as e: | |
| # return f"β Error: {str(e)}" | |
| def generate_response(input_text): | |
| try: | |
| return "Hello" | |
| except Exception as e: | |
| return f"β Error: {str(e)}" | |
| app = Flask(__name__) | |
| def home(): | |
| return "β Sahha chatbot using Gemini is Running", 200 | |
| def QandAnswer(): | |
| try: | |
| user_input = request.json.get('input_text') | |
| if not user_input: | |
| return jsonify({'error': 'Missing input_text'}), 400 | |
| response = generate_response(user_input) | |
| return jsonify({'Answers': response}) | |
| except Exception as e: | |
| return jsonify({'error': str(e)}), 500 | |