liuhua liuhua commited on
Commit
d3d83ec
·
1 Parent(s): 1d4ba3c

Add sdk for list agents and sessions (#3848)

Browse files

### What problem does this PR solve?

Add sdk for list agents and sessions

### Type of change

- [x] New Feature (non-breaking change which adds functionality)

Co-authored-by: liuhua <[email protected]>

docs/references/http_api_reference.md CHANGED
@@ -2364,4 +2364,1162 @@ Failure:
2364
  }
2365
  ```
2366
 
2367
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2364
  }
2365
  ```
2366
 
2367
+ ---
2368
+
2369
+ ## List agent sessions
2370
+
2371
+ **GET** `/api/v1/agents/{agent_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&id={session_id}`
2372
+
2373
+ Lists sessions associated with a specified agent.
2374
+
2375
+ ### Request
2376
+
2377
+ - Method: GET
2378
+ - URL: `/api/v1/agents/{agent_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&id={session_id}`
2379
+ - Headers:
2380
+ - `'Authorization: Bearer <YOUR_API_KEY>'`
2381
+
2382
+ #### Request example
2383
+
2384
+ ```bash
2385
+ curl --request GET \
2386
+ --url http://{address}/api/v1/agents/{agent_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&id={session_id} \
2387
+ --header 'Authorization: Bearer <YOUR_API_KEY>'
2388
+ ```
2389
+
2390
+ #### Request Parameters
2391
+
2392
+ - `agent_id`: (*Path parameter*)
2393
+ The ID of the associated agent.
2394
+ - `page`: (*Filter parameter*), `integer`
2395
+ Specifies the page on which the sessions will be displayed. Defaults to `1`.
2396
+ - `page_size`: (*Filter parameter*), `integer`
2397
+ The number of sessions on each page. Defaults to `30`.
2398
+ - `orderby`: (*Filter parameter*), `string`
2399
+ The field by which sessions should be sorted. Available options:
2400
+ - `create_time` (default)
2401
+ - `update_time`
2402
+ - `desc`: (*Filter parameter*), `boolean`
2403
+ Indicates whether the retrieved sessions should be sorted in descending order. Defaults to `true`.
2404
+ - `id`: (*Filter parameter*), `string`
2405
+ The ID of the agent session to retrieve.
2406
+
2407
+ ### Response
2408
+
2409
+ Success:
2410
+
2411
+ ```json
2412
+ {
2413
+ "code": 0,
2414
+ "data": [
2415
+ {
2416
+ "agent_id": "ccd2f856b12311ef94ca0242ac120005",
2417
+ "create_date": "Tue, 03 Dec 2024 18:28:02 GMT",
2418
+ "create_time": 1733221682994,
2419
+ "dsl": {
2420
+ "answer": [],
2421
+ "components": {
2422
+ "Answer:SilentNeedlesDouble": {
2423
+ "downstream": [
2424
+ "Categorize:TameDodosLove"
2425
+ ],
2426
+ "obj": {
2427
+ "component_name": "Answer",
2428
+ "inputs": [],
2429
+ "output": null,
2430
+ "params": {
2431
+ "inputs": [],
2432
+ "message_history_window_size": 22,
2433
+ "output": null,
2434
+ "output_var_name": "output",
2435
+ "post_answers": [],
2436
+ "query": []
2437
+ }
2438
+ },
2439
+ "upstream": [
2440
+ "Generate:RealCatsJudge"
2441
+ ]
2442
+ },
2443
+ "Answer:ThickBeesTap": {
2444
+ "downstream": [
2445
+ "Categorize:TameDodosLove"
2446
+ ],
2447
+ "obj": {
2448
+ "component_name": "Answer",
2449
+ "inputs": [],
2450
+ "output": {
2451
+ "content": "Hi! I'm your smart assistant. What can I do for you?"
2452
+ },
2453
+ "params": {
2454
+ "inputs": [],
2455
+ "message_history_window_size": 22,
2456
+ "output": {
2457
+ "content": "Hi! I'm your smart assistant. What can I do for you?"
2458
+ },
2459
+ "output_var_name": "output",
2460
+ "post_answers": [],
2461
+ "query": []
2462
+ }
2463
+ },
2464
+ "upstream": [
2465
+ "begin"
2466
+ ]
2467
+ },
2468
+ "Baidu:TrueBananasPay": {
2469
+ "downstream": [],
2470
+ "obj": {
2471
+ "component_name": "Baidu",
2472
+ "inputs": [],
2473
+ "output": null,
2474
+ "params": {
2475
+ "inputs": [],
2476
+ "message_history_window_size": 22,
2477
+ "output": null,
2478
+ "output_var_name": "output",
2479
+ "query": [],
2480
+ "top_n": 10
2481
+ }
2482
+ },
2483
+ "upstream": []
2484
+ },
2485
+ "Categorize:TameDodosLove": {
2486
+ "downstream": [
2487
+ "Retrieval:KindMammalsBeg"
2488
+ ],
2489
+ "obj": {
2490
+ "component_name": "Categorize",
2491
+ "inputs": [],
2492
+ "output": null,
2493
+ "params": {
2494
+ "category_description": {
2495
+ "百度搜索": {
2496
+ "description": "接收用户的问题",
2497
+ "examples": "who are you\n今天天气如何",
2498
+ "index": 0,
2499
+ "to": "Retrieval:KindMammalsBeg"
2500
+ }
2501
+ },
2502
+ "cite": true,
2503
+ "frequency_penalty": 0.7,
2504
+ "inputs": [],
2505
+ "llm_id": "gpt-4o___OpenAI-API@OpenAI-API-Compatible",
2506
+ "max_tokens": 256,
2507
+ "message_history_window_size": 1,
2508
+ "output": null,
2509
+ "output_var_name": "output",
2510
+ "parameters": [],
2511
+ "presence_penalty": 0.4,
2512
+ "prompt": "",
2513
+ "query": [],
2514
+ "temperature": 0.1,
2515
+ "top_p": 0.3
2516
+ }
2517
+ },
2518
+ "upstream": [
2519
+ "Answer:ThickBeesTap",
2520
+ "Answer:SilentNeedlesDouble"
2521
+ ]
2522
+ },
2523
+ "Generate:RealCatsJudge": {
2524
+ "downstream": [
2525
+ "Answer:SilentNeedlesDouble"
2526
+ ],
2527
+ "obj": {
2528
+ "component_name": "Generate",
2529
+ "inputs": [],
2530
+ "output": null,
2531
+ "params": {
2532
+ "cite": true,
2533
+ "frequency_penalty": 0.7,
2534
+ "inputs": [],
2535
+ "llm_id": "gpt-4o___OpenAI-API@OpenAI-API-Compatible",
2536
+ "max_tokens": 256,
2537
+ "message_history_window_size": 12,
2538
+ "output": null,
2539
+ "output_var_name": "output",
2540
+ "parameters": [
2541
+ {
2542
+ "component_id": "Retrieval:KindMammalsBeg",
2543
+ "id": "1cc92398-2306-42ee-b401-6bfb49e1084e",
2544
+ "key": "input"
2545
+ }
2546
+ ],
2547
+ "presence_penalty": 0.4,
2548
+ "prompt": "Please summarize the following paragraphs. Be careful with the numbers, do not make things up. Paragraphs as following:\n {input}\n The above is the content you need to summarize.",
2549
+ "query": [],
2550
+ "temperature": 0.1,
2551
+ "top_p": 0.3
2552
+ }
2553
+ },
2554
+ "upstream": [
2555
+ "Retrieval:KindMammalsBeg"
2556
+ ]
2557
+ },
2558
+ "Retrieval:KindMammalsBeg": {
2559
+ "downstream": [
2560
+ "Generate:RealCatsJudge"
2561
+ ],
2562
+ "obj": {
2563
+ "component_name": "Retrieval",
2564
+ "inputs": [],
2565
+ "output": null,
2566
+ "params": {
2567
+ "empty_response": "",
2568
+ "inputs": [],
2569
+ "kb_ids": [
2570
+ "0f8fe876ab1a11efa22c0242ac120006"
2571
+ ],
2572
+ "keywords_similarity_weight": 0.3,
2573
+ "message_history_window_size": 22,
2574
+ "output": null,
2575
+ "output_var_name": "output",
2576
+ "query": [],
2577
+ "rerank_id": "",
2578
+ "similarity_threshold": 0.2,
2579
+ "top_k": 1024,
2580
+ "top_n": 8
2581
+ }
2582
+ },
2583
+ "upstream": [
2584
+ "Categorize:TameDodosLove"
2585
+ ]
2586
+ },
2587
+ "begin": {
2588
+ "downstream": [
2589
+ "Answer:ThickBeesTap"
2590
+ ],
2591
+ "obj": {
2592
+ "component_name": "Begin",
2593
+ "inputs": [],
2594
+ "output": {
2595
+ "content": "Hi! I'm your smart assistant. What can I do for you?"
2596
+ },
2597
+ "params": {
2598
+ "inputs": [],
2599
+ "message_history_window_size": 22,
2600
+ "output": {
2601
+ "content": "Hi! I'm your smart assistant. What can I do for you?"
2602
+ },
2603
+ "output_var_name": "output",
2604
+ "prologue": "Hi! I'm your smart assistant. What can I do for you?",
2605
+ "query": []
2606
+ }
2607
+ },
2608
+ "upstream": []
2609
+ }
2610
+ },
2611
+ "embed_id": "",
2612
+ "graph": {
2613
+ "edges": [
2614
+ {
2615
+ "id": "reactflow__edge-begin-Answer:ThickBeesTapc",
2616
+ "markerEnd": "logo",
2617
+ "source": "begin",
2618
+ "sourceHandle": null,
2619
+ "style": {
2620
+ "stroke": "rgb(202 197 245)",
2621
+ "strokeWidth": 2
2622
+ },
2623
+ "target": "Answer:ThickBeesTap",
2624
+ "targetHandle": "c",
2625
+ "type": "buttonEdge"
2626
+ },
2627
+ {
2628
+ "id": "reactflow__edge-Answer:ThickBeesTapb-Categorize:TameDodosLovea",
2629
+ "markerEnd": "logo",
2630
+ "source": "Answer:ThickBeesTap",
2631
+ "sourceHandle": "b",
2632
+ "style": {
2633
+ "stroke": "rgb(202 197 245)",
2634
+ "strokeWidth": 2
2635
+ },
2636
+ "target": "Categorize:TameDodosLove",
2637
+ "targetHandle": "a",
2638
+ "type": "buttonEdge"
2639
+ },
2640
+ {
2641
+ "id": "reactflow__edge-Generate:RealCatsJudgec-Answer:SilentNeedlesDoubleb",
2642
+ "markerEnd": "logo",
2643
+ "selected": false,
2644
+ "source": "Generate:RealCatsJudge",
2645
+ "sourceHandle": "c",
2646
+ "style": {
2647
+ "stroke": "rgb(202 197 245)",
2648
+ "strokeWidth": 2
2649
+ },
2650
+ "target": "Answer:SilentNeedlesDouble",
2651
+ "targetHandle": "b",
2652
+ "type": "buttonEdge"
2653
+ },
2654
+ {
2655
+ "id": "reactflow__edge-Answer:SilentNeedlesDoublec-Categorize:TameDodosLovea",
2656
+ "markerEnd": "logo",
2657
+ "source": "Answer:SilentNeedlesDouble",
2658
+ "sourceHandle": "c",
2659
+ "style": {
2660
+ "stroke": "rgb(202 197 245)",
2661
+ "strokeWidth": 2
2662
+ },
2663
+ "target": "Categorize:TameDodosLove",
2664
+ "targetHandle": "a",
2665
+ "type": "buttonEdge"
2666
+ },
2667
+ {
2668
+ "id": "reactflow__edge-Categorize:TameDodosLove百度搜索-Retrieval:KindMammalsBegc",
2669
+ "markerEnd": "logo",
2670
+ "source": "Categorize:TameDodosLove",
2671
+ "sourceHandle": "百度搜索",
2672
+ "style": {
2673
+ "stroke": "rgb(202 197 245)",
2674
+ "strokeWidth": 2
2675
+ },
2676
+ "target": "Retrieval:KindMammalsBeg",
2677
+ "targetHandle": "c",
2678
+ "type": "buttonEdge"
2679
+ },
2680
+ {
2681
+ "id": "reactflow__edge-Retrieval:KindMammalsBegb-Generate:RealCatsJudgeb",
2682
+ "markerEnd": "logo",
2683
+ "source": "Retrieval:KindMammalsBeg",
2684
+ "sourceHandle": "b",
2685
+ "style": {
2686
+ "stroke": "rgb(202 197 245)",
2687
+ "strokeWidth": 2
2688
+ },
2689
+ "target": "Generate:RealCatsJudge",
2690
+ "targetHandle": "b",
2691
+ "type": "buttonEdge"
2692
+ }
2693
+ ],
2694
+ "nodes": [
2695
+ {
2696
+ "data": {
2697
+ "label": "Begin",
2698
+ "name": "begin"
2699
+ },
2700
+ "height": 44,
2701
+ "id": "begin",
2702
+ "position": {
2703
+ "x": 50,
2704
+ "y": 200
2705
+ },
2706
+ "sourcePosition": "left",
2707
+ "targetPosition": "right",
2708
+ "type": "beginNode",
2709
+ "width": 200
2710
+ },
2711
+ {
2712
+ "data": {
2713
+ "form": {},
2714
+ "label": "Answer",
2715
+ "name": "对话_0"
2716
+ },
2717
+ "dragging": false,
2718
+ "height": 44,
2719
+ "id": "Answer:ThickBeesTap",
2720
+ "position": {
2721
+ "x": 297.6576850283112,
2722
+ "y": 203.86553837720618
2723
+ },
2724
+ "positionAbsolute": {
2725
+ "x": 297.6576850283112,
2726
+ "y": 203.86553837720618
2727
+ },
2728
+ "selected": false,
2729
+ "sourcePosition": "right",
2730
+ "targetPosition": "left",
2731
+ "type": "logicNode",
2732
+ "width": 200
2733
+ },
2734
+ {
2735
+ "data": {
2736
+ "form": {
2737
+ "category_description": {
2738
+ "百度搜索": {
2739
+ "description": "接收用户的问题",
2740
+ "examples": "who are you\n今天天气如何",
2741
+ "index": 0,
2742
+ "to": "Retrieval:KindMammalsBeg"
2743
+ }
2744
+ },
2745
+ "frequencyPenaltyEnabled": true,
2746
+ "frequency_penalty": 0.7,
2747
+ "llm_id": "gpt-4o___OpenAI-API@OpenAI-API-Compatible",
2748
+ "maxTokensEnabled": true,
2749
+ "max_tokens": 256,
2750
+ "message_history_window_size": 1,
2751
+ "presencePenaltyEnabled": true,
2752
+ "presence_penalty": 0.4,
2753
+ "query": [],
2754
+ "temperature": 0.1,
2755
+ "temperatureEnabled": true,
2756
+ "topPEnabled": true,
2757
+ "top_p": 0.3
2758
+ },
2759
+ "label": "Categorize",
2760
+ "name": "问题分类_0"
2761
+ },
2762
+ "dragging": false,
2763
+ "height": 136,
2764
+ "id": "Categorize:TameDodosLove",
2765
+ "position": {
2766
+ "x": 621.0820384684355,
2767
+ "y": 220.11059722579682
2768
+ },
2769
+ "positionAbsolute": {
2770
+ "x": 621.0820384684355,
2771
+ "y": 220.11059722579682
2772
+ },
2773
+ "selected": false,
2774
+ "sourcePosition": "right",
2775
+ "targetPosition": "left",
2776
+ "type": "categorizeNode",
2777
+ "width": 200
2778
+ },
2779
+ {
2780
+ "data": {
2781
+ "form": {
2782
+ "query": [],
2783
+ "top_n": 10
2784
+ },
2785
+ "label": "Baidu",
2786
+ "name": "百度_0"
2787
+ },
2788
+ "dragging": false,
2789
+ "height": 64,
2790
+ "id": "Baidu:TrueBananasPay",
2791
+ "position": {
2792
+ "x": 1090.4399996938341,
2793
+ "y": -10.899556912399987
2794
+ },
2795
+ "positionAbsolute": {
2796
+ "x": 1090.4399996938341,
2797
+ "y": -10.899556912399987
2798
+ },
2799
+ "selected": false,
2800
+ "sourcePosition": "right",
2801
+ "targetPosition": "left",
2802
+ "type": "ragNode",
2803
+ "width": 200
2804
+ },
2805
+ {
2806
+ "data": {
2807
+ "form": {
2808
+ "cite": true,
2809
+ "frequencyPenaltyEnabled": true,
2810
+ "frequency_penalty": 0.7,
2811
+ "llm_id": "gpt-4o___OpenAI-API@OpenAI-API-Compatible",
2812
+ "maxTokensEnabled": true,
2813
+ "max_tokens": 256,
2814
+ "message_history_window_size": 12,
2815
+ "parameters": [
2816
+ {
2817
+ "component_id": "Retrieval:KindMammalsBeg",
2818
+ "id": "1cc92398-2306-42ee-b401-6bfb49e1084e",
2819
+ "key": "input"
2820
+ }
2821
+ ],
2822
+ "presencePenaltyEnabled": true,
2823
+ "presence_penalty": 0.4,
2824
+ "prompt": "Please summarize the following paragraphs. Be careful with the numbers, do not make things up. Paragraphs as following:\n {input}\n The above is the content you need to summarize.",
2825
+ "temperature": 0.1,
2826
+ "temperatureEnabled": true,
2827
+ "topPEnabled": true,
2828
+ "top_p": 0.3
2829
+ },
2830
+ "label": "Generate",
2831
+ "name": "生成回答_0"
2832
+ },
2833
+ "dragging": false,
2834
+ "height": 147,
2835
+ "id": "Generate:RealCatsJudge",
2836
+ "position": {
2837
+ "x": 816.022744651524,
2838
+ "y": 585.3018986039125
2839
+ },
2840
+ "positionAbsolute": {
2841
+ "x": 816.022744651524,
2842
+ "y": 585.3018986039125
2843
+ },
2844
+ "selected": true,
2845
+ "sourcePosition": "right",
2846
+ "targetPosition": "left",
2847
+ "type": "generateNode",
2848
+ "width": 200
2849
+ },
2850
+ {
2851
+ "data": {
2852
+ "form": {},
2853
+ "label": "Answer",
2854
+ "name": "对话_1"
2855
+ },
2856
+ "height": 44,
2857
+ "id": "Answer:SilentNeedlesDouble",
2858
+ "position": {
2859
+ "x": 402.5121557783059,
2860
+ "y": 676.449068518027
2861
+ },
2862
+ "sourcePosition": "right",
2863
+ "targetPosition": "left",
2864
+ "type": "logicNode",
2865
+ "width": 200
2866
+ },
2867
+ {
2868
+ "data": {
2869
+ "form": {
2870
+ "kb_ids": [
2871
+ "0f8fe876ab1a11efa22c0242ac120006"
2872
+ ],
2873
+ "keywords_similarity_weight": 0.3,
2874
+ "query": [],
2875
+ "similarity_threshold": 0.2,
2876
+ "top_n": 8
2877
+ },
2878
+ "label": "Retrieval",
2879
+ "name": "知识检索_0"
2880
+ },
2881
+ "dragging": false,
2882
+ "height": 106,
2883
+ "id": "Retrieval:KindMammalsBeg",
2884
+ "position": {
2885
+ "x": 975.4304422274787,
2886
+ "y": 341.7370543002002
2887
+ },
2888
+ "positionAbsolute": {
2889
+ "x": 975.4304422274787,
2890
+ "y": 341.7370543002002
2891
+ },
2892
+ "selected": false,
2893
+ "sourcePosition": "right",
2894
+ "targetPosition": "left",
2895
+ "type": "retrievalNode",
2896
+ "width": 200
2897
+ }
2898
+ ]
2899
+ },
2900
+ "history": [
2901
+ [
2902
+ "assistant",
2903
+ "Hi! I'm your smart assistant. What can I do for you?"
2904
+ ]
2905
+ ],
2906
+ "messages": [
2907
+ {
2908
+ "content": "Hi! I'm your smart assistant. What can I do for you?",
2909
+ "id": "472be0d2b15f11ef92df0242ac120005",
2910
+ "role": "assistant"
2911
+ }
2912
+ ],
2913
+ "path": [
2914
+ [
2915
+ "begin"
2916
+ ],
2917
+ [
2918
+ "Answer:ThickBeesTap"
2919
+ ]
2920
+ ],
2921
+ "reference": []
2922
+ },
2923
+ "duration": 0.0,
2924
+ "id": "46d2cbeeb16111efb2c10242ac120005",
2925
+ "messages": [
2926
+ {
2927
+ "content": "Hi! I'm your smart assistant. What can I do for you?",
2928
+ "role": "assistant"
2929
+ }
2930
+ ],
2931
+ "round": 0,
2932
+ "source": "agent",
2933
+ "thumb_up": 0,
2934
+ "tokens": 0,
2935
+ "update_date": "Tue, 03 Dec 2024 18:28:02 GMT",
2936
+ "update_time": 1733221682994,
2937
+ "user_id": "69736c5e723611efb51b0242ac120007"
2938
+ }
2939
+ ]
2940
+ }
2941
+ ```
2942
+
2943
+ Failure:
2944
+
2945
+ ```json
2946
+ {
2947
+ "code": 102,
2948
+ "message": "You don't own the agent ccd2f856b12311ef94ca0242ac1200052."
2949
+ }
2950
+ ```
2951
+ ---
2952
+ ## List agents
2953
+
2954
+ **GET** `/api/v1/agents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={agent_name}&id={agent_id}`
2955
+
2956
+ Lists agents.
2957
+
2958
+ ### Request
2959
+
2960
+ - Method: GET
2961
+ - URL: `/api/v1/agents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={agent_name}&id={agent_id}`
2962
+ - Headers:
2963
+ - `'Authorization: Bearer <YOUR_API_KEY>'`
2964
+
2965
+ #### Request example
2966
+
2967
+ ```bash
2968
+ curl --request GET \
2969
+ --url http://{address}/api/v1/agents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={agent_name}&id={agent_id} \
2970
+ --header 'Authorization: Bearer <YOUR_API_KEY>'
2971
+ ```
2972
+
2973
+ #### Request parameters
2974
+
2975
+ - `page`: (*Filter parameter*), `integer`
2976
+ Specifies the page on which the agents will be displayed. Defaults to `1`.
2977
+ - `page_size`: (*Filter parameter*), `integer`
2978
+ The number of agents on each page. Defaults to `30`.
2979
+ - `orderby`: (*Filter parameter*), `string`
2980
+ The attribute by which the results are sorted. Available options:
2981
+ - `create_time` (default)
2982
+ - `update_time`
2983
+ - `desc`: (*Filter parameter*), `boolean`
2984
+ Indicates whether the retrieved agents should be sorted in descending order. Defaults to `true`.
2985
+ - `id`: (*Filter parameter*), `string`
2986
+ The ID of the agent to retrieve.
2987
+ - `name`: (*Filter parameter*), `string`
2988
+ The name of the agent to retrieve.
2989
+
2990
+ ### Response
2991
+
2992
+ Success:
2993
+
2994
+ ```json
2995
+ {
2996
+ "code": 0,
2997
+ "data": [
2998
+ {
2999
+ "avatar": null,
3000
+ "canvas_type": null,
3001
+ "create_date": "Tue, 03 Dec 2024 11:07:59 GMT",
3002
+ "create_time": 1733195279013,
3003
+ "description": null,
3004
+ "dsl": {
3005
+ "answer": [],
3006
+ "components": {
3007
+ "Answer:SilentNeedlesDouble": {
3008
+ "downstream": [
3009
+ "Categorize:TameDodosLove"
3010
+ ],
3011
+ "obj": {
3012
+ "component_name": "Answer",
3013
+ "inputs": [],
3014
+ "output": null,
3015
+ "params": {
3016
+ "inputs": [],
3017
+ "message_history_window_size": 22,
3018
+ "output": null,
3019
+ "output_var_name": "output",
3020
+ "post_answers": [],
3021
+ "query": []
3022
+ }
3023
+ },
3024
+ "upstream": [
3025
+ "Generate:RealCatsJudge"
3026
+ ]
3027
+ },
3028
+ "Answer:ThickBeesTap": {
3029
+ "downstream": [
3030
+ "Categorize:TameDodosLove"
3031
+ ],
3032
+ "obj": {
3033
+ "component_name": "Answer",
3034
+ "inputs": [],
3035
+ "output": {
3036
+ "content": "Hi! I'm your smart assistant. What can I do for you?"
3037
+ },
3038
+ "params": {
3039
+ "inputs": [],
3040
+ "message_history_window_size": 22,
3041
+ "output": {
3042
+ "content": "Hi! I'm your smart assistant. What can I do for you?"
3043
+ },
3044
+ "output_var_name": "output",
3045
+ "post_answers": [],
3046
+ "query": []
3047
+ }
3048
+ },
3049
+ "upstream": [
3050
+ "begin"
3051
+ ]
3052
+ },
3053
+ "Baidu:TrueBananasPay": {
3054
+ "downstream": [],
3055
+ "obj": {
3056
+ "component_name": "Baidu",
3057
+ "inputs": [],
3058
+ "output": null,
3059
+ "params": {
3060
+ "inputs": [],
3061
+ "message_history_window_size": 22,
3062
+ "output": null,
3063
+ "output_var_name": "output",
3064
+ "query": [],
3065
+ "top_n": 10
3066
+ }
3067
+ },
3068
+ "upstream": []
3069
+ },
3070
+ "Categorize:TameDodosLove": {
3071
+ "downstream": [
3072
+ "Retrieval:KindMammalsBeg"
3073
+ ],
3074
+ "obj": {
3075
+ "component_name": "Categorize",
3076
+ "inputs": [],
3077
+ "output": null,
3078
+ "params": {
3079
+ "category_description": {
3080
+ "百度搜索": {
3081
+ "description": "接收用户的问题",
3082
+ "examples": "who are you\n今天天气如何",
3083
+ "index": 0,
3084
+ "to": "Retrieval:KindMammalsBeg"
3085
+ }
3086
+ },
3087
+ "cite": true,
3088
+ "frequency_penalty": 0.7,
3089
+ "inputs": [],
3090
+ "llm_id": "gpt-4o___OpenAI-API@OpenAI-API-Compatible",
3091
+ "max_tokens": 256,
3092
+ "message_history_window_size": 1,
3093
+ "output": null,
3094
+ "output_var_name": "output",
3095
+ "parameters": [],
3096
+ "presence_penalty": 0.4,
3097
+ "prompt": "",
3098
+ "query": [],
3099
+ "temperature": 0.1,
3100
+ "top_p": 0.3
3101
+ }
3102
+ },
3103
+ "upstream": [
3104
+ "Answer:ThickBeesTap",
3105
+ "Answer:SilentNeedlesDouble"
3106
+ ]
3107
+ },
3108
+ "Generate:RealCatsJudge": {
3109
+ "downstream": [
3110
+ "Answer:SilentNeedlesDouble"
3111
+ ],
3112
+ "obj": {
3113
+ "component_name": "Generate",
3114
+ "inputs": [],
3115
+ "output": null,
3116
+ "params": {
3117
+ "cite": true,
3118
+ "frequency_penalty": 0.7,
3119
+ "inputs": [],
3120
+ "llm_id": "gpt-4o___OpenAI-API@OpenAI-API-Compatible",
3121
+ "max_tokens": 256,
3122
+ "message_history_window_size": 12,
3123
+ "output": null,
3124
+ "output_var_name": "output",
3125
+ "parameters": [
3126
+ {
3127
+ "component_id": "Retrieval:KindMammalsBeg",
3128
+ "id": "1cc92398-2306-42ee-b401-6bfb49e1084e",
3129
+ "key": "input"
3130
+ }
3131
+ ],
3132
+ "presence_penalty": 0.4,
3133
+ "prompt": "Please summarize the following paragraphs. Be careful with the numbers, do not make things up. Paragraphs as following:\n {input}\n The above is the content you need to summarize.",
3134
+ "query": [],
3135
+ "temperature": 0.1,
3136
+ "top_p": 0.3
3137
+ }
3138
+ },
3139
+ "upstream": [
3140
+ "Retrieval:KindMammalsBeg"
3141
+ ]
3142
+ },
3143
+ "Retrieval:KindMammalsBeg": {
3144
+ "downstream": [
3145
+ "Generate:RealCatsJudge"
3146
+ ],
3147
+ "obj": {
3148
+ "component_name": "Retrieval",
3149
+ "inputs": [],
3150
+ "output": null,
3151
+ "params": {
3152
+ "empty_response": "",
3153
+ "inputs": [],
3154
+ "kb_ids": [
3155
+ "0f8fe876ab1a11efa22c0242ac120006"
3156
+ ],
3157
+ "keywords_similarity_weight": 0.3,
3158
+ "message_history_window_size": 22,
3159
+ "output": null,
3160
+ "output_var_name": "output",
3161
+ "query": [],
3162
+ "rerank_id": "",
3163
+ "similarity_threshold": 0.2,
3164
+ "top_k": 1024,
3165
+ "top_n": 8
3166
+ }
3167
+ },
3168
+ "upstream": [
3169
+ "Categorize:TameDodosLove"
3170
+ ]
3171
+ },
3172
+ "begin": {
3173
+ "downstream": [
3174
+ "Answer:ThickBeesTap"
3175
+ ],
3176
+ "obj": {
3177
+ "component_name": "Begin",
3178
+ "inputs": [],
3179
+ "output": {
3180
+ "content": "Hi! I'm your smart assistant. What can I do for you?"
3181
+ },
3182
+ "params": {
3183
+ "inputs": [],
3184
+ "message_history_window_size": 22,
3185
+ "output": {
3186
+ "content": "Hi! I'm your smart assistant. What can I do for you?"
3187
+ },
3188
+ "output_var_name": "output",
3189
+ "prologue": "Hi! I'm your smart assistant. What can I do for you?",
3190
+ "query": []
3191
+ }
3192
+ },
3193
+ "upstream": []
3194
+ }
3195
+ },
3196
+ "embed_id": "",
3197
+ "graph": {
3198
+ "edges": [
3199
+ {
3200
+ "id": "reactflow__edge-begin-Answer:ThickBeesTapc",
3201
+ "markerEnd": "logo",
3202
+ "source": "begin",
3203
+ "sourceHandle": null,
3204
+ "style": {
3205
+ "stroke": "rgb(202 197 245)",
3206
+ "strokeWidth": 2
3207
+ },
3208
+ "target": "Answer:ThickBeesTap",
3209
+ "targetHandle": "c",
3210
+ "type": "buttonEdge"
3211
+ },
3212
+ {
3213
+ "id": "reactflow__edge-Answer:ThickBeesTapb-Categorize:TameDodosLovea",
3214
+ "markerEnd": "logo",
3215
+ "source": "Answer:ThickBeesTap",
3216
+ "sourceHandle": "b",
3217
+ "style": {
3218
+ "stroke": "rgb(202 197 245)",
3219
+ "strokeWidth": 2
3220
+ },
3221
+ "target": "Categorize:TameDodosLove",
3222
+ "targetHandle": "a",
3223
+ "type": "buttonEdge"
3224
+ },
3225
+ {
3226
+ "id": "reactflow__edge-Generate:RealCatsJudgec-Answer:SilentNeedlesDoubleb",
3227
+ "markerEnd": "logo",
3228
+ "selected": false,
3229
+ "source": "Generate:RealCatsJudge",
3230
+ "sourceHandle": "c",
3231
+ "style": {
3232
+ "stroke": "rgb(202 197 245)",
3233
+ "strokeWidth": 2
3234
+ },
3235
+ "target": "Answer:SilentNeedlesDouble",
3236
+ "targetHandle": "b",
3237
+ "type": "buttonEdge"
3238
+ },
3239
+ {
3240
+ "id": "reactflow__edge-Answer:SilentNeedlesDoublec-Categorize:TameDodosLovea",
3241
+ "markerEnd": "logo",
3242
+ "source": "Answer:SilentNeedlesDouble",
3243
+ "sourceHandle": "c",
3244
+ "style": {
3245
+ "stroke": "rgb(202 197 245)",
3246
+ "strokeWidth": 2
3247
+ },
3248
+ "target": "Categorize:TameDodosLove",
3249
+ "targetHandle": "a",
3250
+ "type": "buttonEdge"
3251
+ },
3252
+ {
3253
+ "id": "reactflow__edge-Categorize:TameDodosLove百度搜索-Retrieval:KindMammalsBegc",
3254
+ "markerEnd": "logo",
3255
+ "source": "Categorize:TameDodosLove",
3256
+ "sourceHandle": "百度搜索",
3257
+ "style": {
3258
+ "stroke": "rgb(202 197 245)",
3259
+ "strokeWidth": 2
3260
+ },
3261
+ "target": "Retrieval:KindMammalsBeg",
3262
+ "targetHandle": "c",
3263
+ "type": "buttonEdge"
3264
+ },
3265
+ {
3266
+ "id": "reactflow__edge-Retrieval:KindMammalsBegb-Generate:RealCatsJudgeb",
3267
+ "markerEnd": "logo",
3268
+ "source": "Retrieval:KindMammalsBeg",
3269
+ "sourceHandle": "b",
3270
+ "style": {
3271
+ "stroke": "rgb(202 197 245)",
3272
+ "strokeWidth": 2
3273
+ },
3274
+ "target": "Generate:RealCatsJudge",
3275
+ "targetHandle": "b",
3276
+ "type": "buttonEdge"
3277
+ }
3278
+ ],
3279
+ "nodes": [
3280
+ {
3281
+ "data": {
3282
+ "label": "Begin",
3283
+ "name": "begin"
3284
+ },
3285
+ "height": 44,
3286
+ "id": "begin",
3287
+ "position": {
3288
+ "x": 50,
3289
+ "y": 200
3290
+ },
3291
+ "sourcePosition": "left",
3292
+ "targetPosition": "right",
3293
+ "type": "beginNode",
3294
+ "width": 200
3295
+ },
3296
+ {
3297
+ "data": {
3298
+ "form": {},
3299
+ "label": "Answer",
3300
+ "name": "对话_0"
3301
+ },
3302
+ "dragging": false,
3303
+ "height": 44,
3304
+ "id": "Answer:ThickBeesTap",
3305
+ "position": {
3306
+ "x": 297.6576850283112,
3307
+ "y": 203.86553837720618
3308
+ },
3309
+ "positionAbsolute": {
3310
+ "x": 297.6576850283112,
3311
+ "y": 203.86553837720618
3312
+ },
3313
+ "selected": false,
3314
+ "sourcePosition": "right",
3315
+ "targetPosition": "left",
3316
+ "type": "logicNode",
3317
+ "width": 200
3318
+ },
3319
+ {
3320
+ "data": {
3321
+ "form": {
3322
+ "category_description": {
3323
+ "百度搜索": {
3324
+ "description": "接收用户的问题",
3325
+ "examples": "who are you\n今天天气如何",
3326
+ "index": 0,
3327
+ "to": "Retrieval:KindMammalsBeg"
3328
+ }
3329
+ },
3330
+ "frequencyPenaltyEnabled": true,
3331
+ "frequency_penalty": 0.7,
3332
+ "llm_id": "gpt-4o___OpenAI-API@OpenAI-API-Compatible",
3333
+ "maxTokensEnabled": true,
3334
+ "max_tokens": 256,
3335
+ "message_history_window_size": 1,
3336
+ "presencePenaltyEnabled": true,
3337
+ "presence_penalty": 0.4,
3338
+ "query": [],
3339
+ "temperature": 0.1,
3340
+ "temperatureEnabled": true,
3341
+ "topPEnabled": true,
3342
+ "top_p": 0.3
3343
+ },
3344
+ "label": "Categorize",
3345
+ "name": "问题分类_0"
3346
+ },
3347
+ "dragging": false,
3348
+ "height": 136,
3349
+ "id": "Categorize:TameDodosLove",
3350
+ "position": {
3351
+ "x": 621.0820384684355,
3352
+ "y": 220.11059722579682
3353
+ },
3354
+ "positionAbsolute": {
3355
+ "x": 621.0820384684355,
3356
+ "y": 220.11059722579682
3357
+ },
3358
+ "selected": false,
3359
+ "sourcePosition": "right",
3360
+ "targetPosition": "left",
3361
+ "type": "categorizeNode",
3362
+ "width": 200
3363
+ },
3364
+ {
3365
+ "data": {
3366
+ "form": {
3367
+ "query": [],
3368
+ "top_n": 10
3369
+ },
3370
+ "label": "Baidu",
3371
+ "name": "百度_0"
3372
+ },
3373
+ "dragging": false,
3374
+ "height": 64,
3375
+ "id": "Baidu:TrueBananasPay",
3376
+ "position": {
3377
+ "x": 1090.4399996938341,
3378
+ "y": -10.899556912399987
3379
+ },
3380
+ "positionAbsolute": {
3381
+ "x": 1090.4399996938341,
3382
+ "y": -10.899556912399987
3383
+ },
3384
+ "selected": false,
3385
+ "sourcePosition": "right",
3386
+ "targetPosition": "left",
3387
+ "type": "ragNode",
3388
+ "width": 200
3389
+ },
3390
+ {
3391
+ "data": {
3392
+ "form": {
3393
+ "cite": true,
3394
+ "frequencyPenaltyEnabled": true,
3395
+ "frequency_penalty": 0.7,
3396
+ "llm_id": "gpt-4o___OpenAI-API@OpenAI-API-Compatible",
3397
+ "maxTokensEnabled": true,
3398
+ "max_tokens": 256,
3399
+ "message_history_window_size": 12,
3400
+ "parameters": [
3401
+ {
3402
+ "component_id": "Retrieval:KindMammalsBeg",
3403
+ "id": "1cc92398-2306-42ee-b401-6bfb49e1084e",
3404
+ "key": "input"
3405
+ }
3406
+ ],
3407
+ "presencePenaltyEnabled": true,
3408
+ "presence_penalty": 0.4,
3409
+ "prompt": "Please summarize the following paragraphs. Be careful with the numbers, do not make things up. Paragraphs as following:\n {input}\n The above is the content you need to summarize.",
3410
+ "temperature": 0.1,
3411
+ "temperatureEnabled": true,
3412
+ "topPEnabled": true,
3413
+ "top_p": 0.3
3414
+ },
3415
+ "label": "Generate",
3416
+ "name": "生成回答_0"
3417
+ },
3418
+ "dragging": false,
3419
+ "height": 147,
3420
+ "id": "Generate:RealCatsJudge",
3421
+ "position": {
3422
+ "x": 816.022744651524,
3423
+ "y": 585.3018986039125
3424
+ },
3425
+ "positionAbsolute": {
3426
+ "x": 816.022744651524,
3427
+ "y": 585.3018986039125
3428
+ },
3429
+ "selected": true,
3430
+ "sourcePosition": "right",
3431
+ "targetPosition": "left",
3432
+ "type": "generateNode",
3433
+ "width": 200
3434
+ },
3435
+ {
3436
+ "data": {
3437
+ "form": {},
3438
+ "label": "Answer",
3439
+ "name": "对话_1"
3440
+ },
3441
+ "height": 44,
3442
+ "id": "Answer:SilentNeedlesDouble",
3443
+ "position": {
3444
+ "x": 402.5121557783059,
3445
+ "y": 676.449068518027
3446
+ },
3447
+ "sourcePosition": "right",
3448
+ "targetPosition": "left",
3449
+ "type": "logicNode",
3450
+ "width": 200
3451
+ },
3452
+ {
3453
+ "data": {
3454
+ "form": {
3455
+ "kb_ids": [
3456
+ "0f8fe876ab1a11efa22c0242ac120006"
3457
+ ],
3458
+ "keywords_similarity_weight": 0.3,
3459
+ "query": [],
3460
+ "similarity_threshold": 0.2,
3461
+ "top_n": 8
3462
+ },
3463
+ "label": "Retrieval",
3464
+ "name": "知识检索_0"
3465
+ },
3466
+ "dragging": false,
3467
+ "height": 106,
3468
+ "id": "Retrieval:KindMammalsBeg",
3469
+ "position": {
3470
+ "x": 975.4304422274787,
3471
+ "y": 341.7370543002002
3472
+ },
3473
+ "positionAbsolute": {
3474
+ "x": 975.4304422274787,
3475
+ "y": 341.7370543002002
3476
+ },
3477
+ "selected": false,
3478
+ "sourcePosition": "right",
3479
+ "targetPosition": "left",
3480
+ "type": "retrievalNode",
3481
+ "width": 200
3482
+ }
3483
+ ]
3484
+ },
3485
+ "history": [
3486
+ [
3487
+ "assistant",
3488
+ "Hi! I'm your smart assistant. What can I do for you?"
3489
+ ]
3490
+ ],
3491
+ "messages": [
3492
+ {
3493
+ "content": "Hi! I'm your smart assistant. What can I do for you?",
3494
+ "id": "472be0d2b15f11ef92df0242ac120005",
3495
+ "role": "assistant"
3496
+ }
3497
+ ],
3498
+ "path": [
3499
+ [
3500
+ "begin"
3501
+ ],
3502
+ [
3503
+ "Answer:ThickBeesTap"
3504
+ ]
3505
+ ],
3506
+ "reference": []
3507
+ },
3508
+ "id": "ccd2f856b12311ef94ca0242ac120005",
3509
+ "title": "test2",
3510
+ "update_date": "Tue, 03 Dec 2024 18:13:44 GMT",
3511
+ "update_time": 1733220824599,
3512
+ "user_id": "69736c5e723611efb51b0242ac120007"
3513
+ }
3514
+ ]
3515
+ }
3516
+ ```
3517
+
3518
+ Failure:
3519
+
3520
+ ```json
3521
+ {
3522
+ "code": 102,
3523
+ "message": "The agent doesn't exist."
3524
+ }
3525
+ ```
docs/references/python_api_reference.md CHANGED
@@ -1,4 +1,4 @@
1
- ---
2
  sidebar_position: 2
