elinstallation commited on
Commit
6893abc
·
verified ·
1 Parent(s): 2834861

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -12
app.py CHANGED
@@ -68,7 +68,7 @@ def create_embeddings(text_chunks):
68
  return chunk_embeddings
69
 
70
  charity_embeddings = create_embeddings(cleaned_charities)
71
- finance_embeddings2 = create_embeddings(cleaned_finance)
72
  # Call the create_embeddings function and store the result in a new chunk_embeddings variable
73
  #chunk_embeddings = create_embeddings(cleaned_chunks) # Complete this line
74
 
@@ -116,15 +116,11 @@ client= InferenceClient("openai/gpt-oss-20b")
116
  information=""
117
 
118
  def respond(message,history):
119
- topic_chunks=[]
120
- if chatbot_topic=="Helping Charities":
121
-
122
- topic_chunks=get_top_chunks(message, charity_embeddings, cleaned_charities)
123
- #print(topic_chunks)
124
-
125
- elif chatbot_topic=="Financial Aid":
126
- topic_chunks=get_top_chunks(message, finance_embeddings, cleaned_finance)
127
- #print(topic_chunks)
128
 
129
 
130
  #return information
@@ -148,9 +144,9 @@ def respond(message,history):
148
  ### STEP 6
149
  # Call the preprocess_text function and store the result in a cleaned_chunks variable
150
  cleaned_chunks = preprocess_text(financial_advice_text) # Complete this line
151
- top_results = get_top_chunks("What financial advice you give me?", chunk_embeddings2, cleaned_chunks2)
152
 
153
- print(top_results)
154
 
155
  #Defining chatbot giving user a UI to interact, see their conversation history, and see new messages using built in gr feature
156
  #ChatInterface requires at least one parameter(a function)
 
68
  return chunk_embeddings
69
 
70
  charity_embeddings = create_embeddings(cleaned_charities)
71
+ finance_embeddings = create_embeddings(cleaned_finance)
72
  # Call the create_embeddings function and store the result in a new chunk_embeddings variable
73
  #chunk_embeddings = create_embeddings(cleaned_chunks) # Complete this line
74
 
 
116
  information=""
117
 
118
  def respond(message,history):
119
+ topic_chunks = []
120
+ if chatbot_topic and "Helping Charities" in chatbot_topic:
121
+ topic_chunks = get_top_chunks(message, charity_embeddings, cleaned_charities)
122
+ elif chatbot_topic and "Financial Aid" in chatbot_topic:
123
+ topic_chunks = get_top_chunks(message, finance_embeddings, cleaned_finance)
 
 
 
 
124
 
125
 
126
  #return information
 
144
  ### STEP 6
145
  # Call the preprocess_text function and store the result in a cleaned_chunks variable
146
  cleaned_chunks = preprocess_text(financial_advice_text) # Complete this line
147
+ top_results = get_top_chunks("What financial advice you give me?", finance_embeddings, cleaned_finance)
148
 
149
+ #print(top_results)
150
 
151
  #Defining chatbot giving user a UI to interact, see their conversation history, and see new messages using built in gr feature
152
  #ChatInterface requires at least one parameter(a function)