Spaces:
Runtime error
Runtime error
Commit
·
4992462
1
Parent(s):
eb5a3fb
Fixed minor issues
Browse files- .idea/misc.xml +1 -1
- main/config.yaml +1 -1
- main/main.py +24 -8
.idea/misc.xml
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
<component name="Black">
|
| 4 |
<option name="sdkName" value="Python 3.13 (Inference-API)" />
|
| 5 |
</component>
|
| 6 |
-
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="Python 3.
|
| 7 |
<output url="file://$PROJECT_DIR$/out" />
|
| 8 |
</component>
|
| 9 |
</project>
|
|
|
|
| 3 |
<component name="Black">
|
| 4 |
<option name="sdkName" value="Python 3.13 (Inference-API)" />
|
| 5 |
</component>
|
| 6 |
+
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="Python 3.12 (Inference-API)" project-jdk-type="Python SDK">
|
| 7 |
<output url="file://$PROJECT_DIR$/out" />
|
| 8 |
</component>
|
| 9 |
</project>
|
main/config.yaml
CHANGED
|
@@ -6,7 +6,7 @@ server:
|
|
| 6 |
|
| 7 |
llm_server:
|
| 8 |
host: "teamgenki-llmserver.hf.space"
|
| 9 |
-
port:
|
| 10 |
timeout: 60.0
|
| 11 |
api_prefix: "/api/v1" # This will be used for route prefixing
|
| 12 |
endpoints:
|
|
|
|
| 6 |
|
| 7 |
llm_server:
|
| 8 |
host: "teamgenki-llmserver.hf.space"
|
| 9 |
+
port: 7680 # Will be ignored for hf.space URLs
|
| 10 |
timeout: 60.0
|
| 11 |
api_prefix: "/api/v1" # This will be used for route prefixing
|
| 12 |
endpoints:
|
main/main.py
CHANGED
|
@@ -15,6 +15,16 @@ from .api import InferenceApi
|
|
| 15 |
_WORKER_PROCESSES = []
|
| 16 |
_MANAGER = None
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
def setup_logging():
|
| 19 |
"""Set up basic logging configuration"""
|
| 20 |
logging.basicConfig(
|
|
@@ -23,15 +33,10 @@ def setup_logging():
|
|
| 23 |
)
|
| 24 |
return logging.getLogger(__name__)
|
| 25 |
|
| 26 |
-
def load_config():
|
| 27 |
-
"""Load configuration from config.yaml"""
|
| 28 |
-
config_path = Path(__file__).parent / "config.yaml"
|
| 29 |
-
with open(config_path) as f:
|
| 30 |
-
return yaml.safe_load(f)
|
| 31 |
|
| 32 |
def create_app():
|
| 33 |
"""Create and configure the application instance."""
|
| 34 |
-
global _WORKER_PROCESSES, _MANAGER
|
| 35 |
|
| 36 |
logger = setup_logging()
|
| 37 |
|
|
@@ -46,7 +51,6 @@ def create_app():
|
|
| 46 |
else:
|
| 47 |
logger.warning("No Hugging Face access token found")
|
| 48 |
|
| 49 |
-
config = load_config()
|
| 50 |
server_config = config.get('server', {})
|
| 51 |
|
| 52 |
# Initialize API with config
|
|
@@ -88,4 +92,16 @@ def create_app():
|
|
| 88 |
return app
|
| 89 |
|
| 90 |
# Create the app instance for uvicorn
|
| 91 |
-
app = create_app()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
_WORKER_PROCESSES = []
|
| 16 |
_MANAGER = None
|
| 17 |
|
| 18 |
+
|
| 19 |
+
def load_config():
|
| 20 |
+
"""Load configuration from config.yaml"""
|
| 21 |
+
config_path = Path(__file__).parent / "config.yaml"
|
| 22 |
+
with open(config_path) as f:
|
| 23 |
+
return yaml.safe_load(f)
|
| 24 |
+
|
| 25 |
+
config = load_config()
|
| 26 |
+
|
| 27 |
+
|
| 28 |
def setup_logging():
|
| 29 |
"""Set up basic logging configuration"""
|
| 30 |
logging.basicConfig(
|
|
|
|
| 33 |
)
|
| 34 |
return logging.getLogger(__name__)
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
def create_app():
|
| 38 |
"""Create and configure the application instance."""
|
| 39 |
+
global _WORKER_PROCESSES, _MANAGER, config
|
| 40 |
|
| 41 |
logger = setup_logging()
|
| 42 |
|
|
|
|
| 51 |
else:
|
| 52 |
logger.warning("No Hugging Face access token found")
|
| 53 |
|
|
|
|
| 54 |
server_config = config.get('server', {})
|
| 55 |
|
| 56 |
# Initialize API with config
|
|
|
|
| 92 |
return app
|
| 93 |
|
| 94 |
# Create the app instance for uvicorn
|
| 95 |
+
app = create_app()
|
| 96 |
+
|
| 97 |
+
if __name__ == "__main__":
|
| 98 |
+
# Run the app with uvicorn
|
| 99 |
+
import uvicorn
|
| 100 |
+
host = config["server"]["host"]
|
| 101 |
+
port = config["server"]["port"]
|
| 102 |
+
uvicorn.run(
|
| 103 |
+
app,
|
| 104 |
+
host=host,
|
| 105 |
+
port=port,
|
| 106 |
+
log_level=config["logging"]["level"].lower()
|
| 107 |
+
)
|