3
  slug: /python_api_reference
4
  ---
@@ -1513,4 +1513,123 @@ while True:
1513
  for ans in session.ask(question, stream=True):
1514
  print(ans.content[len(cont):], end='', flush=True)
1515
  cont = ans.content
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1516
  ```
 
1
+ from sdk.python.ragflow_sdk import Agentfrom docutils.nodes import titlefrom sdk.python.ragflow_sdk import Agent---
2
  sidebar_position: 2
3
  slug: /python_api_reference
4
  ---
 
1513
  for ans in session.ask(question, stream=True):
1514
  print(ans.content[len(cont):], end='', flush=True)
1515
  cont = ans.content
1516
+ ```
1517
+ ---
1518
+
1519
+ ## List agent sessions
1520
+
1521
+ ```python
1522
+ Agent.list_sessions(
1523
+ agent_id,
1524
+ rag
1525
+ page: int = 1,
1526
+ page_size: int = 30,
1527
+ orderby: str = "update_time",
1528
+ desc: bool = True,
1529
+ id: str = None
1530
+ ) -> List[Session]
1531
+ ```
1532
+
1533
+ Lists sessions associated with the current agent.
1534
+
1535
+ ### Parameters
1536
+
1537
+ #### page: `int`
1538
+
1539
+ Specifies the page on which the sessions will be displayed. Defaults to `1`.
1540
+
1541
+ #### page_size: `int`
1542
+
1543
+ The number of sessions on each page. Defaults to `30`.
1544
+
1545
+ #### orderby: `str`
1546
+
1547
+ The field by which sessions should be sorted. Available options:
1548
+
1549
+ - `"create_time"`
1550
+ - `"update_time"`(default)
1551
+
1552
+ #### desc: `bool`
1553
+
1554
+ Indicates whether the retrieved sessions should be sorted in descending order. Defaults to `True`.
1555
+
1556
+ #### id: `str`
1557
+
1558
+ The ID of the agent session to retrieve. Defaults to `None`.
1559
+
1560
+
1561
+ ### Returns
1562
+
1563
+ - Success: A list of `Session` objects associated with the current agent.
1564
+ - Failure: `Exception`.
1565
+
1566
+ ### Examples
1567
+
1568
+ ```python
1569
+ from ragflow_sdk import RAGFlow
1570
+
1571
+ rag_object = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
1572
+ agent_id = "2710f2269b4611ef8fdf0242ac120006"
1573
+ sessions=Agent.list_sessions(agent_id,rag_object)
1574
+ for session in sessions:
1575
+ print(session)
1576
+ ```
1577
+
1578
+ ---
1579
+ ## List agents
1580
+
1581
+ ```python
1582
+ RAGFlow.list_agents(
1583
+ page: int = 1,
1584
+ page_size: int = 30,
1585
+ orderby: str = "create_time",
1586
+ desc: bool = True,
1587
+ id: str = None,
1588
+ title: str = None
1589
+ ) -> List[Agent]
1590
+ ```
1591
+
1592
+ Lists agents.
1593
+
1594
+ ### Parameters
1595
+
1596
+ #### page: `int`
1597
+
1598
+ Specifies the page on which the agents will be displayed. Defaults to `1`.
1599
+
1600
+ #### page_size: `int`
1601
+
1602
+ The number of agents on each page. Defaults to `30`.
1603
+
1604
+ #### orderby: `str`
1605
+
1606
+ The attribute by which the results are sorted. Available options:
1607
+
1608
+ - `"create_time"` (default)
1609
+ - `"update_time"`
1610
+
1611
+ #### desc: `bool`
1612
+
1613
+ Indicates whether the retrieved agents should be sorted in descending order. Defaults to `True`.
1614
+
1615
+ #### id: `str`
1616
+
1617
+ The ID of the agent to retrieve. Defaults to `None`.
1618
+
1619
+ #### name: `str`
1620
+
1621
+ The name of the agent to retrieve. Defaults to `None`.
1622
+
1623
+ ### Returns
1624
+
1625
+ - Success: A list of `Agent` objects.
1626
+ - Failure: `Exception`.
1627
+
1628
+ ### Examples
1629
+
1630
+ ```python
1631
+ from ragflow_sdk import RAGFlow
1632
+ rag_object = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
1633
+ for agent in rag_object.list_agents():
1634
+ print(agent)
1635
  ```
