Oracle_Wikipage / app.py
Sujithanumala's picture
Update app.py
52631c2 verified
raw
history blame
811 Bytes
import gradio as gr
from typing import List
from langchain_google_genai import GoogleGenerativeAIEmbeddings
import google.generativeai as genai
from langchain_community.vectorstores import FAISS
from langchain_google_genai import ChatGoogleGenerativeAI
genai.configure(api_key="AIzaSyD2o8vjePJb6z8vT_PVe82lVWMD3_cBL0g")
def predict(message :str ,history,topic : str = "OIC") -> str:
model = genai.GenerativeModel("gemini-pro")
his = []
for i,j in history:
his.extend([
{"role": "user", "parts": i},
{"role": "model", "parts": j},
])
chat = model.start_chat(
history=his
)
response = chat.send_message(message)
return response.text
iface = gr.Interface(fn = predict,inputs = ["text","list","text"],outputs = "text")
iface.launch()