Spaces:
Sleeping
Sleeping
chore: Remove files that should be ignored
Browse files- .editorconfig +52 -0
- pyrightconfig.json +32 -0
- tests/__pycache__/test_gradio_ui.cpython-312-pytest-8.3.5.pyc +0 -0
- tests/__pycache__/test_security.cpython-312-pytest-8.3.5.pyc +0 -0
- tests/__pycache__/test_tools.cpython-312-pytest-8.3.5.pyc +0 -0
- tools/__pycache__/__init__.cpython-312.pyc +0 -0
- tools/__pycache__/api_optimization.cpython-312.pyc +0 -0
- tools/__pycache__/base.cpython-312.pyc +0 -0
- tools/__pycache__/cache.cpython-312.pyc +0 -0
- tools/__pycache__/error_recovery.cpython-312.pyc +0 -0
- tools/__pycache__/errors.cpython-312.pyc +0 -0
- tools/__pycache__/exceptions.cpython-312.pyc +0 -0
- tools/__pycache__/final_answer.cpython-312.pyc +0 -0
- tools/__pycache__/health.cpython-312.pyc +0 -0
- tools/__pycache__/logging_config.cpython-312.pyc +0 -0
- tools/__pycache__/monitoring.cpython-312.pyc +0 -0
- tools/__pycache__/security.cpython-312.pyc +0 -0
- tools/__pycache__/stats.cpython-312.pyc +0 -0
- tools/__pycache__/system_status.cpython-312.pyc +0 -0
- tools/__pycache__/timezone_tools.cpython-312.pyc +0 -0
- tools/__pycache__/validation.cpython-312.pyc +0 -0
- tools/__pycache__/weather.cpython-312.pyc +0 -0
- ui.py +70 -0
.editorconfig
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# EditorConfig is awesome: https://EditorConfig.org
|
| 2 |
+
|
| 3 |
+
# top-most EditorConfig file
|
| 4 |
+
root = true
|
| 5 |
+
|
| 6 |
+
# Unix-style newlines with a newline ending every file
|
| 7 |
+
[*]
|
| 8 |
+
end_of_line = lf
|
| 9 |
+
insert_final_newline = true
|
| 10 |
+
trim_trailing_whitespace = true
|
| 11 |
+
charset = utf-8
|
| 12 |
+
|
| 13 |
+
# Python files
|
| 14 |
+
[*.py]
|
| 15 |
+
indent_style = space
|
| 16 |
+
indent_size = 4
|
| 17 |
+
max_line_length = 100
|
| 18 |
+
|
| 19 |
+
# Use 2 spaces for YAML files
|
| 20 |
+
[*.{yml,yaml}]
|
| 21 |
+
indent_style = space
|
| 22 |
+
indent_size = 2
|
| 23 |
+
|
| 24 |
+
# Use 2 spaces for JSON files
|
| 25 |
+
[*.json]
|
| 26 |
+
indent_style = space
|
| 27 |
+
indent_size = 2
|
| 28 |
+
|
| 29 |
+
# Use 2 spaces for TOML files
|
| 30 |
+
[*.toml]
|
| 31 |
+
indent_style = space
|
| 32 |
+
indent_size = 2
|
| 33 |
+
|
| 34 |
+
# Markdown files
|
| 35 |
+
[*.md]
|
| 36 |
+
trim_trailing_whitespace = false
|
| 37 |
+
max_line_length = 120
|
| 38 |
+
|
| 39 |
+
# Requirements files
|
| 40 |
+
[requirements*.txt]
|
| 41 |
+
indent_style = space
|
| 42 |
+
indent_size = 2
|
| 43 |
+
|
| 44 |
+
# Documentation files
|
| 45 |
+
[docs/**/*.rst]
|
| 46 |
+
indent_style = space
|
| 47 |
+
indent_size = 3
|
| 48 |
+
max_line_length = 120
|
| 49 |
+
|
| 50 |
+
# Git commit messages
|
| 51 |
+
[COMMIT_EDITMSG]
|
| 52 |
+
max_line_length = 72
|
pyrightconfig.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"include": [
|
| 3 |
+
"tools",
|
| 4 |
+
"tests"
|
| 5 |
+
],
|
| 6 |
+
"exclude": [
|
| 7 |
+
"**/node_modules",
|
| 8 |
+
"**/__pycache__",
|
| 9 |
+
"build",
|
| 10 |
+
"dist"
|
| 11 |
+
],
|
| 12 |
+
"ignore": [
|
| 13 |
+
"**/migrations"
|
| 14 |
+
],
|
| 15 |
+
"defineConstant": {
|
| 16 |
+
"DEBUG": true
|
| 17 |
+
},
|
| 18 |
+
"reportMissingImports": true,
|
| 19 |
+
"reportMissingTypeStubs": true,
|
| 20 |
+
"reportUnknownMemberType": true,
|
| 21 |
+
"reportUnknownParameterType": true,
|
| 22 |
+
"reportUnknownVariableType": true,
|
| 23 |
+
"reportUnnecessaryTypeIgnoreComment": true,
|
| 24 |
+
"pythonVersion": "3.9",
|
| 25 |
+
"typeCheckingMode": "strict",
|
| 26 |
+
"useLibraryCodeForTypes": true,
|
| 27 |
+
"strictListInference": true,
|
| 28 |
+
"strictDictionaryInference": true,
|
| 29 |
+
"strictSetInference": true,
|
| 30 |
+
"strictParameterNoneValue": true,
|
| 31 |
+
"enableTypeIgnoreComments": true
|
| 32 |
+
}
|
tests/__pycache__/test_gradio_ui.cpython-312-pytest-8.3.5.pyc
DELETED
|
Binary file (11 kB)
|
|
|
tests/__pycache__/test_security.cpython-312-pytest-8.3.5.pyc
DELETED
|
Binary file (19.1 kB)
|
|
|
tests/__pycache__/test_tools.cpython-312-pytest-8.3.5.pyc
DELETED
|
Binary file (25 kB)
|
|
|
tools/__pycache__/__init__.cpython-312.pyc
DELETED
|
Binary file (1.37 kB)
|
|
|
tools/__pycache__/api_optimization.cpython-312.pyc
DELETED
|
Binary file (18.8 kB)
|
|
|
tools/__pycache__/base.cpython-312.pyc
DELETED
|
Binary file (5.16 kB)
|
|
|
tools/__pycache__/cache.cpython-312.pyc
DELETED
|
Binary file (15.9 kB)
|
|
|
tools/__pycache__/error_recovery.cpython-312.pyc
DELETED
|
Binary file (9.68 kB)
|
|
|
tools/__pycache__/errors.cpython-312.pyc
DELETED
|
Binary file (10.6 kB)
|
|
|
tools/__pycache__/exceptions.cpython-312.pyc
DELETED
|
Binary file (8.49 kB)
|
|
|
tools/__pycache__/final_answer.cpython-312.pyc
DELETED
|
Binary file (1.68 kB)
|
|
|
tools/__pycache__/health.cpython-312.pyc
DELETED
|
Binary file (6.91 kB)
|
|
|
tools/__pycache__/logging_config.cpython-312.pyc
DELETED
|
Binary file (5.33 kB)
|
|
|
tools/__pycache__/monitoring.cpython-312.pyc
DELETED
|
Binary file (13 kB)
|
|
|
tools/__pycache__/security.cpython-312.pyc
DELETED
|
Binary file (27.1 kB)
|
|
|
tools/__pycache__/stats.cpython-312.pyc
DELETED
|
Binary file (15.8 kB)
|
|
|
tools/__pycache__/system_status.cpython-312.pyc
DELETED
|
Binary file (6.75 kB)
|
|
|
tools/__pycache__/timezone_tools.cpython-312.pyc
DELETED
|
Binary file (6.34 kB)
|
|
|
tools/__pycache__/validation.cpython-312.pyc
DELETED
|
Binary file (8.79 kB)
|
|
|
tools/__pycache__/weather.cpython-312.pyc
DELETED
|
Binary file (5.63 kB)
|
|
|
ui.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Gradio UI implementation for the AI Assistant application.
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
import gradio as gr
|
| 6 |
+
import logging
|
| 7 |
+
from typing import Callable, Optional
|
| 8 |
+
from config import UIConfig
|
| 9 |
+
|
| 10 |
+
logger = logging.getLogger(__name__)
|
| 11 |
+
|
| 12 |
+
class AssistantUI:
|
| 13 |
+
"""Gradio UI implementation for the AI Assistant."""
|
| 14 |
+
|
| 15 |
+
def __init__(self, callback: Callable[[str], str], config: Optional[UIConfig] = None):
|
| 16 |
+
"""
|
| 17 |
+
Initialize the UI.
|
| 18 |
+
|
| 19 |
+
Args:
|
| 20 |
+
callback: Function to process user input and return response
|
| 21 |
+
config: UI configuration settings
|
| 22 |
+
"""
|
| 23 |
+
self.callback = callback
|
| 24 |
+
self.config = config or UIConfig()
|
| 25 |
+
self.interface = None
|
| 26 |
+
|
| 27 |
+
def process_input(self, message: str) -> str:
|
| 28 |
+
"""
|
| 29 |
+
Process user input through the callback function.
|
| 30 |
+
|
| 31 |
+
Args:
|
| 32 |
+
message: User input message
|
| 33 |
+
|
| 34 |
+
Returns:
|
| 35 |
+
str: Assistant's response
|
| 36 |
+
"""
|
| 37 |
+
try:
|
| 38 |
+
if not message.strip():
|
| 39 |
+
return "Please enter a message."
|
| 40 |
+
|
| 41 |
+
response = self.callback(message)
|
| 42 |
+
logger.info(f"Processed input: {message[:100]}...")
|
| 43 |
+
return response
|
| 44 |
+
except Exception as e:
|
| 45 |
+
error_msg = f"Error processing input: {str(e)}"
|
| 46 |
+
logger.error(error_msg)
|
| 47 |
+
return error_msg
|
| 48 |
+
|
| 49 |
+
def launch(self, **kwargs) -> None:
|
| 50 |
+
"""Launch the Gradio interface."""
|
| 51 |
+
try:
|
| 52 |
+
self.interface = gr.Interface(
|
| 53 |
+
fn=self.process_input,
|
| 54 |
+
inputs=gr.Textbox(
|
| 55 |
+
placeholder="Enter your message here...",
|
| 56 |
+
label="User Input"
|
| 57 |
+
),
|
| 58 |
+
outputs=gr.Textbox(label="Assistant Response"),
|
| 59 |
+
title=self.config.title,
|
| 60 |
+
description=self.config.description,
|
| 61 |
+
theme=self.config.theme,
|
| 62 |
+
allow_flagging=self.config.allow_flagging
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
self.interface.launch(**kwargs)
|
| 66 |
+
logger.info("UI launched successfully")
|
| 67 |
+
except Exception as e:
|
| 68 |
+
error_msg = f"Error launching UI: {str(e)}"
|
| 69 |
+
logger.error(error_msg)
|
| 70 |
+
raise RuntimeError(error_msg)
|