File size: 718 Bytes
e2cd0b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
def generate_trip_plan(question):
  hf_api_key = hf_api_key
  repo_id = 'tiiuae/falcon-7b'
  llm = HuggingFaceHub(huggingfacehub_api_token=hf_api_key,
                     repo_id=repo_id,
                     model_kwargs={"temperature": 0.7, "max_new_tokens": 500})
  template="""Question: {question}
            Answer: Let's give a detailed answer."""
        
  prompt = PromptTemplate(template=template, input_variables=['question'])
  chain = LLMChain(prompt=prompt, llm=llm)
  out = chain.run(question)
  return out

input_text = gr.Textbox(label="Enter your question")
generate_button = gr.Button("Generate")

iface = gr.Interface(fn=generate_trip_plan, inputs=input_text, outputs=gr.Textbox())
iface.launch()