Shafaq25 commited on
Commit
baceaba
·
verified ·
1 Parent(s): a259cc8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -1,20 +1,20 @@
1
  import os
 
2
  from langchain.chains import LLMChain, SequentialChain
3
  from langchain.prompts import PromptTemplate
4
- from langchain.llms import OpenAI
5
 
6
- # Get OpenAI API key from environment variable (configured in Hugging Face Secrets)
7
  openai_api_key = os.getenv("OPENAI_API_KEY")
8
  llm = OpenAI(openai_api_key=openai_api_key, temperature=0.9)
9
 
10
  # Define prompt templates
11
  prompt_template_name = PromptTemplate(
12
  input_variables=['cuisine'],
13
- template="i want to open a restaurant for {cuisine} food. Suggest a fancy name for this"
14
  )
15
  name_chain = LLMChain(llm=llm, prompt=prompt_template_name, output_key="restaraunt_name")
16
 
17
- llm = OpenAI(openai_api_key=openai_api_key, temperature=0.9)
18
  prompt_template_items = PromptTemplate(
19
  input_variables=['restaraunt_name', 'cuisine'],
20
  template="Suggest a comprehensive menu for {restaraunt_name} which is {cuisine} cuisine. For each item, provide a brief, one-sentence description. Do not use any numbering or bullet points. Only mention items names and descriptions, break down according to category. Format the output as 'Category:\nItem Name - Description\n...'"
@@ -27,7 +27,6 @@ chain = SequentialChain(
27
  output_variables=['restaraunt_name', 'menu_items']
28
  )
29
 
30
- # Dropdown options
31
  TOP_CUISINES = [
32
  "Italian", "Chinese", "Japanese", "Mexican", "Indian",
33
  "French", "Thai", "Mediterranean", "American", "Spanish"
@@ -114,7 +113,6 @@ def on_generate(selected, custom):
114
  cuisine = custom.strip() if custom and custom.strip() else selected
115
  return generate_restaurant(cuisine)
116
 
117
- # Build Gradio interface
118
  with gr.Blocks(title="Restaurant Business Generator", theme="soft", css="""
119
  @import url('https://fonts.googleapis.com/css2?family=Comic+Neue:wght@400;700&display=swap');
120
  body {
 
1
  import os
2
+ import gradio as gr
3
  from langchain.chains import LLMChain, SequentialChain
4
  from langchain.prompts import PromptTemplate
5
+ from langchain_community.llms import OpenAI # <-- UPDATED IMPORT
6
 
7
+ # Get OpenAI API key from environment variable
8
  openai_api_key = os.getenv("OPENAI_API_KEY")
9
  llm = OpenAI(openai_api_key=openai_api_key, temperature=0.9)
10
 
11
  # Define prompt templates
12
  prompt_template_name = PromptTemplate(
13
  input_variables=['cuisine'],
14
+ template="I want to open a restaurant for {cuisine} food. Suggest a fancy name for this"
15
  )
16
  name_chain = LLMChain(llm=llm, prompt=prompt_template_name, output_key="restaraunt_name")
17
 
 
18
  prompt_template_items = PromptTemplate(
19
  input_variables=['restaraunt_name', 'cuisine'],
20
  template="Suggest a comprehensive menu for {restaraunt_name} which is {cuisine} cuisine. For each item, provide a brief, one-sentence description. Do not use any numbering or bullet points. Only mention items names and descriptions, break down according to category. Format the output as 'Category:\nItem Name - Description\n...'"
 
27
  output_variables=['restaraunt_name', 'menu_items']
28
  )
29
 
 
30
  TOP_CUISINES = [
31
  "Italian", "Chinese", "Japanese", "Mexican", "Indian",
32
  "French", "Thai", "Mediterranean", "American", "Spanish"
 
113
  cuisine = custom.strip() if custom and custom.strip() else selected
114
  return generate_restaurant(cuisine)
115
 
 
116
  with gr.Blocks(title="Restaurant Business Generator", theme="soft", css="""
117
  @import url('https://fonts.googleapis.com/css2?family=Comic+Neue:wght@400;700&display=swap');
118
  body {