sdk/python/ragflow_sdk/modules/agent.py CHANGED
@@ -1,6 +1,7 @@
1
  from .base import Base
2
  from .session import Session
3
  import requests
 
4
 
5
  class Agent(Base):
6
  def __init__(self,rag,res_dict):
@@ -57,3 +58,18 @@ class Agent(Base):
57
  return Session(rag,res.get("data"))
58
  raise Exception(res.get("message"))
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from .base import Base
2
  from .session import Session
3
  import requests
4
+ from typing import List
5
 
6
  class Agent(Base):
7
  def __init__(self,rag,res_dict):
 
58
  return Session(rag,res.get("data"))
59
  raise Exception(res.get("message"))
60
 
61
+ @staticmethod
62
+ def list_sessions(agent_id,rag,page: int = 1, page_size: int = 30, orderby: str = "create_time", desc: bool = True,
63
+ id: str = None) -> List[Session]:
64
+ url = f"{rag.api_url}/agents/{agent_id}/sessions"
65
+ headers = {"Authorization": f"Bearer {rag.user_key}"}
66
+ params = {"page": page, "page_size": page_size, "orderby": orderby, "desc": desc, "id": id}
67
+ res = requests.get(url=url,headers=headers,params=params)
68
+ res = res.json()
69
+ if res.get("code") == 0:
70
+ result_list = []
71
+ for data in res.get("data"):
72
+ temp_agent = Session(rag,data)
73
+ result_list.append(temp_agent)
74
+ return result_list
75
+ raise Exception(res.get("message"))
sdk/python/ragflow_sdk/modules/session.py CHANGED
@@ -8,12 +8,12 @@ class Session(Base):
8
  self.id = None
