mirror of
https://github.com/m5stack/ModuleLLM-OpenAI-Plugin.git
synced 2026-05-20 11:37:26 -07:00
[fix] Fix config.yaml PATH
This commit is contained in:
+3
-1
@@ -38,7 +38,9 @@ limiter = Limiter(key_func=get_remote_address)
|
||||
|
||||
class Config:
|
||||
def __init__(self):
|
||||
with open("config/config.yaml") as f:
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
config_path = os.path.join(current_dir, "config", "config.yaml")
|
||||
with open(config_path) as f:
|
||||
self.data = yaml.safe_load(f)
|
||||
|
||||
config = Config()
|
||||
|
||||
+12
-2
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
import logging
|
||||
import asyncio
|
||||
import yaml
|
||||
@@ -15,8 +16,17 @@ class GetModelList:
|
||||
try:
|
||||
if not self._sys_client:
|
||||
self._sys_client = SYSClient(host=self.host, port=self.port)
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
parent_dir = os.path.dirname(current_dir)
|
||||
config_path = os.path.join(parent_dir, "config", "config.yaml")
|
||||
|
||||
with open('config/config.yaml', 'r') as f:
|
||||
with open(config_path, 'r') as f:
|
||||
config = yaml.safe_load(f)
|
||||
config['models'] = {}
|
||||
with open(config_path, 'w') as f:
|
||||
yaml.safe_dump(config, f, default_flow_style=False, sort_keys=False)
|
||||
|
||||
with open(config_path, 'r') as f:
|
||||
config = yaml.safe_load(f)
|
||||
models_config = config.get('models', {})
|
||||
model_list = await self._get_model_list()
|
||||
@@ -84,7 +94,7 @@ class GetModelList:
|
||||
|
||||
models_config[mode] = new_entry
|
||||
config['models'] = models_config
|
||||
with open('config/config.yaml', 'w') as f:
|
||||
with open(config_path, 'w') as f:
|
||||
yaml.safe_dump(config, f, default_flow_style=False, sort_keys=False)
|
||||
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user