Spaces:
Sleeping
Sleeping
File size: 779 Bytes
1e156c7 52631c2 becf7f0 52631c2 becf7f0 52631c2 becf7f0 52631c2 becf7f0 52631c2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
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 ) -> 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"],outputs = "text")
iface.launch()
|