Copain22 commited on
Commit
b36fdc1
·
verified ·
1 Parent(s): 1e5d467

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -10
app.py CHANGED
@@ -1,4 +1,7 @@
1
- import os, torch
 
 
 
2
  from pathlib import Path
3
  from huggingface_hub import login
4
 
@@ -10,7 +13,6 @@ from llama_index.llms.huggingface import HuggingFaceLLM
10
  from llama_index.embeddings.langchain import LangchainEmbedding
11
  from langchain_huggingface import HuggingFaceEmbeddings
12
 
13
- # ---------- Constants ----------
14
  SYSTEM_PROMPT = """
15
  You are a friendly café assistant for Café Eleven. Your job is to:
16
  1. Greet the customer warmly
@@ -18,6 +20,7 @@ You are a friendly café assistant for Café Eleven. Your job is to:
18
  3. Answer questions about ingredients, preparation, etc.
19
  4. Process special requests (allergies, modifications)
20
  5. Provide a friendly farewell
 
21
  Always be polite and helpful!
22
  """
23
 
@@ -77,12 +80,15 @@ def chat_with_cafe_eleven(message: str) -> str:
77
  response = engine.chat(message).response
78
  return response
79
 
80
- # ---------- Example usage ----------
 
 
 
 
 
 
 
 
 
81
  if __name__ == "__main__":
82
- while True:
83
- user_message = input("You: ")
84
- bot_response = chat_with_cafe_eleven(user_message)
85
- print("Café Eleven:", bot_response)
86
-
87
- if user_message.lower().strip() in {"quit", "exit", "done"}:
88
- break
 
1
+ # ---------- 0. Imports & constants ----------
2
+ import os
3
+ import torch
4
+ import gradio as gr
5
  from pathlib import Path
6
  from huggingface_hub import login
7
 
 
13
  from llama_index.embeddings.langchain import LangchainEmbedding
14
  from langchain_huggingface import HuggingFaceEmbeddings
15
 
 
16
  SYSTEM_PROMPT = """
17
  You are a friendly café assistant for Café Eleven. Your job is to:
18
  1. Greet the customer warmly
 
20
  3. Answer questions about ingredients, preparation, etc.
21
  4. Process special requests (allergies, modifications)
22
  5. Provide a friendly farewell
23
+ 6. Provide calories if they ask.
24
  Always be polite and helpful!
25
  """
26
 
 
80
  response = engine.chat(message).response
81
  return response
82
 
83
+ # ---------- 4. Gradio UI ----------
84
+ iface = gr.Interface(
85
+ fn=chat_with_cafe_eleven,
86
+ inputs=gr.Textbox(lines=2, placeholder="Ask about menu items, orders, etc..."),
87
+ outputs="text",
88
+ title="Café Eleven Assistant",
89
+ description="A friendly café assistant to help you with orders and questions!"
90
+ )
91
+
92
+ # ---------- 5. Launch App ----------
93
  if __name__ == "__main__":
94
+ iface.launch(server_name="0.0.0.0", server_port=7860)