Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- README.md +3 -9
- chatbot.py +40 -0
- flagged_responses/log.csv +26 -0
README.md
CHANGED
|
@@ -1,12 +1,6 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
|
| 4 |
-
colorFrom: pink
|
| 5 |
-
colorTo: purple
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
-
app_file: app.py
|
| 9 |
-
pinned: false
|
| 10 |
---
|
| 11 |
-
|
| 12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: src
|
| 3 |
+
app_file: chatbot.py
|
|
|
|
|
|
|
| 4 |
sdk: gradio
|
| 5 |
+
sdk_version: 4.43.0
|
|
|
|
|
|
|
| 6 |
---
|
|
|
|
|
|
chatbot.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from dotenv import load_dotenv
|
| 2 |
+
import os
|
| 3 |
+
import gradio as gr
|
| 4 |
+
from swarmauri.standard.llms.concrete.GroqModel import GroqModel
|
| 5 |
+
from swarmauri.standard.messages.concrete.SystemMessage import SystemMessage
|
| 6 |
+
from swarmauri.standard.agents.concrete.SimpleConversationAgent import SimpleConversationAgent
|
| 7 |
+
from swarmauri.standard.conversations.concrete.MaxSystemContextConversation import MaxSystemContextConversation
|
| 8 |
+
|
| 9 |
+
load_dotenv()
|
| 10 |
+
API_KEY = os.getenv("GROQ_API_KEY")
|
| 11 |
+
llm = GroqModel(api_key=API_KEY)
|
| 12 |
+
allowed_models = llm.allowed_models
|
| 13 |
+
conversation = MaxSystemContextConversation()
|
| 14 |
+
|
| 15 |
+
def load_model(selected_model):
|
| 16 |
+
return GroqModel(api_key=API_KEY, name=selected_model)
|
| 17 |
+
|
| 18 |
+
def chatbot(system_context, input_text, model_name):
|
| 19 |
+
llm = load_model(model_name)
|
| 20 |
+
agent = SimpleConversationAgent(llm=llm, conversation=conversation)
|
| 21 |
+
agent.conversation.system_context = SystemMessage(content=system_context)
|
| 22 |
+
result = agent.exec(str(input_text))
|
| 23 |
+
return str(result)
|
| 24 |
+
|
| 25 |
+
flagging_dir = "flagged_responses"
|
| 26 |
+
if not os.path.exists(flagging_dir):
|
| 27 |
+
os.makedirs(flagging_dir)
|
| 28 |
+
|
| 29 |
+
iface = gr.Interface(
|
| 30 |
+
fn=chatbot,
|
| 31 |
+
inputs=[gr.Textbox(label="System Context"), gr.Textbox(label="User Input"), gr.Dropdown(choices=allowed_models, label="Model")],
|
| 32 |
+
outputs="text",
|
| 33 |
+
title="Dynamic Chatbot with System Context",
|
| 34 |
+
description="Interact with the chatbot using a system context and user query.",
|
| 35 |
+
flagging_dir=flagging_dir,
|
| 36 |
+
flagging_options=["Inappropriate Response", "Incorrect Information", "Other"]
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
if __name__ == "__main__":
|
| 40 |
+
iface.launch(share=True)
|
flagged_responses/log.csv
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
System Context,User Input,Model,output,flag,username,timestamp
|
| 2 |
+
This is a great work,great work in which way,llama3-8b-8192,"I apologize for the ambiguity! I'm a large language model, I don't have a specific work that I can take credit for, but I'm here to assist you with any questions or tasks you may have.
|
| 3 |
+
|
| 4 |
+
However, I'm assuming you're referring to the conversation we just had. If that's the case, I'm glad you think our conversation was great! I'm designed to provide helpful and informative responses, and I'm always happy to hear that I've been able to do so.
|
| 5 |
+
|
| 6 |
+
If you have any specific topics or questions you'd like to discuss, I'm here to help. Just let me know what's on your mind!",Inappropriate Response,,2024-11-15 12:56:49.182998
|
| 7 |
+
he is a very fatty men,how to be less fat and be slim ?,llama3-8b-8192," week for a sustainable and healthy weight loss.
|
| 8 |
+
* **Strength training**: Incorporate strength training exercises to build muscle mass, which can help boost metabolism and support weight loss.
|
| 9 |
+
* **High-intensity interval training (HIIT)**: HIIT workouts can be an effective way to burn calories and improve cardiovascular health.
|
| 10 |
+
* **Mindful eating**: Practice mindful eating by paying attention to hunger and fullness cues, eating slowly, and savoring your food.
|
| 11 |
+
* **Seek support**: Share your goals with a friend or family member and seek support from a healthcare professional or a registered dietitian.
|
| 12 |
+
|
| 13 |
+
Remember, the key to successful weight loss is to make sustainable lifestyle changes that you can maintain in the long term. Focus on nourishing your body with whole foods, staying hydrated, and getting regular exercise to support your overall health and well-being.",Other,,2024-11-15 13:00:07.118189
|
| 14 |
+
he is a very fatty men,how to be less fat and be slim ?,llama3-8b-8192,"Congratulations on taking the first step towards a healthier lifestyle! Losing weight and becoming slim requires a combination of healthy diet, regular exercise, and sustainable lifestyle changes. Here are some tips to help you get started:
|
| 15 |
+
|
| 16 |
+
**Diet:**
|
| 17 |
+
|
| 18 |
+
1. **Eat a balanced diet:** Focus on whole, unprocessed foods like vegetables, fruits, whole grains, lean proteins, and healthy fats. Avoid sugary drinks, fast food, and processed snacks.
|
| 19 |
+
2. **Keep track of your calorie intake:** Use a food diary or an app to track your daily calorie intake. Aim for a deficit of 500-1000 calories per day to promote weight loss.
|
| 20 |
+
3. **Incorporate protein-rich foods:** Protein takes more energy to digest, which can help increase your metabolism and support weight loss. Good sources include lean meats, fish, eggs, tofu, and legumes.
|
| 21 |
+
4. **Drink plenty of water:** Aim for at least 8 cups (64 ounces) of water per day to help control hunger and boost metabolism.
|
| 22 |
+
5. **Limit your intake of added sugars:** Try to limit your daily sugar intake to less than 10% of your total daily calories.
|
| 23 |
+
|
| 24 |
+
**Exercise:**
|
| 25 |
+
|
| 26 |
+
1. **Start with moderate-intensity exercise:** Aim for 150 minutes of moderate-int",Other,,2024-11-15 13:28:25.132779
|