Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,14 +11,14 @@ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
|
11 |
from huggingface_hub import InferenceClient, cached_download
|
12 |
|
13 |
# --- Configuration ---
|
14 |
-
VERBOSE = True
|
15 |
-
MAX_HISTORY = 5
|
16 |
-
MAX_TOKENS = 2048
|
17 |
-
TEMPERATURE = 0.7
|
18 |
-
TOP_P = 0.8
|
19 |
-
REPETITION_PENALTY = 1.5
|
20 |
-
MODEL_NAME = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
21 |
-
API_KEY = "YOUR_API_KEY"
|
22 |
|
23 |
# --- Logging Setup ---
|
24 |
logging.basicConfig(
|
@@ -138,32 +138,4 @@ def main():
|
|
138 |
examples = [
|
139 |
["What is the purpose of this AI agent?", "I am designed to assist with no-code development tasks."],
|
140 |
["Can you help me generate a Python function to calculate the factorial of a number?", "Sure! Here is a Python function to calculate the factorial of a number:"],
|
141 |
-
["Generate a simple HTML page with a heading and a paragraph.", "
|
142 |
-
["Create a basic SQL query to select all data from a table named 'users'.", "```sql\nSELECT * FROM users;\n```"],
|
143 |
-
["Design a user interface for a mobile app that allows users to track their daily expenses.", "Here's a basic UI design for a mobile expense tracker app:\n\n**Screen 1: Home**\n- Top: App Name and Balance Display\n- Middle: List of Recent Transactions (Date, Description, Amount)\n- Bottom: Buttons for Add Expense, Add Income, View Categories\n\n**Screen 2: Add Expense**\n- Input fields for Date, Category, Description, Amount\n- Buttons for Save, Cancel\n\n**Screen 3: Expense Categories**\n- List of expense categories (e.g., Food, Transportation, Entertainment)\n- Option to add/edit categories\n\n**Screen 4: Reports**\n- Charts and graphs to visualize spending by category, date range, etc.\n- Filters to customize the reports"],
|
144 |
-
]
|
145 |
-
|
146 |
-
def chat(purpose: str, message: str, agent_name: str, sys_prompt: str, temperature: float, max_new_tokens: int, top_p: float, repetition_penalty: float, history: List[Tuple[str, str]]) -> Tuple[List[Tuple[str, str]], List[Tuple[str, str]]]:
|
147 |
-
"""Handles the chat interaction."""
|
148 |
-
response = generate(message, history, agent_name, sys_prompt, temperature, max_new_tokens, top_p, repetition_penalty)
|
149 |
-
history.append((message, response))
|
150 |
-
return history, history
|
151 |
-
|
152 |
-
submit_button.click(chat, inputs=[purpose, message, agent_name, sys_prompt, temperature, max_new_tokens, top_p, repetition_penalty, history], outputs=[chatbot, history])
|
153 |
-
|
154 |
-
# Project Explorer Logic
|
155 |
-
def explore_project(project_path: str) -> str:
|
156 |
-
"""Explores the project directory and returns a file tree."""
|
157 |
-
try:
|
158 |
-
tree = subprocess.check_output(["tree", project_path]).decode("utf-8")
|
159 |
-
return tree
|
160 |
-
except Exception as e:
|
161 |
-
return f"Error exploring project: {e}"
|
162 |
-
|
163 |
-
explore_button.click(explore_project, inputs=[project_path], outputs=[project_output])
|
164 |
-
|
165 |
-
demo.launch()
|
166 |
-
|
167 |
-
if __name__ == "__main__":
|
168 |
-
main()
|
169 |
-
```
|
|
|
11 |
from huggingface_hub import InferenceClient, cached_download
|
12 |
|
13 |
# --- Configuration ---
|
14 |
+
VERBOSE = True
|
15 |
+
MAX_HISTORY = 5
|
16 |
+
MAX_TOKENS = 2048
|
17 |
+
TEMPERATURE = 0.7
|
18 |
+
TOP_P = 0.8
|
19 |
+
REPETITION_PENALTY = 1.5
|
20 |
+
MODEL_NAME = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
21 |
+
API_KEY = "YOUR_API_KEY"
|
22 |
|
23 |
# --- Logging Setup ---
|
24 |
logging.basicConfig(
|
|
|
138 |
examples = [
|
139 |
["What is the purpose of this AI agent?", "I am designed to assist with no-code development tasks."],
|
140 |
["Can you help me generate a Python function to calculate the factorial of a number?", "Sure! Here is a Python function to calculate the factorial of a number:"],
|
141 |
+
["Generate a simple HTML page with a heading and a paragraph.", "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|