-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient_test.py
50 lines (42 loc) · 1.66 KB
/
client_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import os
import asyncio
from dotenv import load_dotenv
from client_bridge.config import BridgeConfig, LLMConfig
from client_bridge.bridge import BridgeManager
from server.browser_navigator_server import BrowserNavigationServer
from loguru import logger
async def main():
# Load environment variables
load_dotenv()
# Configure bridge
server = BrowserNavigationServer()
config = BridgeConfig(
mcp=server,
llm_config=LLMConfig(
azure_endpoint=os.getenv("AZURE_OPEN_AI_ENDPOINT"),
api_version=os.getenv("AZURE_OPEN_AI_API_VERSION"),
api_key=os.getenv("AZURE_OPEN_AI_API_KEY"),
deploy_name=os.getenv("AZURE_OPEN_AI_DEPLOYMENT_MODEL")
),
system_prompt="You are a helpful assistant that can use tools to help answer questions."
)
logger.info(f"Starting bridge with model: {config.llm_config.deploy_name}")
# Use bridge with context manager
async with BridgeManager(config) as bridge:
while True:
try:
user_input = input("\nEnter your prompt (or 'quit' to exit): ")
if user_input.lower() in ['quit', 'exit', 'q']:
break
response = await bridge.process_message(user_input)
print(f"\nResponse: {response}")
except KeyboardInterrupt:
logger.info("\nExiting...")
break
except Exception as e:
logger.error(f"\nError occurred: {e}")
if __name__ == "__main__":
try:
asyncio.run(main())
except Exception as e:
logger.error(f"Unhandled exception: {e}")