Skip to content

Commit 6387f64

Browse files
committed
use code blocks for long signatures to rid ugly wrapping
1 parent d2b2389 commit 6387f64

File tree

1 file changed

+63
-10
lines changed

1 file changed

+63
-10
lines changed

content/docs/extensions/server.mdx

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ When creating a server extension, you work with an `ExtensionContext` instance t
294294
```python
295295
def init(ctx: ExtensionContext):
296296
# Your extension initialization code here
297-
ctx.register_tool(my_tool_function)
297+
ctx.register_tool(my_tool_function, group="my_tools")
298298
ctx.add_get("status", handle_status)
299299
```
300300

@@ -542,7 +542,8 @@ ctx.register_shutdown_handler(cleanup)
542542

543543
### Tool Registration
544544

545-
#### `register_tool(func: Callable, tool_def: Optional[Dict] = None, group: Optional[str] = None)`
545+
#### `register_tool(func:Callable, tool_def:Optional[Dict]=None, group:Optional[str]=None)`
546+
546547
Register a tool function that LLMs can invoke.
547548

548549
```python
@@ -579,7 +580,12 @@ Process a tool definition to inline `$defs` references.
579580

580581
### Tool Execution
581582

582-
#### `async exec_tool(name: str, args: Dict[str, Any]) -> Tuple[Optional[str], List[Dict[str, Any]]]`
583+
584+
```python
585+
async exec_tool(name: str, args: Dict[str, Any])
586+
-> Tuple[Optional[str], List[Dict[str, Any]]]
587+
```
588+
583589
Execute a registered tool by name.
584590

585591
```python
@@ -590,10 +596,23 @@ The `text` captures the tool text response that can be embedded in AI Messages a
590596

591597
The `resources` contains a list of artifacts extracted from the tool results in the same structure as [Open AI content types](https://platform.openai.com/docs/api-reference/chat/create#chat_create-messages-user_message-content).
592598

593-
#### `tool_result(result: Any, function_name: Optional[str] = None, function_args: Optional[Dict] = None) -> Dict[str, Any]`
599+
```python
600+
tool_result(result: Any,
601+
function_name: Optional[str] = None,
602+
function_args: Optional[Dict] = None)
603+
-> Dict[str, Any]
604+
```
605+
594606
Format a tool execution result for return to the LLM.
595607

596-
#### `tool_result_part(result: Dict, function_name: Optional[str] = None, function_args: Optional[Dict] = None) -> Dict[str, Any]`
608+
609+
```python
610+
tool_result_part(result: Dict,
611+
function_name: Optional[str] = None,
612+
function_args: Optional[Dict] = None)
613+
-> Dict[str, Any]
614+
```
615+
597616
Format a partial tool result.
598617

599618
#### `to_content(result: Any) -> str`
@@ -603,7 +622,15 @@ Convert a result to string content.
603622

604623
### Chat Utilities
605624

606-
#### `chat_request(template: Optional[str] = None, text: Optional[str] = None, model: Optional[str] = None, system_prompt: Optional[str] = None) -> Dict[str, Any]`
625+
```python
626+
chat_request(
627+
template: Optional[str] = None,
628+
text: Optional[str] = None,
629+
model: Optional[str] = None,
630+
system_prompt: Optional[str] = None)
631+
-> Dict[str, Any]
632+
```
633+
607634
Create a chat request object.
608635

609636
```python
@@ -666,7 +693,11 @@ data = ctx.json_from_file("/path/to/config.json")
666693
#### `download_file(url: str) -> Tuple[bytes, Dict[str, Any]]`
667694
Download a file from a URL. Returns bytes and metadata.
668695

669-
#### `session_download_file(session: aiohttp.ClientSession, url: str) -> Tuple[bytes, Dict[str, Any]]`
696+
```python
697+
session_download_file(session: aiohttp.ClientSession, url: str)
698+
-> Tuple[bytes, Dict[str, Any]]
699+
```
700+
670701
Download a file using an existing aiohttp session.
671702

672703
#### `read_binary_file(url: str) -> Tuple[bytes, Dict[str, Any]]`
@@ -683,14 +714,29 @@ Get the full path to a cache location.
683714
cache_file = ctx.get_cache_path("my_extension/data.json")
684715
```
685716

686-
#### `save_image_to_cache(base64_data: Union[str, bytes], filename: str, image_info: Dict[str, Any], ignore_info: bool = False) -> Tuple[str, Optional[Dict[str, Any]]]`
717+
```python
718+
save_image_to_cache(
719+
base64_data: Union[str, bytes],
720+
filename: str,
721+
image_info: Dict[str, Any],
722+
ignore_info: bool = False)
723+
-> Tuple[str, Optional[Dict[str, Any]]]
724+
```
725+
687726
Save image data to the cache. Returns the cache path and info.
688727

689728
```python
690729
path, info = ctx.save_image_to_cache(b64_data, "output.png", {"prompt": "..."})
691730
```
692731

693-
#### `save_bytes_to_cache(bytes_data: Union[str, bytes], filename: str, file_info: Optional[Dict[str, Any]]) -> Tuple[str, Optional[Dict[str, Any]]]`
732+
```python
733+
save_bytes_to_cache(
734+
bytes_data: Union[str, bytes],
735+
filename: str,
736+
file_info: Optional[Dict[str, Any]])
737+
-> Tuple[str, Optional[Dict[str, Any]]]
738+
```
739+
694740
Save binary data to the cache.
695741

696742
#### `cache_message_inline_data(message: Dict[str, Any])`
@@ -785,7 +831,14 @@ Get the MIME type for a filename.
785831
mime = ctx.get_file_mime_type("image.png") # "image/png"
786832
```
787833

788-
#### `to_file_info(chat: Dict[str, Any], info: Optional[Dict] = None, response: Optional[Dict] = None) -> Dict[str, Any]`
834+
```python
835+
to_file_info(
836+
chat: Dict[str, Any],
837+
info: Optional[Dict] = None,
838+
response: Optional[Dict] = None)
839+
-> Dict[str, Any]
840+
```
841+
789842
Create file info metadata from chat/response data.
790843

791844
#### `group_resources(resources: List[Dict[str, Any]]) -> Dict[str, List[Dict[str, Any]]]`

0 commit comments

Comments
 (0)