Skip to content

Commit

Permalink
Add search and updated get page tools. (#322)
Browse files Browse the repository at this point in the history
  • Loading branch information
dglazkov authored Apr 26, 2024
1 parent 30d02d2 commit 8ced5b7
Show file tree
Hide file tree
Showing 3 changed files with 382 additions and 6 deletions.
15 changes: 9 additions & 6 deletions seeds/team-experiments/graphs/bgl/insta/chat-with-tools.bgl.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"metadata": {
"visual": {
"x": 60,
"y": 0
"y": -1.4210854715202004e-14
}
}
}
Expand Down Expand Up @@ -95,8 +95,8 @@
"type": "human",
"metadata": {
"visual": {
"x": -77,
"y": -108
"x": -97,
"y": -175
},
"title": "Ask User",
"logLevel": "debug"
Expand All @@ -116,15 +116,18 @@
"configuration": {
"instruction": "You are a super-helpful chat bot who uses tools to help users. In cases where the tool is not applicable, you improvise and try to answer the question anyway. In situations when the user just wants to have a conversation, just have a conversation.",
"tools": [
"https://raw.githubusercontent.com/google/labs-prototypes/main/seeds/team-experiments/graphs/bgl/insta/get-page.json"
"https://raw.githubusercontent.com/google/labs-prototypes/main/seeds/team-experiments/graphs/bgl/insta/tool-get-web-page.bgl.json",
"https://raw.githubusercontent.com/google/labs-prototypes/main/seeds/team-experiments/graphs/bgl/insta/tool-search.bgl.json"
]
}
},
{
"id": "secrets-dbf8ee4c",
"type": "secrets",
"configuration": {
"keys": ["model"]
"keys": [
"model"
]
},
"metadata": {
"visual": {
Expand Down Expand Up @@ -241,4 +244,4 @@
]
}
}
}
}
195 changes: 195 additions & 0 deletions seeds/team-experiments/graphs/bgl/insta/tool-get-web-page.bgl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
{
"title": "Get Web Page Content",
"description": "Returns the contents of a web page at a given URL.",
"version": "0.0.1",
"nodes": [
{
"type": "input",
"id": "input",
"configuration": {
"schema": {
"type": "object",
"properties": {
"url": {
"type": "string",
"title": "URL",
"examples": []
}
},
"required": []
}
},
"metadata": {
"visual": {
"x": 19,
"y": 538.0000000000001
}
}
},
{
"type": "output",
"id": "output",
"configuration": {
"schema": {
"type": "object",
"properties": {
"json": {
"type": "object",
"title": "JSON",
"examples": []
}
},
"required": []
}
},
"metadata": {
"visual": {
"x": 595,
"y": 505.00000000000006
}
}
},
{
"id": "fetch-27da0eda",
"type": "fetch",
"metadata": {
"visual": {
"x": 568.0000000000001,
"y": 151
},
"title": "Scraping Bee",
"description": "Calling Scraping Bee to Get the Contents",
"logLevel": "debug"
},
"configuration": {
"method": "GET"
}
},
{
"id": "urlTemplate-77553e6f",
"type": "urlTemplate",
"configuration": {
"template": "https://app.scrapingbee.com/api/v1/?api_key={SCRAPING_BEE_KEY}&url={url}&extract_rules={extract_rules}&js_scenario={js_scenario}&json_response=true"
},
"metadata": {
"visual": {
"x": 318,
"y": 193.00000000000003
},
"title": "Scraping Bee API Template",
"logLevel": "debug"
}
},
{
"id": "secrets-197969de",
"type": "secrets",
"configuration": {
"keys": [
"SCRAPING_BEE_KEY"
]
},
"metadata": {
"visual": {
"x": 25,
"y": 4.000000000000007
},
"title": "Get API Key",
"description": "Asking for API Key",
"logLevel": "debug"
}
},
{
"id": "jsonata-02f9c069",
"type": "jsonata",
"configuration": {
"expression": "(\n $results := $eval(evaluate_results[0]);\n{ \"title\": body.title, \"body\": $results.data, \"links\": $results.links }\n)"
},
"metadata": {
"visual": {
"x": 366,
"y": 500.99999999999994
},
"title": "Format Output",
"logLevel": "debug"
}
},
{
"id": "jsonata-c018bbf7",
"type": "jsonata",
"configuration": {
"expression": "$string({ \"title\": \"title\" })",
"json": "{}"
},
"metadata": {
"visual": {
"x": 23,
"y": 165.00000000000003
},
"title": "Extract Rules",
"description": "Specifying the rules to extract content",
"logLevel": "debug"
}
},
{
"id": "jsonata-a145253b",
"type": "jsonata",
"metadata": {
"title": "JS Scenario",
"description": "Specifying JS to evaluate",
"logLevel": "debug",
"visual": {
"x": 17,
"y": 349
}
},
"configuration": {
"expression": "$string({\n \"instructions\":[ {\"evaluate\": $ }]\n})",
"json": "JSON.stringify({ data: document.body.innerText, links: Array.from(document.querySelectorAll(\"a\")).map((a) => ({ href: a.href, title: a.innerText.trim() }))})"
}
}
],
"edges": [
{
"from": "input",
"to": "urlTemplate-77553e6f",
"out": "url",
"in": "url"
},
{
"from": "urlTemplate-77553e6f",
"to": "fetch-27da0eda",
"out": "url",
"in": "url"
},
{
"from": "secrets-197969de",
"to": "urlTemplate-77553e6f",
"out": "SCRAPING_BEE_KEY",
"in": "SCRAPING_BEE_KEY"
},
{
"from": "jsonata-02f9c069",
"to": "output",
"out": "result",
"in": "text"
},
{
"from": "fetch-27da0eda",
"to": "jsonata-02f9c069",
"out": "response",
"in": "json"
},
{
"from": "jsonata-c018bbf7",
"to": "urlTemplate-77553e6f",
"out": "result",
"in": "extract_rules"
},
{
"from": "jsonata-a145253b",
"to": "urlTemplate-77553e6f",
"out": "result",
"in": "js_scenario"
}
]
}
Loading

0 comments on commit 8ced5b7

Please sign in to comment.