Spaces:
Sleeping
Sleeping
return
Browse files
app.py
CHANGED
|
@@ -123,10 +123,10 @@ chunk_embeddings = create_embeddings(cleaned_chunks)
|
|
| 123 |
client= InferenceClient("Qwen/Qwen2.5-7B-Instruct-1M")
|
| 124 |
response=""
|
| 125 |
#defining role of AI and user
|
| 126 |
-
messages = [{"role": "assistant", "content": f"You are a friendly chatbot that gives advice to disadvantaged students about their education based on their question. When you give advice, keep in mind the following infromation {information}"}]
|
| 127 |
|
| 128 |
def respond(message,history):
|
| 129 |
information = get_top_chunks(message, chunk_embeddings, cleaned_chunks)
|
|
|
|
| 130 |
|
| 131 |
|
| 132 |
if history:
|
|
@@ -134,11 +134,9 @@ def respond(message,history):
|
|
| 134 |
|
| 135 |
messages.append({"role":"user", "content": message})
|
| 136 |
|
| 137 |
-
response=client.chat_completion(messages,
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
response+=token
|
| 141 |
-
yield response['choices'][0]['message']['content'].strip() #storing value of response in a readable format to display
|
| 142 |
|
| 143 |
### STEP 6
|
| 144 |
# Call the preprocess_text function and store the result in a cleaned_chunks variable
|
|
|
|
| 123 |
client= InferenceClient("Qwen/Qwen2.5-7B-Instruct-1M")
|
| 124 |
response=""
|
| 125 |
#defining role of AI and user
|
|
|
|
| 126 |
|
| 127 |
def respond(message,history):
|
| 128 |
information = get_top_chunks(message, chunk_embeddings, cleaned_chunks)
|
| 129 |
+
messages = [{"role": "assistant", "content": f"You are a friendly chatbot that gives advice to disadvantaged students about their education based on their question. When you give advice, keep in mind the following infromation {information}"}]
|
| 130 |
|
| 131 |
|
| 132 |
if history:
|
|
|
|
| 134 |
|
| 135 |
messages.append({"role":"user", "content": message})
|
| 136 |
|
| 137 |
+
response=client.chat_completion(messages, max_tokens=100) #capping how many words the LLM is allowed to generate as a respond (100 words)
|
| 138 |
+
|
| 139 |
+
return response['choices'][0]['message']['content'].strip() #storing value of response in a readable format to display
|
|
|
|
|
|
|
| 140 |
|
| 141 |
### STEP 6
|
| 142 |
# Call the preprocess_text function and store the result in a cleaned_chunks variable
|