Spaces:
Build error
Build error
| 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() |