Skip to content

Commit

Permalink
include helper for tool_result
Browse files Browse the repository at this point in the history
  • Loading branch information
rgbkrk committed Jan 16, 2024
1 parent 561c537 commit 71f64cc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions chatlab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
narrate,
system,
user,
tool_result
)
from .registry import FunctionRegistry
from .views.markdown import Markdown
Expand Down Expand Up @@ -85,6 +86,7 @@ def __init__(self, *args, **kwargs):
"assistant",
"assistant_function_call",
"function_result",
"tool_result",
"models",
"Session",
"Chat",
Expand Down
18 changes: 18 additions & 0 deletions chatlab/messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,24 @@ def function_result(name: str, content: str) -> ChatCompletionMessageParam:
}


def tool_result(tool_call_id: str, name: str, content: str) -> ChatCompletionMessageParam:
"""Create a tool result message.
Args:
tool_call_id: The ID of the tool call.
name: The name of the tool.
content: The content of the message.
Returns:
A dictionary representing a tool result message.
"""
return {
"role": "tool",
"content": content,
"name": name,
"tool_call_id": tool_call_id,
}

# Aliases
narrate = system
human = user
Expand Down

0 comments on commit 71f64cc

Please sign in to comment.