init
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Main entry point for the LangChain + LangGraph scaffolding project
|
||||
LangChain + LangGraph 脚手架项目主入口
|
||||
"""
|
||||
|
||||
import sys
|
||||
@@ -9,11 +9,14 @@ from workflows.workflow_manager import WorkflowManager, WorkflowType
|
||||
|
||||
|
||||
def interactive_cli():
|
||||
"""Interactive command-line interface"""
|
||||
"""交互式命令行界面"""
|
||||
print("🚀 LangChain + LangGraph Scaffolding")
|
||||
print("=" * 50)
|
||||
|
||||
manager = WorkflowManager()
|
||||
# 允许通过命令行指定模型配置段,例如 python main.py gpt-3.5-turbo
|
||||
model_section = sys.argv[1] if len(sys.argv) > 1 else None
|
||||
|
||||
manager = WorkflowManager(default_model_section=model_section)
|
||||
|
||||
while True:
|
||||
print("\nAvailable workflows:")
|
||||
@@ -37,7 +40,7 @@ def interactive_cli():
|
||||
print("Invalid choice")
|
||||
continue
|
||||
|
||||
# Interactive session
|
||||
# 交互会话
|
||||
session_id = None
|
||||
while True:
|
||||
user_input = input("\nYou: ").strip()
|
||||
@@ -57,12 +60,12 @@ def interactive_cli():
|
||||
|
||||
session_id = result['session_id']
|
||||
|
||||
# Extract and display the response
|
||||
# 提取并显示回复
|
||||
last_message = result['result']['messages'][-1]
|
||||
if hasattr(last_message, 'content'):
|
||||
if hasattr(last_message, 'content') and last_message.content:
|
||||
print(f"AI: {last_message.content}")
|
||||
|
||||
# Show tool usage if any
|
||||
# 如有工具调用则显示
|
||||
if hasattr(last_message, 'tool_calls') and last_message.tool_calls:
|
||||
print(f"🔧 Tools used: {[tc['name'] for tc in last_message.tool_calls]}")
|
||||
|
||||
@@ -77,7 +80,7 @@ def interactive_cli():
|
||||
|
||||
|
||||
def main():
|
||||
"""Main function"""
|
||||
"""主函数"""
|
||||
try:
|
||||
from config import Config
|
||||
Config.validate_config()
|
||||
@@ -85,8 +88,8 @@ def main():
|
||||
except Exception as e:
|
||||
print(f"❌ Configuration error: {e}")
|
||||
print("\nPlease make sure to:")
|
||||
print("1. Copy .env.example to .env")
|
||||
print("2. Set your OPENAI_API_KEY in the .env file")
|
||||
print("1. Copy 'config/config.ini.example' to 'config/config.ini'")
|
||||
print("2. Set your API key in the 'config/config.ini' file")
|
||||
print("3. Install dependencies: pip install -r requirements.txt")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user