mirror of
https://github.com/OpenBMB/ChatDev.git
synced 2026-09-10 05:59:20 +00:00
chores: improve docstring
This commit is contained in:
parent
6d1aa211fe
commit
40ac5f8c16
23
.env.example
23
.env.example
@ -1,24 +1,17 @@
|
|||||||
# ============================================================================
|
# ============================================================================
|
||||||
# LLM Provider Configuration (OpenAI-Compatible API)
|
# LLM Provider Configuration
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# This project supports any OpenAI-compatible API provider.
|
# BASE_URL and API_KEY are the standard configurations for model call authentication.
|
||||||
# Configure BASE_URL, API_KEY, and MODEL_NAME based on your chosen provider.
|
# These variables support OpenAI, Gemini, LM Studio, Ollama, and other providers.
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
|
||||||
# Option 1: OpenAI
|
|
||||||
# ----------------------------------------------------------------------------
|
|
||||||
BASE_URL=https://api.openai.com/v1
|
BASE_URL=https://api.openai.com/v1
|
||||||
API_KEY=sk-your-openai-api-key-here
|
API_KEY=sk-your-openai-api-key-here
|
||||||
MODEL_NAME=gpt-4o
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
# Example BASE_URL values:
|
||||||
# Option 2: Other OpenAI-Compatible Providers
|
# - OpenAI: https://api.openai.com/v1
|
||||||
# ----------------------------------------------------------------------------
|
# - Gemini: https://generativelanguage.googleapis.com/v1beta/openai/
|
||||||
# Example for LM Studio
|
# - LM Studio: http://localhost:1234/v1
|
||||||
|
# - Ollama: http://localhost:11434/v1
|
||||||
# BASE_URL=http://localhost:1234/v1
|
|
||||||
# API_KEY=lm-studio
|
|
||||||
# MODEL_NAME=local-model
|
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# Optional: Web Search and Reading Tools
|
# Optional: Web Search and Reading Tools
|
||||||
|
|||||||
@ -1,3 +1,21 @@
|
|||||||
|
"""
|
||||||
|
Synchronize YAML Configurations to VueGraph Database
|
||||||
|
|
||||||
|
This tool uploads local YAML workflow configurations from the yaml_instance/
|
||||||
|
directory to the VueGraph database via the API endpoint. This is essential for
|
||||||
|
making workflow configurations available to the frontend visualization system.
|
||||||
|
|
||||||
|
Purpose:
|
||||||
|
- Ensures the database reflects the latest YAML configurations
|
||||||
|
- Required after modifying workflow YAML files to see changes in the UI
|
||||||
|
- Useful for development and deployment workflows
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
python tools/sync_vuegraphs.py
|
||||||
|
# or via Makefile:
|
||||||
|
make sync
|
||||||
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
import requests
|
import requests
|
||||||
@ -8,19 +26,20 @@ from pathlib import Path
|
|||||||
API_URL = "http://localhost:6400/api/vuegraphs/upload/content"
|
API_URL = "http://localhost:6400/api/vuegraphs/upload/content"
|
||||||
YAML_DIR = "yaml_instance"
|
YAML_DIR = "yaml_instance"
|
||||||
|
|
||||||
|
|
||||||
def sync_yaml_to_vuegraphs():
|
def sync_yaml_to_vuegraphs():
|
||||||
"""Reads all YAML files and uploads them to the VueGraph database."""
|
"""Reads all YAML files and uploads them to the VueGraph database."""
|
||||||
print(f"Syncing YAML files from {YAML_DIR} to {API_URL}...")
|
print(f"Syncing YAML files from {YAML_DIR} to {API_URL}...")
|
||||||
|
|
||||||
yaml_files = glob.glob(os.path.join(YAML_DIR, "*.yaml"))
|
yaml_files = glob.glob(os.path.join(YAML_DIR, "*.yaml"))
|
||||||
|
|
||||||
for file_path in yaml_files:
|
for file_path in yaml_files:
|
||||||
try:
|
try:
|
||||||
filename = Path(file_path).stem # simulation_hospital_lmstudio
|
filename = Path(file_path).stem # simulation_hospital_lmstudio
|
||||||
|
|
||||||
with open(file_path, "r") as f:
|
with open(file_path, "r") as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
|
|
||||||
# Basic validation to ensure it's a valid YAML
|
# Basic validation to ensure it's a valid YAML
|
||||||
try:
|
try:
|
||||||
yaml.safe_load(content)
|
yaml.safe_load(content)
|
||||||
@ -29,20 +48,18 @@ def sync_yaml_to_vuegraphs():
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# Upload to VueGraph API
|
# Upload to VueGraph API
|
||||||
payload = {
|
payload = {"filename": filename, "content": content}
|
||||||
"filename": filename,
|
|
||||||
"content": content
|
|
||||||
}
|
|
||||||
|
|
||||||
response = requests.post(API_URL, json=payload)
|
response = requests.post(API_URL, json=payload)
|
||||||
|
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
print(f"Synced: {filename}")
|
print(f"Synced: {filename}")
|
||||||
else:
|
else:
|
||||||
print(f"Failed: {filename} - {response.status_code} {response.text}")
|
print(f"Failed: {filename} - {response.status_code} {response.text}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error processing {file_path}: {e}")
|
print(f"Error processing {file_path}: {e}")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
sync_yaml_to_vuegraphs()
|
sync_yaml_to_vuegraphs()
|
||||||
|
|||||||
@ -1,3 +1,22 @@
|
|||||||
|
"""
|
||||||
|
Validate All YAML Workflow Configurations
|
||||||
|
|
||||||
|
This tool performs strict validation on all YAML workflow configuration files
|
||||||
|
in the yaml_instance/ directory. It ensures configuration integrity and prevents
|
||||||
|
runtime errors by catching issues early in the development process.
|
||||||
|
|
||||||
|
Purpose:
|
||||||
|
- Validates YAML syntax and schema compliance for all workflow configurations
|
||||||
|
- Prevents invalid configurations from causing runtime failures
|
||||||
|
- Essential for CI/CD pipelines to ensure code quality
|
||||||
|
- Provides detailed error reporting for debugging
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
python tools/validate_all_yamls.py
|
||||||
|
# or via Makefile:
|
||||||
|
make validate-yamls
|
||||||
|
"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -57,7 +76,7 @@ def validate_all():
|
|||||||
failed_files.append(str(rel_path))
|
failed_files.append(str(rel_path))
|
||||||
|
|
||||||
print("\n" + "=" * 40)
|
print("\n" + "=" * 40)
|
||||||
print(f"Validation Summary")
|
print(f"YAML Validation Summary")
|
||||||
print("=" * 40)
|
print("=" * 40)
|
||||||
print(f"Total Files: {len(files)}")
|
print(f"Total Files: {len(files)}")
|
||||||
print(f"Passed: {passed}")
|
print(f"Passed: {passed}")
|
||||||
@ -67,9 +86,17 @@ def validate_all():
|
|||||||
print("\nFailed Files:")
|
print("\nFailed Files:")
|
||||||
for f in failed_files:
|
for f in failed_files:
|
||||||
print(f"- {f}")
|
print(f"- {f}")
|
||||||
|
|
||||||
|
# Overall validation status
|
||||||
|
print("\n" + "=" * 40)
|
||||||
|
print("Overall Validation Status")
|
||||||
|
print("=" * 40)
|
||||||
|
|
||||||
|
if failed > 0:
|
||||||
|
print("YAML validation: FAILED")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
print("\nAll files passed validation.")
|
print("All validations passed successfully.")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user