Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
def generate_trip_plan(question):
|
2 |
+
hf_api_key = hf_api_key
|
3 |
+
repo_id = 'tiiuae/falcon-7b'
|
4 |
+
llm = HuggingFaceHub(huggingfacehub_api_token=hf_api_key,
|
5 |
+
repo_id=repo_id,
|
6 |
+
model_kwargs={"temperature": 0.7, "max_new_tokens": 500})
|
7 |
+
template="""Question: {question}
|
8 |
+
Answer: Let's give a detailed answer."""
|
9 |
+
|
10 |
+
prompt = PromptTemplate(template=template, input_variables=['question'])
|
11 |
+
chain = LLMChain(prompt=prompt, llm=llm)
|
12 |
+
out = chain.run(question)
|
13 |
+
return out
|
14 |
+
|
15 |
+
input_text = gr.Textbox(label="Enter your question")
|
16 |
+
generate_button = gr.Button("Generate")
|
17 |
+
|
18 |
+
iface = gr.Interface(fn=generate_trip_plan, inputs=input_text, outputs=gr.Textbox())
|
19 |
+
iface.launch()
|