File tree Expand file tree Collapse file tree 3 files changed +31
-6
lines changed
Expand file tree Collapse file tree 3 files changed +31
-6
lines changed Original file line number Diff line number Diff line change 44
55## Getting started
66
7- 1 . Install the dependencies
7+ 1 . update [ config.json] ( config.json ) with your own OpenAI API key etc.
8+ > You need to modify the values corresponding to model_name and base_url.
9+
10+ ``` json
11+
12+ {
13+ "model_name" :" qwen3-32b" ,
14+ "api_key" : " API_KEY" ,
15+ "base_url" : " https://dashscope.aliyuncs.com/compatible-mode/v1"
16+ }
17+ ```
18+ 2 . Create an environment file with your API key:
19+ > You need to set the value corresponding to API_KEY.
20+
21+ ``` bash
22+ echo " API_KEY=your_api_key_here" > .env
23+ ```
24+
25+ 3 . Install the dependencies
826 ``` bash
927 cd ~ /a2a-python/
1028 pip install .
1129 ```
1230
13- 2 . Start the server
31+ 4 . Start the server
1432 ``` bash
1533 uv run .
1634 ```
1735
18- 3 . Run the test client
36+ 5 . Run the test client
1937 ` ` ` bash
2038 uv run loop_client.py
2139 ` ` `
Original file line number Diff line number Diff line change 11from langchain_openai import ChatOpenAI
22from langchain_core .messages import HumanMessage , SystemMessage
3- import json ,asyncio
3+ import json
4+ import sys
5+ import os
6+
47from collections .abc import AsyncGenerator
58
69class TravelPlannerAgent :
@@ -11,10 +14,14 @@ def __init__(self):
1114 try :
1215 with open ("config.json" ) as f :
1316 config = json .load (f )
17+ if not os .getenv (config ["api_key" ]):
18+ print (f'{ config ["api_key" ]} environment variable not set.' )
19+ sys .exit (1 )
20+ api_key = os .getenv (config ["api_key" ])
1421 self .model = ChatOpenAI (
1522 model = config ["model_name" ],
1623 base_url = config ["base_url" ],
17- api_key = config [ " api_key" ] ,
24+ api_key = api_key ,
1825 temperature = 0.7 # Control the generation randomness (0-2, higher values indicate greater randomness)
1926 )
2027 except FileNotFoundError :
Original file line number Diff line number Diff line change 11{
22 "model_name" :" qwen3-32b" ,
3- "api_key" : " sk-74e8a7c32e2741ff892844597dcc31c1 " ,
3+ "api_key" : " API_KEY " ,
44 "base_url" : " https://dashscope.aliyuncs.com/compatible-mode/v1"
55}
You can’t perform that action at this time.
0 commit comments