Replies: 3 comments 1 reply
|
This works, got confused by the "array" thing in the input, fixed, and with this documented :-) is there any way to define the array insde the args? |
0 replies
|
Hi @eloycoto, yes the above is the correct way. In the first example, the In the above example, in the |
1 reply
|
Ok, at the end, the PDL which implement the function to call the models with tools that can be reused looks like this: description: TEST
defs:
test:
function:
messages : obj
return:
"${ messages }"
retrieve_stock_for_item:
function:
product_name: str
return:
lang: python
code: |
import random
san_francisco_stock = random.randint(1, 100)
palo_alto_stock = random.randint(1, 30)
mountain_view_stock = random.randint(1, 60)
inventory_report = (
f"The current stock in the stores for {product_name} is the following: \n"
f"- {san_francisco_stock} devices in San Francisco\n"
f"- {palo_alto_stock} devices in Palo Alto\n"
f"- {mountain_view_stock} devices in Mountain view store\n"
)
result = inventory_report;
model_call_with_tools:
function:
model: str
temperature: int
messages: list
tools: list
return:
lastOf:
# This is to send the messages to the model context, so the loop after
# always pick the initial messages
- for:
msg: ${messages}
repeat:
text:
- def: "parse_messages"
contribute:
- context:
value:
- role: "${msg.role}"
content: "${ msg.content }"
- def: finished
contribute: []
text: "false"
- repeat:
text:
- model: ${ model }
modelResponse: out
contribute: []
parameters:
temperature: ${ temperature }
tools: ${tools}
- if: ${ out.choices[0].finish_reason == 'tool_calls'}
then:
text:
- for:
item: ${ out.choices[0].message.tool_calls }
repeat:
text:
- def: tool_arguments
text: ${ item.function.arguments }
parser: json
contribute: []
- def: functionRes
call: ${ item.function.name }
args: "${ tool_arguments }"
contribute:
- context:
value:
- role: "tool"
tool_call_id: "${ item.id }"
name: "${ item.function.name }"
content: "${ functionRes }"
- if: ${ out.choices[0].finish_reason == 'stop'}
then:
text:
- def: finished
contribute: []
text: "true"
# We need to contribute to the result the lastest message
# just to be used by the function results
- "${out.choices[0].message.content}"
until: ${ finished == "true" }
text:
- call: model_call_with_tools
args:
model: openai/llama3.2:3b
temperature: 0
messages:
- role: system
content: "You're a helpful assintant"
- role: user
content: "Do you have any stock for Iphone 8 or Google Pixel 9?"
tools:
- type: function
function:
name: retrieve_stock_for_item
description: Get the stock information for the given product
parameters:
type: object
properties:
product_name:
type: string
description: The product name to check the stock.
required:
- product_name
|
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I'm trying to do an abstraction of my LLM calls using function, for that I do this:
So, I can use like this:
But, I have the following issues when using an obj for messages, it doesn't parse as BlockType in the ast.
Full example:
All reactions