test.html 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>合同信息提取</title>
  5. <style>
  6. body {
  7. font-family: Arial, sans-serif;
  8. padding: 20px;
  9. }
  10. button {
  11. padding: 10px 20px;
  12. background-color: #4caf50;
  13. color: white;
  14. border: none;
  15. border-radius: 4px;
  16. cursor: pointer;
  17. }
  18. button:hover {
  19. background-color: #45a049;
  20. }
  21. #result {
  22. margin-top: 20px;
  23. padding: 15px;
  24. border: 1px solid #ddd;
  25. border-radius: 4px;
  26. white-space: pre-wrap;
  27. }
  28. </style>
  29. </head>
  30. <body>
  31. <button onclick="sendRequest()">提取合同信息</button>
  32. <div id="result"></div>
  33. <script>
  34. async function sendRequest() {
  35. const url = "http://192.168.10.204:5000/api/chats/contract_extract";
  36. const payload = {
  37. ip: "192.168.10.204",
  38. port: "8080",
  39. chat_id: "74d25da0fd8a11ef9b830242ac120006",
  40. question:
  41. "抽取合同关键信息,将信息转为结构化数据 抽取信息如下:金额(相同含义:服务费)、甲方信息(甲方,甲方法定代表人(负责人),住 所)、乙方信息(已方,乙方法定代表人(负责人),住 所)、付款计划(服务费结算期限)、合同期限,以key-value的方式返回信息",
  42. stream: false,
  43. session_id: "f0ee1021110047d4a51f82e0570f43ca",
  44. };
  45. try {
  46. const response = await fetch(url, {
  47. method: "POST",
  48. headers: {
  49. "Content-Type": "application/json",
  50. Authorization: "Bearer ragflow-I5ZWRhYzU2ZmEzMTExZWZiYmI3MDI0Mm",
  51. },
  52. body: JSON.stringify(payload),
  53. });
  54. if (!response.ok) {
  55. throw new Error(`HTTP error! status: ${response.status}`);
  56. }
  57. const data = await response.json();
  58. document.getElementById("result").textContent = JSON.stringify(
  59. data,
  60. null,
  61. 2
  62. );
  63. } catch (error) {
  64. console.error("Error:", error);
  65. document.getElementById("result").textContent =
  66. "请求失败: " + error.message;
  67. }
  68. }
  69. </script>
  70. </body>
  71. </html>