from typing import Optional import gradio as gr from build_rag import get_context from models.gemma import gemma_predict from models.gemini import get_gemini_response def clear(): return None, None, None def generate_text(query_text, model_name: Optional[str] = "google/gemma-2b-it", tokens: Optional[int] = 1024, temp: Optional[float] = 0.49): combined_information = get_context(query_text) gen_config = { "temperature": temp, "max_output_tokens": tokens, } if model_name is None or model_name == "google/gemma-2b-it": return gemma_predict(combined_information, model_name, gen_config) if model_name == "gemini-1.0-pro": return get_gemini_response(combined_information, model_name, gen_config) return "Sorry, something went wrong! Please try again." examples = [["I'm planning a vacation to France. Can you suggest a one-week itinerary including must-visit places and " "local cuisines to try?", "google/gemma-2b-it"], ["I want to explore off-the-beaten-path destinations in Europe, any suggestions?", "gemini-1.0-pro"], ["Suggest some cities that can be visited from London and are very rich in history and culture.", "google/gemma-2b-it"], ] with gr.Blocks() as demo: gr.HTML("""
We're testing the compatibility of Retrieval Augmented Generation (RAG) implementations with Google's Gemma-2b-it & Gemini 1.0 Pro models through HuggingFace and VertexAI, respectively, to generate travel recommendations. This early version (read quick and dirty implementation) aims to see if functionalities work smoothly. It relies on Wikipedia abstracts from 160 European cities to provide answers to your questions. Please be kind with it, as it's a work in progress!