Skip to content

Commit 487f293

Browse files
added note on naming and fix #2951
1 parent 7a8808b commit 487f293

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

python/DEV_SETUP.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,14 @@ Example:
154154
chat_completion = OpenAIChatClient(env_file_path="openai.env")
155155
```
156156

157+
# Method naming inside connectors
158+
159+
When naming methods inside connectors, we have a loose preference for using the following conventions:
160+
- Use `_prepare_<object>_for_<purpose>` as a prefix for methods that prepare data for sending to the external service.
161+
- Use `_parse_<object>_from_<source>` as a prefix for methods that process data received from the external service.
162+
163+
This is not a strict rule, but a guideline to help maintain consistency across the codebase.
164+
157165
## Tests
158166

159167
All the tests are located in the `tests` folder of each package. There are tests that are marked with a `@skip_if_..._integration_tests_disabled` decorator, these are integration tests that require an external service to be running, like OpenAI or Azure OpenAI.

python/packages/core/agent_framework/openai/_chat_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,8 @@ def _prepare_message_for_openai(self, message: ChatMessage) -> list[dict[str, An
392392
args: dict[str, Any] = {
393393
"role": message.role.value if isinstance(message.role, Role) else message.role,
394394
}
395+
if message.author_name and message.role != Role.TOOL:
396+
args["name"] = message.author_name
395397
match content:
396398
case FunctionCallContent():
397399
if all_messages and "tool_calls" in all_messages[-1]:

0 commit comments

Comments
 (0)