Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from dotenv import load_dotenv
|
| 2 |
+
from langchain.embeddings import HuggingFaceHub, LLMChain
|
| 3 |
+
from langchain.prompts import prompt_templates
|
| 4 |
+
import gradio
|
| 5 |
+
|
| 6 |
+
load_dotenv()
|
| 7 |
+
os.getenv('HF_API')
|
| 8 |
+
|
| 9 |
+
hub_llm = HuggingFaceHub(repo_id='facebook/blenderbot-400M-distill')
|
| 10 |
+
|
| 11 |
+
prompt = prompt_templates(
|
| 12 |
+
input_variable = ["question"]
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
hub_chain = LLMChain(prompt=prompt, llm=hub_llm, verbose=True)
|
| 16 |
+
|
| 17 |
+
def responsenew(data):
|
| 18 |
+
return hub_chain(data)
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
gradio_interface = gradio.Interface(
|
| 22 |
+
fn = responsenew,
|
| 23 |
+
inputs = "text",
|
| 24 |
+
outputs = "text"
|
| 25 |
+
)
|
| 26 |
+
gradio_interface.launch()
|