9
  self.name = "New session"
10
  self.messages = [{"role": "assistant", "content": "Hi! I am your assistant,can I help you?"}]
11
- self.chat_id = None
12
- self.agent_id = None
13
  for key,value in res_dict.items():
14
  if key =="chat_id" and value is not None:
 
15
  self.__session_type = "chat"
16
  if key == "agent_id" and value is not None:
 
17
  self.__session_type = "agent"
18
  super().__init__(rag, res_dict)
19
 
 
8
  self.id = None
9
  self.name = "New session"
10
  self.messages = [{"role": "assistant", "content": "Hi! I am your assistant,can I help you?"}]
 
 
11
  for key,value in res_dict.items():
12
  if key =="chat_id" and value is not None:
13
+ self.chat_id = None
14
  self.__session_type = "chat"
15
  if key == "agent_id" and value is not None:
16
+ self.agent_id = None
17
  self.__session_type = "agent"
18
  super().__init__(rag, res_dict)
19
 
sdk/python/ragflow_sdk/ragflow.py CHANGED
@@ -18,6 +18,7 @@ import requests
18
  from .modules.chat import Chat
19
  from .modules.chunk import Chunk
20
  from .modules.dataset import DataSet
 
21
 
22
 
23
  class RAGFlow:
@@ -86,8 +87,10 @@ class RAGFlow:
86
  return result_list
