Spaces:
Runtime error
Runtime error
Commit ·
d38127c
1
Parent(s): 9c5b502
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import math
|
| 3 |
+
from langchain import PromptTemplate, HuggingFaceHub, LLMChain
|
| 4 |
+
import os
|
| 5 |
+
os.environ['HUGGINGFACEHUB_API_TOKEN'] = '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'
|
| 6 |
+
llm=HuggingFaceHub(repo_id="google/flan-t5-xxl")
|
| 7 |
+
template = """
|
| 8 |
+
I want you to convert a number as word to an integer.
|
| 9 |
+
Convert {number}?
|
| 10 |
+
"""
|
| 11 |
+
prompt = PromptTemplate(template=template, input_variables=["question"])
|
| 12 |
+
chain = LLMChain(llm=llm, prompt=prompt)
|
| 13 |
+
def answer(number):
|
| 14 |
+
out=chain.run(number)
|
| 15 |
+
out1=int(out)
|
| 16 |
+
out2=math.factorial(out1)
|
| 17 |
+
return out2
|
| 18 |
+
demo = gr.Interface(fn=answer, inputs='text',outputs='text',examples= [['Eight']])
|
| 19 |
+
demo.launch()
|