ソースを参照

支持 headers

visuddhinanda 1 年間 前
コミット
d1f6830515

+ 2 - 1
api-v8/database/migrations/2025_02_04_081924_create_model_logs_table.php

@@ -17,8 +17,9 @@ class CreateModelLogsTable extends Migration
             $table->id();
             $table->uuid('uid')->unique();
             $table->uuid('model_id')->index();
-            $table->text('request_url');
+            $table->json('request_headers');
             $table->json('request_data');
+            $table->json('response_headers')->nullable();
             $table->json('response_data')->nullable();
             $table->integer('status')->index();
             $table->boolean('success')->default(true);

+ 39 - 2
dashboard-v4/dashboard/src/components/ai/AiModelLogList.tsx

@@ -44,6 +44,32 @@ const AiModelLogList = ({ modelId }: IWidget) => {
                 </div>
               );
             };
+            const info = (headers: string, data: string) => {
+              return (
+                <div>
+                  <Text strong>Headers</Text>
+                  <div
+                    style={{
+                      backgroundColor: "rgb(246, 248, 250)",
+                      border: "1px solid gray",
+                      padding: 6,
+                    }}
+                  >
+                    {jsonView(headers)}
+                  </div>
+                  <Text strong>Payload</Text>
+                  <div
+                    style={{
+                      backgroundColor: "rgb(246, 248, 250)",
+                      border: "1px solid gray",
+                      padding: 6,
+                    }}
+                  >
+                    {jsonView(data)}
+                  </div>
+                </div>
+              );
+            };
             return (
               <>
                 <Tabs
@@ -51,12 +77,23 @@ const AiModelLogList = ({ modelId }: IWidget) => {
                     {
                       label: "request",
                       key: "request",
-                      children: jsonView(entity.request_data),
+                      children: (
+                        <div>
+                          {info(entity.request_headers, entity.request_data)}
+                        </div>
+                      ),
                     },
                     {
                       label: "response",
                       key: "response",
-                      children: jsonView(entity.response_data),
+                      children: (
+                        <div>
+                          {info(
+                            entity.response_headers ?? "",
+                            entity.response_data ?? ""
+                          )}
+                        </div>
+                      ),
                     },
                   ]}
                 />

+ 2 - 1
dashboard-v4/dashboard/src/components/api/ai.ts

@@ -81,8 +81,9 @@ export interface IAiModelLogData {
   id: string;
   uid: string;
   model_id: string;
-  request_url: string;
+  request_headers: string;
   request_data: string;
+  response_headers?: string | null;
   response_data?: string | null;
   status: number;
   success: boolean;