87
  raise Exception(res["message"])
88
 
89
- def create_chat(self, name: str, avatar: str = "", dataset_ids: list[str] = [],
90
- llm: Chat.LLM | None = None, prompt: Chat.Prompt | None = None) -> Chat:
 
 
91
  dataset_list = []
92
  for id in dataset_ids:
93
  dataset_list.append(id)
@@ -176,3 +179,15 @@ class RAGFlow:
176
  chunks.append(chunk)
177
  return chunks
178
  raise Exception(res.get("message"))
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  from .modules.chat import Chat
19
  from .modules.chunk import Chunk
20
  from .modules.dataset import DataSet
21
+ from .modules.agent import Agent
22
 
23
 
24
  class RAGFlow:
 
87
  return result_list
88
  raise Exception(res["message"])
89
 
90
+ def create_chat(self, name: str, avatar: str = "", dataset_ids=None,
91
+ llm: Chat.LLM | None = None, prompt: Chat.Prompt | None = None) -> Chat:
92
+ if dataset_ids is None:
93
+ dataset_ids = []
94
  dataset_list = []
95
  for id in dataset_ids:
96
  dataset_list.append(id)
 
179
  chunks.append(chunk)
180
  return chunks
181
  raise Exception(res.get("message"))
182
+
183
+
184
+ def list_agents(self, page: int = 1, page_size: int = 30, orderby: str = "update_time", desc: bool = True,
185
+ id: str | None = None, title: str | None = None) -> list[Agent]:
186
+ res = self.get("/agents",{"page": page, "page_size": page_size, "orderby": orderby, "desc": desc, "id": id, "title": title})
187
+ res = res.json()
188
+ result_list = []
189
+ if res.get("code") == 0:
190
+ for data in res['data']:
191
+ result_list.append(Agent(self, data))
192
+ return result_list
193
+ raise Exception(res["message"])
sdk/python/test/test_sdk_api/t_agent.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ from ragflow_sdk import RAGFlow,Agent
2
+ from common import HOST_ADDRESS
3
+ import pytest
4
+
5
+ @pytest.mark.skip(reason="")
6
+ def test_list_agents_with_success(get_api_key_fixture):
7
+ API_KEY=get_api_key_fixture
8
+ rag = RAGFlow(API_KEY,HOST_ADDRESS)
9
+ rag.list_agents()
sdk/python/test/test_sdk_api/t_dataset.py CHANGED
@@ -51,4 +51,5 @@ def test_delete_datasets_with_success(get_api_key_fixture):
51
  def test_list_datasets_with_success(get_api_key_fixture):
