|
7 | 7 |
|
8 | 8 | from agents import Agent, OpenAIChatCompletionsModel, Runner, function_tool, set_tracing_disabled
|
9 | 9 |
|
10 |
| -BASE_URL = os.getenv("EXAMPLE_BASE_URL") or "" |
11 |
| -API_KEY = os.getenv("EXAMPLE_API_KEY") or "" |
12 |
| -MODEL_NAME = os.getenv("EXAMPLE_MODEL_NAME") or "" |
| 10 | +BASE_URL = os.getenv("EXAMPLE_BASE_URL") or "https://aigc.sankuai.com/v1/openai/native" |
| 11 | +API_KEY = os.getenv("EXAMPLE_API_KEY") or "1891455646399500337" |
| 12 | +MODEL_NAME = os.getenv("EXAMPLE_MODEL_NAME") or "anthropic.claude-3.7-sonnet" |
13 | 13 |
|
14 | 14 | if not BASE_URL or not API_KEY or not MODEL_NAME:
|
15 | 15 | raise ValueError(
|
@@ -61,7 +61,7 @@ def write_file(filename: str, content: str) -> str:
|
61 | 61 | if event.type == "raw_response_event":
|
62 | 62 | # Function call started
|
63 | 63 | if event.data.type == "response.output_item.added":
|
64 |
| - if hasattr(event.data.item, 'name'): |
| 64 | + if getattr(event.data.item, "type", None) == "function_call": |
65 | 65 | function_name = event.data.item.name
|
66 | 66 | print(f"📞 Function call streaming started: {function_name}()")
|
67 | 67 | print("📝 Arguments building...")
|
@@ -148,7 +148,7 @@ def add_readme(project_name: str, description: str) -> str:
|
148 | 148 | if event.type == "raw_response_event":
|
149 | 149 | # Function call started
|
150 | 150 | if event.data.type == "response.output_item.added":
|
151 |
| - if hasattr(event.data.item, 'name') and hasattr(event.data.item, 'call_id'): |
| 151 | + if getattr(event.data.item, "type", None) == "function_call": |
152 | 152 | output_index = event.data.output_index
|
153 | 153 | function_name = event.data.item.name
|
154 | 154 | call_id = event.data.item.call_id
|
|
0 commit comments