Procházet zdrojové kódy

add langchat-web-sdk preview

tycoding před 1 rokem
rodič
revize
b3722efe97

+ 2 - 1
langchat-ui/index.html

@@ -1,5 +1,5 @@
 <!DOCTYPE html>
-<html lang="zh-cmn-Hans" id="htmlRoot" data-theme="light">
+<html id="htmlRoot" data-theme="light" lang="zh-cmn-Hans">
 <head>
   <meta charset="UTF-8">
   <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"/>
@@ -10,6 +10,7 @@
   />
   <link href="/favicon.ico" rel="icon"/>
   <title><%= title %></title>
+  <script defer src="/langchat-web-sdk/index.umd.js"></script>
 </head>
 <body>
 <div id="appProvider" style="display: none"></div>

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
langchat-ui/public/langchat-web-sdk/index.cjs


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
langchat-ui/public/langchat-web-sdk/index.cjs.map


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
langchat-ui/public/langchat-web-sdk/index.modern.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
langchat-ui/public/langchat-web-sdk/index.modern.js.map


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
langchat-ui/public/langchat-web-sdk/index.module.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
langchat-ui/public/langchat-web-sdk/index.module.js.map


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
langchat-ui/public/langchat-web-sdk/index.umd.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
langchat-ui/public/langchat-web-sdk/index.umd.js.map


+ 27 - 0
langchat-ui/public/langchat-web-sdk/src/index.d.ts

@@ -0,0 +1,27 @@
+export type WidgetConfig = {
+    url: string;
+    apiKey: string;
+    threadId: string | null;
+    responseIsAStream: boolean;
+    user: Record<any, any>;
+    widgetTitle: string;
+    greetingMessage: string | null;
+    disableErrorAlert: boolean;
+    closeOnOutsideClick: boolean;
+    openOnLoad: boolean;
+};
+declare function init(): Promise<void>;
+declare function open(e: Event): void;
+declare function close(): void;
+declare const langchatChatWidget: {
+    open: typeof open;
+    close: typeof close;
+    config: WidgetConfig;
+    init: typeof init;
+};
+declare global {
+    interface Window {
+        langchatChatWidget: typeof langchatChatWidget;
+    }
+}
+export default langchatChatWidget;

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
langchat-ui/public/langchat-web-sdk/src/widgetHtmlString.d.ts


+ 25 - 3
langchat-ui/src/views/app/web/components/preview.vue

@@ -14,11 +14,33 @@
   - limitations under the License.
   -->
 
-<script lang="ts" setup></script>
+<script lang="ts" setup>
+  import { onMounted } from 'vue';
+
+  onMounted(() => {
+    window.langchatChatWidget.config.widgetTitle = 'LangChat';
+    window.langchatChatWidget.config.apiKey = 'langchat-20c32a09b95c44c4a16301da70860d57';
+    window.langchatChatWidget.config.greetingMessage =
+      "Hello there! Here's a super long greeting.\n\nJust to see how you'd handle multiple lines and linebreaks.";
+    window.langchatChatWidget.config.url = 'http://127.0.0.1:8100/v1/chat/completions/channel/web';
+    window.langchatChatWidget.config.openOnLoad = true;
+    window.langchatChatWidget.config.responseIsAStream = true;
+    window.langchatChatWidget.config.closeOnOutsideClick = false;
+  });
+</script>
 
 <template>
-  <div class="h-full overflow-auto rounded">
-    <iframe height="100%" src="http://127.0.0.1:8099/" width="100%"></iframe>
+  <div class="h-full overflow-auto rounded w-full relative">
+    <div style="position: absolute; bottom: 8%; left: 8%">
+      <div data-langchat-chat-widget-button style="cursor: pointer; margin-top: 10px">
+        <svg height="40" viewBox="0 0 20 20" width="40" xmlns="http://www.w3.org/2000/svg">
+          <path
+            d="M14.479 8c.179 0 .356.034.521.099V4.5A1.5 1.5 0 0 0 13.5 3h-3v-.5A.48.48 0 0 0 10 2c-.276 0-.5.23-.5.5V3h-3A1.5 1.5 0 0 0 5 4.5v4A1.5 1.5 0 0 0 6.5 10h6.294l.338-1.039l.004-.012A1.42 1.42 0 0 1 14.48 8M7 6.5a1 1 0 1 1 2 0a1 1 0 0 1-2 0m4 0a1 1 0 1 1 2 0a1 1 0 0 1-2 0M10 18c1.743 0 3.042-.226 4.005-.612a1.3 1.3 0 0 1 .117-.44a1.42 1.42 0 0 1-.964-.897l-.004-.012l-.351-1.08l-.035-.09a1.2 1.2 0 0 0-.257-.383l-.064-.06a1.2 1.2 0 0 0-.406-.232l-1.08-.35l-.011-.005a1.423 1.423 0 0 1-.545-2.336H5.309a1.81 1.81 0 0 0-1.809 1.81v.689h.005c.034.78.248 1.757 1.123 2.555C5.584 17.43 7.234 18 10 18m5.226-7.647l-.348-1.07a.423.423 0 0 0-.799 0l-.348 1.07a2.2 2.2 0 0 1-1.377 1.397l-1.071.348a.423.423 0 0 0 0 .798l1.071.348a2.2 2.2 0 0 1 1.399 1.403l.348 1.07a.423.423 0 0 0 .798 0l.349-1.07a2.2 2.2 0 0 1 1.398-1.397l1.072-.348a.424.424 0 0 0 0-.798l-.022-.005l-1.072-.349a2.2 2.2 0 0 1-1.398-1.397m3.791 6.612l.766.248l.015.004a.303.303 0 0 1 .147.46a.3.3 0 0 1-.147.11l-.765.248a1.58 1.58 0 0 0-1 .999l-.248.764a.302.302 0 0 1-.57 0l-.249-.764a1.58 1.58 0 0 0-.999-1.002l-.765-.249a.303.303 0 0 1-.146-.46a.3.3 0 0 1 .146-.11l.765-.248a1.58 1.58 0 0 0 .984-.998l.249-.765a.302.302 0 0 1 .57 0l.249.765a1.58 1.58 0 0 0 .999.998"
+            fill="currentColor"
+          />
+        </svg>
+      </div>
+    </div>
   </div>
 </template>
 

+ 1 - 1
langchat-ui/src/views/app/web/index.vue

@@ -46,7 +46,7 @@
 
     <div class="flex-1 overflow-y-auto">
       <div class="flex gap-4 h-full w-full">
-        <Preview class="w-3/5" />
+        <Preview class="w-2/4" />
         <Edit class="w-full" />
       </div>
     </div>

+ 1 - 0
langchat-ui/tsconfig.json

@@ -45,6 +45,7 @@
     "build/**/*.ts",
     "build/**/*.d.ts",
     "mock/**/*.ts",
+    "public/**/*.ts",
     "components.d.ts",
     "vite.config.ts"
   ],

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů