File size: 969 Bytes
19683e9
69e6f95
364fbf2
 
 
69e6f95
19683e9
e2cd0b0
 
 
 
 
 
 
 
 
 
 
 
 
 
9e80133
e2cd0b0
 
 
b4ac1fd
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
import gradio as gr
# from langchain import HuggingFaceHub
# from langchain import PromptTemplate, LLMChain
from langchain.chains import LLMChain
from langchain.prompts import PromptTemplate
from langchain_community.llms import HuggingFaceHub

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 city you want to go!")
generate_button = gr.Button("Generate")

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