Spaces:
Sleeping
Sleeping
File size: 991 Bytes
211fb31 f96d782 211fb31 6ba7abd 211fb31 6ba7abd 211fb31 6ba7abd 211fb31 da45566 211fb31 a4886c0 211fb31 6ba7abd a04f57f a4886c0 081455c 30b001b 211fb31 6ba7abd 211fb31 6ba7abd |
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 29 30 31 32 33 34 35 36 37 38 |
import gradio as gr
import os
from langchain_google_genai import GoogleGenerativeAI
from langchain import LLMChain
from langchain.prompts import ChatPromptTemplate, HumanMessagePromptTemplate
from langchain.schema import SystemMessage
google_api_key = os.getenv("google_api_key")
llm = GoogleGenerativeAI(model='gemini-1.5-pro', google_api_key=google_api_key)
messages = [
SystemMessage(content="You are an expert at extracting entities from text."),
HumanMessagePromptTemplate.from_template("{text}")
]
chat_prompt = ChatPromptTemplate.from_messages(messages)
chain = LLMChain(llm=llm, prompt=chat_prompt)
def extract_entities(text):
result = chain.run(text)
return result
iface = gr.Interface(
fn=extract_entities,
inputs=gr.Textbox(label="Enter your text",lines=10),
outputs=gr.Markdown(label="Extracted Entities"),
title="Entity Extraction Tool for Email!",
description="Extract entities from Email using Gemini 1.5 Pro."
)
iface.launch()
|