52
  API_KEY = get_api_key_fixture
53
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
 
54
  rag.list_datasets()
 
51
  def test_list_datasets_with_success(get_api_key_fixture):
52
  API_KEY = get_api_key_fixture
53
  rag = RAGFlow(API_KEY, HOST_ADDRESS)
54
+ rag.create_dataset("test_list_datasets")
55
  rag.list_datasets()
sdk/python/test/test_sdk_api/t_session.py CHANGED
@@ -107,4 +107,11 @@ def test_create_agent_conversation_with_success(get_api_key_fixture):
107
  API_KEY = "ragflow-BkOGNhYjIyN2JiODExZWY5MzVhMDI0Mm"
108
  rag = RAGFlow(API_KEY,HOST_ADDRESS)
109
  session = Agent.create_session("2e45b5209c1011efa3e90242ac120006", rag)
110
- session.ask("What is this job")
 
 
 
 
 
 
 
 
107
  API_KEY = "ragflow-BkOGNhYjIyN2JiODExZWY5MzVhMDI0Mm"
108
  rag = RAGFlow(API_KEY,HOST_ADDRESS)
109
  session = Agent.create_session("2e45b5209c1011efa3e90242ac120006", rag)
110
+ session.ask("What is this job")
111
+
112
+ @pytest.mark.skip(reason="")
113
+ def test_list_agent_sessions_with_success(get_api_key_fixture):
114
+ API_KEY = "ragflow-BkOGNhYjIyN2JiODExZWY5MzVhMDI0Mm"
115
+ agent_id = "2710f2269b4611ef8fdf0242ac120006"
116
+ rag = RAGFlow(API_KEY,HOST_ADDRESS)
117
+ Agent.list_sessions(agent_id,rag)