Spaces:
Running
Running
Gradio chat box.
Browse files
examples/LynxScribe/MCP/Multi-agent.lynxkite.json
CHANGED
|
@@ -55,6 +55,13 @@
|
|
| 55 |
"sourceHandle": "output",
|
| 56 |
"target": "Agent 2",
|
| 57 |
"targetHandle": "tools"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
}
|
| 59 |
],
|
| 60 |
"env": "LynxKite Graph Analytics",
|
|
@@ -154,12 +161,15 @@
|
|
| 154 |
"title": "MCP: Query database with SQL"
|
| 155 |
},
|
| 156 |
"dragHandle": ".drag-handle",
|
|
|
|
| 157 |
"height": 152.0,
|
| 158 |
"id": "MCP: Query database with SQL 2",
|
|
|
|
| 159 |
"position": {
|
| 160 |
-
"x": -
|
| 161 |
-
"y":
|
| 162 |
},
|
|
|
|
| 163 |
"type": "basic",
|
| 164 |
"width": 334.0
|
| 165 |
},
|
|
@@ -196,12 +206,15 @@
|
|
| 196 |
"title": "MCP: Calculator"
|
| 197 |
},
|
| 198 |
"dragHandle": ".drag-handle",
|
|
|
|
| 199 |
"height": 200.0,
|
| 200 |
"id": "MCP: Calculator 1",
|
|
|
|
| 201 |
"position": {
|
| 202 |
-
"x":
|
| 203 |
-
"y":
|
| 204 |
},
|
|
|
|
| 205 |
"type": "basic",
|
| 206 |
"width": 200.0
|
| 207 |
},
|
|
@@ -212,11 +225,11 @@
|
|
| 212 |
"dataframes": {
|
| 213 |
"service": {
|
| 214 |
"columns": [
|
| 215 |
-
"
|
| 216 |
],
|
| 217 |
"data": [
|
| 218 |
[
|
| 219 |
-
"
|
| 220 |
]
|
| 221 |
]
|
| 222 |
}
|
|
@@ -295,18 +308,22 @@
|
|
| 295 |
"title": "MCP: Financial data"
|
| 296 |
},
|
| 297 |
"dragHandle": ".drag-handle",
|
|
|
|
| 298 |
"height": 175.0,
|
| 299 |
"id": "MCP: Financial data 1",
|
|
|
|
| 300 |
"position": {
|
| 301 |
-
"x":
|
| 302 |
-
"y":
|
| 303 |
},
|
|
|
|
| 304 |
"type": "basic",
|
| 305 |
"width": 242.0
|
| 306 |
},
|
| 307 |
{
|
| 308 |
"data": {
|
| 309 |
"__execution_delay": 0.0,
|
|
|
|
| 310 |
"display": null,
|
| 311 |
"error": null,
|
| 312 |
"input_metadata": [],
|
|
@@ -351,18 +368,22 @@
|
|
| 351 |
"title": "MCP: Search web"
|
| 352 |
},
|
| 353 |
"dragHandle": ".drag-handle",
|
|
|
|
| 354 |
"height": 200.0,
|
| 355 |
"id": "MCP: Search web 1",
|
|
|
|
| 356 |
"position": {
|
| 357 |
-
"x": -
|
| 358 |
-
"y": -
|
| 359 |
},
|
|
|
|
| 360 |
"type": "basic",
|
| 361 |
"width": 200.0
|
| 362 |
},
|
| 363 |
{
|
| 364 |
"data": {
|
| 365 |
"__execution_delay": 0.0,
|
|
|
|
| 366 |
"display": null,
|
| 367 |
"error": null,
|
| 368 |
"input_metadata": [
|
|
@@ -373,7 +394,12 @@
|
|
| 373 |
"LynxScribe"
|
| 374 |
],
|
| 375 |
"color": "blue",
|
| 376 |
-
"doc":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 377 |
"id": "LynxScribe > Agent",
|
| 378 |
"inputs": [
|
| 379 |
{
|
|
@@ -432,8 +458,8 @@
|
|
| 432 |
"height": 354.0,
|
| 433 |
"id": "Agent 2",
|
| 434 |
"position": {
|
| 435 |
-
"x": -207.
|
| 436 |
-
"y": -
|
| 437 |
},
|
| 438 |
"type": "basic",
|
| 439 |
"width": 552.0
|
|
@@ -441,6 +467,7 @@
|
|
| 441 |
{
|
| 442 |
"data": {
|
| 443 |
"__execution_delay": 0.0,
|
|
|
|
| 444 |
"display": null,
|
| 445 |
"error": null,
|
| 446 |
"input_metadata": [
|
|
@@ -451,7 +478,12 @@
|
|
| 451 |
"LynxScribe"
|
| 452 |
],
|
| 453 |
"color": "blue",
|
| 454 |
-
"doc":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 455 |
"id": "LynxScribe > Agent",
|
| 456 |
"inputs": [
|
| 457 |
{
|
|
@@ -507,18 +539,22 @@
|
|
| 507 |
"title": "Agent"
|
| 508 |
},
|
| 509 |
"dragHandle": ".drag-handle",
|
|
|
|
| 510 |
"height": 336.0,
|
| 511 |
"id": "Agent 3",
|
|
|
|
| 512 |
"position": {
|
| 513 |
-
"x": -
|
| 514 |
-
"y": -
|
| 515 |
},
|
|
|
|
| 516 |
"type": "basic",
|
| 517 |
"width": 497.0
|
| 518 |
},
|
| 519 |
{
|
| 520 |
"data": {
|
| 521 |
"__execution_delay": 0.0,
|
|
|
|
| 522 |
"display": null,
|
| 523 |
"error": null,
|
| 524 |
"input_metadata": [
|
|
@@ -529,7 +565,12 @@
|
|
| 529 |
"LynxScribe"
|
| 530 |
],
|
| 531 |
"color": "blue",
|
| 532 |
-
"doc":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 533 |
"id": "LynxScribe > Agent",
|
| 534 |
"inputs": [
|
| 535 |
{
|
|
@@ -585,14 +626,62 @@
|
|
| 585 |
"title": "Agent"
|
| 586 |
},
|
| 587 |
"dragHandle": ".drag-handle",
|
|
|
|
| 588 |
"height": 352.0,
|
| 589 |
"id": "Agent 4",
|
|
|
|
| 590 |
"position": {
|
| 591 |
-
"x":
|
| 592 |
-
"y": -
|
| 593 |
},
|
|
|
|
| 594 |
"type": "basic",
|
| 595 |
"width": 444.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 596 |
}
|
| 597 |
],
|
| 598 |
"paused": false
|
|
|
|
| 55 |
"sourceHandle": "output",
|
| 56 |
"target": "Agent 2",
|
| 57 |
"targetHandle": "tools"
|
| 58 |
+
},
|
| 59 |
+
{
|
| 60 |
+
"id": "Agent 2 output Gradio chat 1 agent",
|
| 61 |
+
"source": "Agent 2",
|
| 62 |
+
"sourceHandle": "output",
|
| 63 |
+
"target": "Gradio chat 1",
|
| 64 |
+
"targetHandle": "agent"
|
| 65 |
}
|
| 66 |
],
|
| 67 |
"env": "LynxKite Graph Analytics",
|
|
|
|
| 161 |
"title": "MCP: Query database with SQL"
|
| 162 |
},
|
| 163 |
"dragHandle": ".drag-handle",
|
| 164 |
+
"extent": null,
|
| 165 |
"height": 152.0,
|
| 166 |
"id": "MCP: Query database with SQL 2",
|
| 167 |
+
"parentId": null,
|
| 168 |
"position": {
|
| 169 |
+
"x": -217.44870919686196,
|
| 170 |
+
"y": 70.34858585847527
|
| 171 |
},
|
| 172 |
+
"selected": false,
|
| 173 |
"type": "basic",
|
| 174 |
"width": 334.0
|
| 175 |
},
|
|
|
|
| 206 |
"title": "MCP: Calculator"
|
| 207 |
},
|
| 208 |
"dragHandle": ".drag-handle",
|
| 209 |
+
"extent": null,
|
| 210 |
"height": 200.0,
|
| 211 |
"id": "MCP: Calculator 1",
|
| 212 |
+
"parentId": null,
|
| 213 |
"position": {
|
| 214 |
+
"x": 734.3322911323813,
|
| 215 |
+
"y": 39.05828199753944
|
| 216 |
},
|
| 217 |
+
"selected": false,
|
| 218 |
"type": "basic",
|
| 219 |
"width": 200.0
|
| 220 |
},
|
|
|
|
| 225 |
"dataframes": {
|
| 226 |
"service": {
|
| 227 |
"columns": [
|
| 228 |
+
"markdown"
|
| 229 |
],
|
| 230 |
"data": [
|
| 231 |
[
|
| 232 |
+
"[Go to frontend](http://localhost:8501/?service=%2Fapi%2Fservice%2Flynxkite_graph_analytics%2FLynxScribe%2FMCP%2FMulti-agent.lynxkite.json%2FChat+frontend+1/chat/completions)"
|
| 233 |
]
|
| 234 |
]
|
| 235 |
}
|
|
|
|
| 308 |
"title": "MCP: Financial data"
|
| 309 |
},
|
| 310 |
"dragHandle": ".drag-handle",
|
| 311 |
+
"extent": null,
|
| 312 |
"height": 175.0,
|
| 313 |
"id": "MCP: Financial data 1",
|
| 314 |
+
"parentId": null,
|
| 315 |
"position": {
|
| 316 |
+
"x": 189.43781301714756,
|
| 317 |
+
"y": 68.28856010305702
|
| 318 |
},
|
| 319 |
+
"selected": false,
|
| 320 |
"type": "basic",
|
| 321 |
"width": 242.0
|
| 322 |
},
|
| 323 |
{
|
| 324 |
"data": {
|
| 325 |
"__execution_delay": 0.0,
|
| 326 |
+
"collapsed": false,
|
| 327 |
"display": null,
|
| 328 |
"error": null,
|
| 329 |
"input_metadata": [],
|
|
|
|
| 368 |
"title": "MCP: Search web"
|
| 369 |
},
|
| 370 |
"dragHandle": ".drag-handle",
|
| 371 |
+
"extent": null,
|
| 372 |
"height": 200.0,
|
| 373 |
"id": "MCP: Search web 1",
|
| 374 |
+
"parentId": null,
|
| 375 |
"position": {
|
| 376 |
+
"x": -544.0200138114182,
|
| 377 |
+
"y": -471.48309406184484
|
| 378 |
},
|
| 379 |
+
"selected": false,
|
| 380 |
"type": "basic",
|
| 381 |
"width": 200.0
|
| 382 |
},
|
| 383 |
{
|
| 384 |
"data": {
|
| 385 |
"__execution_delay": 0.0,
|
| 386 |
+
"collapsed": false,
|
| 387 |
"display": null,
|
| 388 |
"error": null,
|
| 389 |
"input_metadata": [
|
|
|
|
| 394 |
"LynxScribe"
|
| 395 |
],
|
| 396 |
"color": "blue",
|
| 397 |
+
"doc": [
|
| 398 |
+
{
|
| 399 |
+
"kind": "text",
|
| 400 |
+
"value": "You can connect tools, other agents, or models to the input of this agent.\n\nIf a model is connected, it has the be the only model. This agent and all its\nsub-agents will use this model."
|
| 401 |
+
}
|
| 402 |
+
],
|
| 403 |
"id": "LynxScribe > Agent",
|
| 404 |
"inputs": [
|
| 405 |
{
|
|
|
|
| 458 |
"height": 354.0,
|
| 459 |
"id": "Agent 2",
|
| 460 |
"position": {
|
| 461 |
+
"x": -207.35812276980306,
|
| 462 |
+
"y": -1046.679434496195
|
| 463 |
},
|
| 464 |
"type": "basic",
|
| 465 |
"width": 552.0
|
|
|
|
| 467 |
{
|
| 468 |
"data": {
|
| 469 |
"__execution_delay": 0.0,
|
| 470 |
+
"collapsed": false,
|
| 471 |
"display": null,
|
| 472 |
"error": null,
|
| 473 |
"input_metadata": [
|
|
|
|
| 478 |
"LynxScribe"
|
| 479 |
],
|
| 480 |
"color": "blue",
|
| 481 |
+
"doc": [
|
| 482 |
+
{
|
| 483 |
+
"kind": "text",
|
| 484 |
+
"value": "You can connect tools, other agents, or models to the input of this agent.\n\nIf a model is connected, it has the be the only model. This agent and all its\nsub-agents will use this model."
|
| 485 |
+
}
|
| 486 |
+
],
|
| 487 |
"id": "LynxScribe > Agent",
|
| 488 |
"inputs": [
|
| 489 |
{
|
|
|
|
| 539 |
"title": "Agent"
|
| 540 |
},
|
| 541 |
"dragHandle": ".drag-handle",
|
| 542 |
+
"extent": null,
|
| 543 |
"height": 336.0,
|
| 544 |
"id": "Agent 3",
|
| 545 |
+
"parentId": null,
|
| 546 |
"position": {
|
| 547 |
+
"x": -175.9678982120131,
|
| 548 |
+
"y": -469.9704493239694
|
| 549 |
},
|
| 550 |
+
"selected": false,
|
| 551 |
"type": "basic",
|
| 552 |
"width": 497.0
|
| 553 |
},
|
| 554 |
{
|
| 555 |
"data": {
|
| 556 |
"__execution_delay": 0.0,
|
| 557 |
+
"collapsed": false,
|
| 558 |
"display": null,
|
| 559 |
"error": null,
|
| 560 |
"input_metadata": [
|
|
|
|
| 565 |
"LynxScribe"
|
| 566 |
],
|
| 567 |
"color": "blue",
|
| 568 |
+
"doc": [
|
| 569 |
+
{
|
| 570 |
+
"kind": "text",
|
| 571 |
+
"value": "You can connect tools, other agents, or models to the input of this agent.\n\nIf a model is connected, it has the be the only model. This agent and all its\nsub-agents will use this model."
|
| 572 |
+
}
|
| 573 |
+
],
|
| 574 |
"id": "LynxScribe > Agent",
|
| 575 |
"inputs": [
|
| 576 |
{
|
|
|
|
| 626 |
"title": "Agent"
|
| 627 |
},
|
| 628 |
"dragHandle": ".drag-handle",
|
| 629 |
+
"extent": null,
|
| 630 |
"height": 352.0,
|
| 631 |
"id": "Agent 4",
|
| 632 |
+
"parentId": null,
|
| 633 |
"position": {
|
| 634 |
+
"x": 364.02455841898757,
|
| 635 |
+
"y": -472.6832842294044
|
| 636 |
},
|
| 637 |
+
"selected": false,
|
| 638 |
"type": "basic",
|
| 639 |
"width": 444.0
|
| 640 |
+
},
|
| 641 |
+
{
|
| 642 |
+
"data": {
|
| 643 |
+
"display": {
|
| 644 |
+
"backend": "/api/lynxkite_graph_analytics/LynxScribe/MCP/Multi-agent.lynxkite.json/Gradio%20chat%201"
|
| 645 |
+
},
|
| 646 |
+
"error": null,
|
| 647 |
+
"input_metadata": [
|
| 648 |
+
{}
|
| 649 |
+
],
|
| 650 |
+
"meta": {
|
| 651 |
+
"categories": [
|
| 652 |
+
"LynxScribe"
|
| 653 |
+
],
|
| 654 |
+
"color": "gray",
|
| 655 |
+
"doc": null,
|
| 656 |
+
"id": "LynxScribe > Gradio chat",
|
| 657 |
+
"inputs": [
|
| 658 |
+
{
|
| 659 |
+
"name": "agent",
|
| 660 |
+
"position": "bottom",
|
| 661 |
+
"type": {
|
| 662 |
+
"type": "<class 'dict'>"
|
| 663 |
+
}
|
| 664 |
+
}
|
| 665 |
+
],
|
| 666 |
+
"name": "Gradio chat",
|
| 667 |
+
"outputs": [],
|
| 668 |
+
"params": [],
|
| 669 |
+
"type": "gradio"
|
| 670 |
+
},
|
| 671 |
+
"op_id": "LynxScribe > Gradio chat",
|
| 672 |
+
"params": {},
|
| 673 |
+
"status": "done",
|
| 674 |
+
"title": "Gradio chat"
|
| 675 |
+
},
|
| 676 |
+
"dragHandle": ".drag-handle",
|
| 677 |
+
"height": 642.0,
|
| 678 |
+
"id": "Gradio chat 1",
|
| 679 |
+
"position": {
|
| 680 |
+
"x": 609.4860260783217,
|
| 681 |
+
"y": -1616.616244121314
|
| 682 |
+
},
|
| 683 |
+
"type": "gradio",
|
| 684 |
+
"width": 764.0
|
| 685 |
}
|
| 686 |
],
|
| 687 |
"paused": false
|
lynxkite-lynxscribe/pyproject.toml
CHANGED
|
@@ -21,7 +21,8 @@ lynxkite-core = { git = "https://github.com/lynxkite/lynxkite-2000", subdirector
|
|
| 21 |
lynxscribe = { git = "git+ssh://git@github.com/biggraph/lynxscribe", branch = "main" }
|
| 22 |
|
| 23 |
[tool.deptry.per_rule_ignores]
|
| 24 |
-
DEP001 = ["chromadb"]
|
|
|
|
| 25 |
|
| 26 |
[build-system]
|
| 27 |
requires = ["setuptools", "wheel", "setuptools-scm"]
|
|
|
|
| 21 |
lynxscribe = { git = "git+ssh://git@github.com/biggraph/lynxscribe", branch = "main" }
|
| 22 |
|
| 23 |
[tool.deptry.per_rule_ignores]
|
| 24 |
+
DEP001 = ["chromadb", "gradio"]
|
| 25 |
+
DEP003 = ["chromadb", "gradio"]
|
| 26 |
|
| 27 |
[build-system]
|
| 28 |
requires = ["setuptools", "wheel", "setuptools-scm"]
|
lynxkite-lynxscribe/src/lynxkite_lynxscribe/agentic.py
CHANGED
|
@@ -6,6 +6,7 @@ import typing
|
|
| 6 |
|
| 7 |
from lynxkite_core import ops
|
| 8 |
from lynxscribe.components.task_solver import TaskSolver
|
|
|
|
| 9 |
from lynxscribe.components.mcp_client import MCPClient
|
| 10 |
from lynxscribe.core.llm.base import get_llm_engine
|
| 11 |
from lynxscribe.core.models.prompts import Function, Tool
|
|
@@ -25,16 +26,32 @@ def chat_frontend(agent: dict):
|
|
| 25 |
return agent_from_dict(agent, default_model={"name": "openai", "model_name": "gpt-4.1-nano"})
|
| 26 |
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
def agent_from_dict(agent: dict, default_model: dict) -> "Agent":
|
| 29 |
agent = agent["agent"]
|
| 30 |
model = agent.get("model", default_model)
|
| 31 |
return Agent(
|
| 32 |
name=agent["name"],
|
| 33 |
description=agent["description"],
|
| 34 |
-
|
| 35 |
mcp_servers=agent["mcp_servers"],
|
| 36 |
-
model=model,
|
| 37 |
agents=[agent_from_dict(a, default_model=model) for a in agent["sub_agents"]],
|
|
|
|
| 38 |
)
|
| 39 |
|
| 40 |
|
|
@@ -158,6 +175,11 @@ class Agent:
|
|
| 158 |
temperature=0.0,
|
| 159 |
max_tool_call_steps=999,
|
| 160 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
|
| 162 |
def get_description(self, url: str) -> str:
|
| 163 |
return f"[Go to frontend]({CHAT_FRONTEND_URL}?service={url}/chat/completions)"
|
|
|
|
| 6 |
|
| 7 |
from lynxkite_core import ops
|
| 8 |
from lynxscribe.components.task_solver import TaskSolver
|
| 9 |
+
from lynxscribe.components.tool_use import LLM
|
| 10 |
from lynxscribe.components.mcp_client import MCPClient
|
| 11 |
from lynxscribe.core.llm.base import get_llm_engine
|
| 12 |
from lynxscribe.core.models.prompts import Function, Tool
|
|
|
|
| 26 |
return agent_from_dict(agent, default_model={"name": "openai", "model_name": "gpt-4.1-nano"})
|
| 27 |
|
| 28 |
|
| 29 |
+
@op("Gradio chat", color="gray", outputs=[], view="gradio")
|
| 30 |
+
def gradio_chat(agent: dict):
|
| 31 |
+
import gradio as gr
|
| 32 |
+
|
| 33 |
+
async def respond(message, chat_history):
|
| 34 |
+
await agent.init()
|
| 35 |
+
response = await agent.llm.ask([*chat_history, {"role": "user", "content": message}])
|
| 36 |
+
answer = await response.get_answer()
|
| 37 |
+
return answer
|
| 38 |
+
|
| 39 |
+
agent = agent_from_dict(agent, default_model={"name": "openai", "model_name": "gpt-4.1-nano"})
|
| 40 |
+
with gr.Blocks() as demo:
|
| 41 |
+
gr.ChatInterface(fn=respond, type="messages")
|
| 42 |
+
return demo
|
| 43 |
+
|
| 44 |
+
|
| 45 |
def agent_from_dict(agent: dict, default_model: dict) -> "Agent":
|
| 46 |
agent = agent["agent"]
|
| 47 |
model = agent.get("model", default_model)
|
| 48 |
return Agent(
|
| 49 |
name=agent["name"],
|
| 50 |
description=agent["description"],
|
| 51 |
+
prompt=agent["system_prompt"],
|
| 52 |
mcp_servers=agent["mcp_servers"],
|
|
|
|
| 53 |
agents=[agent_from_dict(a, default_model=model) for a in agent["sub_agents"]],
|
| 54 |
+
model=model,
|
| 55 |
)
|
| 56 |
|
| 57 |
|
|
|
|
| 175 |
temperature=0.0,
|
| 176 |
max_tool_call_steps=999,
|
| 177 |
)
|
| 178 |
+
self.llm = LLM(
|
| 179 |
+
engine=get_llm_engine(**self.llm_engine_params),
|
| 180 |
+
model=self.model_name,
|
| 181 |
+
tools=[*self.mcp_client.functions, *agents_as_functions],
|
| 182 |
+
)
|
| 183 |
|
| 184 |
def get_description(self, url: str) -> str:
|
| 185 |
return f"[Go to frontend]({CHAT_FRONTEND_URL}?service={url}/chat/completions)"
|
uv.lock
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|