Closed devmao closed 2 months ago
Thanks! Gonna take a look. Are you running this in a jupyter notebook or just normal py?
Thanks! Gonna take a look. Are you running this in a jupyter notebook or just normal py?
jupyter
To get the text out you need the last line of the example to be:
- print("Weather info:", tool_results.text)
+ print("Weather info:", tool_results.tool_results[0].result[0].text)
To get the text out you need the last line of the example to be:
- print("Weather info:", tool_results.text) + print("Weather info:", tool_results.tool_results[0].result[0].text)
I know, but it seems to me not ideal based on the function call_tools_and_collect_as_message()
intent.
Yeah I agree this is not great :)
Would this be better?
print("Weather info:", message.tool_results[0].text)
Would you rather it look like:
│ assistant: Certainly, I'll file the claim draft for you with the information we have.
│ I'll use today's date and make some assumptions based on what you've told
│ me, but please note that you may need to provide more details later in the
│ process.
│ I'll go ahead and create the claim draft now:
│ ToolCall(tool=<function create_claim_draft at 0x106ecc4a0>,
│ tool_call_id='toolu_015R3MrU1RpnRLfLrpApZL4L',
│ params=create_claim_draft(claim_details='Car was smashed by someone else.
│ Further details pending investigation.', claim_type='Collision',
│ claim_amount=5000.0, claim_date='2023-05-24'))
│
│ user: ToolResult(tool_call_id='toolu_015R3MrU1RpnRLfLrpApZL4L',
│ result=[ContentBlock(text=claim_id-123234)])
│ assistant: Thank you for providing that information. I understand that your car was
│ smashed by someone else today, and you estimate the damage to be around
│ $5,000. Let's create a claim draft based on this information. I'll need
│ to use today's date for the claim.
│ I'm going to create a claim draft for you now using the information
│ you've provided. Here's what I'm going to do:
│ ToolCall(tool=<function create_claim_draft at 0x1056ac4a0>,
│ tool_call_id='toolu_01Vxzv7sS5zwokJFGTFk6cGE',
│ params=create_claim_draft(claim_details='Car was smashed by another
│ vehicle. Damage estimated at $5,000.', claim_type='Collision',
│ claim_amount=5000.0, claim_date='2023-05-30'))
│
│ user: claim_id-123234
for
@ell.tool()
def create_claim_draft(claim_details: str, claim_type: str, claim_amount: float,
claim_date : str = Field(description="The date of the claim in the format YYYY-MM-DD.")):
"""Create a claim draft. Returns the claim id created."""
print("Create claim draft", claim_details, claim_type, claim_amount, claim_date)
return "claim_id-123234"
@ell.tool()
def approve_claim(claim_id : str):
"""Approve a claim"""
return "approved"
@ell.complex(model="claude-3-5-sonnet-20240620", tools=[create_claim_draft, approve_claim], temperature=0.1, max_tokens=400)
def insurance_claim_chatbot(message_history: List[Message]) -> List[Message]:
return [
ell.system( """You are a an insurance adjuster AI. You are given a dialogue with a user and have access to various tools to effectuate the insurance claim adjustment process. Ask question until you have enough information to create a claim draft. Then ask for approval."""),
] + message_history
I feel like you'd miss that "claim_id-123234" is a tool result on first glance.
we could make the repr readable also
│ assistant: Thank you for providing that information. I understand that your car was
│ smashed by someone else today, and you estimate the damage to be around
│ $5,000. Let's create a claim draft based on this information.
│ First, I'll need to use today's date for the claim. I'll proceed with
│ creating a claim draft using the information you've provided.
│ ToolCall(create_claim_draft(claim_details='Car was smashed by another
│ party. Estimated damage: $5,000.' claim_type='Auto Collision'
│ claim_amount=5000.0 claim_date='2023-05-30'),
│ tool_call_id=toolu_01G76pfqEpBGgxQx7Gi3yL1z)
│
│ user: ToolResult(tool_call_id=toolu_01G76pfqEpBGgxQx7Gi3yL1z,
│ result=claim_id-123234)
See: https://github.com/MadcowD/ell/pull/239 for what I mean
fuckit we're goign to go with the readable repr for now since we're pre 0.1.0 and i'm fine for breaking changes here until we resolve this conversation cc @alex-dixon
Description
Running this "tool usage" example from the doc doesn't output the tool result as expected:
Moreover, when a tool uses a
Field
to provide an argument description, the lexical closure fails.Env