from fastapi import FastAPI import os import json import google.generativeai as genai from pydantic import BaseModel, validator class Item(BaseModel): text: str = "sddddddddddd" app = FastAPI() GOOGLE_API_KEY = os.environ.get("GOOGLE_API_KEY") genai.configure(api_key=GOOGLE_API_KEY) # Set up the model generation_config = { "temperature": 0.9, "top_p": 1, "top_k": 1, "max_output_tokens": 2048, } model = genai.GenerativeModel( model_name="gemini-pro", generation_config=generation_config, ) task_description = " You need to classify each message you receive among the following categories: 'admiration','amusement','anger','annoyance','approval','caring','confusion','curiosity','desire','disappointment','disapproval','disgust','embarrassment','excitement','fear','gratitude','grief','joy','love','nervousness', 'optimism', 'pride', 'realization', 'relief', 'remorse', 'sadness', 'surprise', 'neutral'