antoinette-f commited on
Commit
84890d0
·
verified ·
1 Parent(s): 2a3a6a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -7
app.py CHANGED
@@ -1,25 +1,43 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
 
3
 
4
  client = InferenceClient("microsoft/phi-4")
5
 
 
 
6
  def respond(message,history): #function to return the history of messages sent
7
- messages = [{"role": "system", "content": "You are a friendly chatbot!"}]
8
 
9
  if history:
10
  messages.extend(history)
11
 
12
  messages.append({"role": "user", "content":message})
13
 
14
-
15
- response = client.chat_completion(
16
- messages,
17
- max_tokens = 568
18
- )
19
  return response['choices'][0]['message']['content'].strip()
20
 
21
 
22
- chatbot = gr.ChatInterface(respond, type="messages", title = "Friendly chatbot")
23
  # chatbot UI - conversation history and user input
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  chatbot.launch()
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
+ import pandas as pd
4
 
5
  client = InferenceClient("microsoft/phi-4")
6
 
7
+ clothing_df = pd.read_csv("clothing_daatabase.csv")
8
+
9
  def respond(message,history): #function to return the history of messages sent
10
+ messages = [{"role": "system", "content": "You are a clothing assistant. Based on the the user's request, suggest suitable clothing items from the database and return their image paths"}]
11
 
12
  if history:
13
  messages.extend(history)
14
 
15
  messages.append({"role": "user", "content":message})
16
 
17
+ #get AI reasoning
18
+ response = client.chat_completion(messages, max_tokens=200)
19
+ ai_text = response
 
 
20
  return response['choices'][0]['message']['content'].strip()
21
 
22
 
23
+ chatbot = gr.ChatInterface(respond, type="messages", title = "Capstone project")
24
  # chatbot UI - conversation history and user input
25
 
26
+
27
+ #Load the clothing database
28
+ clothing_df = pd.read_csv("clothing_databse.csv")
29
+
30
+ def search_clothing(weather=None, formality=None):
31
+ results = clothing_df
32
+ if weather:
33
+ results = results[results[weather].str.contain(weather, case=False)]
34
+ if formality:
35
+ results = results[results[formality].str.contains(formality, case=False)]
36
+ return results
37
+
38
+
39
+
40
+
41
+
42
+
43
  chatbot.launch()