diff --git a/README.md b/README.md index c357962c..9c84156c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@
- 简体中文 | English | 日本語 | Russian + 简体中文 | English | 日本語 | Russian | 한국어

川虎 Chat 🐯 Chuanhu Chat

diff --git a/locale/ko_KR.json b/locale/ko_KR.json index 959a7641..d454482b 100644 --- a/locale/ko_KR.json +++ b/locale/ko_KR.json @@ -15,7 +15,7 @@ "⚠️ 为保证API-Key安全,请在配置文件`config.json`中修改网络设置": "⚠️ API-Key의 안전을 보장하기 위해 네트워크 설정을 `config.json` 구성 파일에서 수정해주세요.", "。你仍然可以使用聊天功能。": ". 채팅 기능을 계속 사용할 수 있습니다.", "上传": "업로드", - "上传了": "업로드되었습니다.", + "上传了": "업로드완료.", "上传到 OpenAI 后自动填充": "OpenAI로 업로드한 후 자동으로 채워집니다", "上传到OpenAI": "OpenAI로 업로드", "上传文件": "파일 업로드", @@ -56,14 +56,14 @@ "对话历史": "대화 내역", "对话历史记录": "대화 기록", "对话命名方式": "대화 이름 설정", - "导出为 Markdown": "마크다운으로 내보내기", + "导出为 Markdown": "Markdown으로 내보내기", "川虎Chat": "Chuanhu Chat", "川虎Chat 🚀": "Chuanhu Chat 🚀", "工具箱": "도구 상자", "已经被删除啦": "이미 삭제되었습니다.", "开始实时传输回答……": "실시간 응답 출력 시작...", "开始训练": "훈련 시작", - "微调": "미세 조정", + "微调": "파인튜닝", "总结": "요약", "总结完成": "작업 완료", "您使用的就是最新版!": "최신 버전을 사용하고 있습니다!", @@ -80,7 +80,7 @@ "更新失败,请尝试[手动更新](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#手动更新)": "업데이트 실패, [수동 업데이트](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#手动更新)를 시도하십시오", "更新成功,请重启本程序": "업데이트 성공, 이 프로그램을 재시작 해주세요", "未命名对话历史记录": "이름없는 대화 기록", - "未设置代理...": "대리인이 설정되지 않았습니다...", + "未设置代理...": "프록시가 설정되지 않았습니다...", "本月使用金额": "이번 달 사용금액", "查看[使用介绍](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#微调-gpt-35)": "[사용 가이드](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#微调-gpt-35) 보기", "根据日期时间": "날짜 및 시간 기준", @@ -95,17 +95,17 @@ "用于定位滥用行为": "악용 사례 파악에 활용됨", "用户标识符": "사용자 식별자", "由Bilibili [土川虎虎虎](https://space.bilibili.com/29125536)、[明昭MZhao](https://space.bilibili.com/24807452) 和 [Keldos](https://github.com/Keldos-Li) 开发
访问川虎Chat的 [GitHub项目](https://github.com/GaiZhenbiao/ChuanhuChatGPT) 下载最新版脚本": "제작: Bilibili [土川虎虎虎](https://space.bilibili.com/29125536), [明昭MZhao](https://space.bilibili.com/24807452), [Keldos](https://github.com/Keldos-Li)\n\n최신 코드 다운로드: [GitHub](https://github.com/GaiZhenbiao/ChuanhuChatGPT)", - "知识库": "지식 라이브러리", - "知识库文件": "지식 라이브러리 파일", + "知识库": "knowledge base", + "知识库文件": "knowledge base 파일", "第一条提问": "첫 번째 질문", "索引构建完成": "인덱스 구축이 완료되었습니다.", "网络": "네트워크", "获取API使用情况失败:": "API 사용량 가져오기 실패:", "获取IP地理位置失败。原因:": "다음과 같은 이유로 IP 위치를 가져올 수 없습니다. 이유: ", "获取对话时发生错误,请查看后台日志": "대화를 가져오는 중 에러가 발생했습니다. 백그라운드 로그를 확인하세요", - "训练": "훈련", - "训练状态": "훈련 상태", - "训练轮数(Epochs)": "훈련 라운드(Epochs)", + "训练": "학습", + "训练状态": "학습 상태", + "训练轮数(Epochs)": "학습 Epochs", "设置": "설정", "设置保存文件名": "저장 파일명 설정", "设置文件名: 默认为.json,可选为.md": "파일 이름 설정: 기본값: .json, 선택: .md", @@ -114,7 +114,7 @@ "请查看 config_example.json,配置 Azure OpenAI": "Azure OpenAI 설정을 확인하세요", "请检查网络连接,或者API-Key是否有效。": "네트워크 연결 또는 API키가 유효한지 확인하세요", "请输入对话内容。": "대화 내용을 입력하세요.", - "请输入有效的文件名,不要包含以下特殊字符:": "유효한 파일 이름을 입력하세요. 다음 특수 문자는 포함하지 마세요: ", + "请输入有效的文件名,不要包含以下特殊字符:": "유효한 파일 이름을 입력하세요. 다음 특수 문자를 포함하지 마세요: ", "读取超时,无法获取对话。": "읽기 시간 초과, 대화를 가져올 수 없습니다.", "账单信息不适用": "청구 정보를 가져올 수 없습니다", "连接超时,无法获取对话。": "연결 시간 초과, 대화를 가져올 수 없습니다.", @@ -128,7 +128,7 @@ "高级": "고급", ",本次对话累计消耗了 ": ",이 대화의 전체 비용은 ", "💾 保存对话": "💾 대화 저장", - "📝 导出为 Markdown": "📝 마크다운으로 내보내기", + "📝 导出为 Markdown": "📝 Markdown으로 내보내기", "🔄 切换API地址": "🔄 API 주소 변경", "🔄 刷新": "🔄 새로고침", "🔄 检查更新...": "🔄 업데이트 확인...", @@ -139,4 +139,4 @@ "🗑️ 删除最旧对话": "🗑️ 가장 오래된 대화 삭제", "🧹 新的对话": "🧹 새로운 대화", "正在获取IP地址信息,请稍候...": "IP 주소 정보를 가져오는 중입니다. 잠시만 기다려주세요...", -} \ No newline at end of file +} diff --git a/modules/models/ChuanhuAgent.py b/modules/models/ChuanhuAgent.py index 8e04ee83..6a13c75d 100644 --- a/modules/models/ChuanhuAgent.py +++ b/modules/models/ChuanhuAgent.py @@ -13,7 +13,7 @@ from langchain.tools import BaseTool, StructuredTool, Tool, tool from langchain.callbacks.stdout import StdOutCallbackHandler from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler -from langchain.callbacks.manager import BaseCallbackManager +from langchain.callbacks.base import BaseCallbackManager from duckduckgo_search import DDGS from itertools import islice diff --git a/modules/models/DALLE3.py b/modules/models/DALLE3.py new file mode 100644 index 00000000..1adca4c9 --- /dev/null +++ b/modules/models/DALLE3.py @@ -0,0 +1,38 @@ +import re +import json +import openai +from openai import OpenAI +from .base_model import BaseLLMModel +from .. import shared +from ..config import retrieve_proxy + + +class OpenAI_DALLE3_Client(BaseLLMModel): + def __init__(self, model_name, api_key, user_name="") -> None: + super().__init__(model_name=model_name, user=user_name) + self.api_key = api_key + + def _get_dalle3_prompt(self): + prompt = self.history[-1]["content"] + if prompt.endswith("--raw"): + prompt = "I NEED to test how the tool works with extremely simple prompts. DO NOT add any detail, just use it AS-IS:" + prompt + return prompt + + @shared.state.switching_api_key + def get_answer_at_once(self): + prompt = self._get_dalle3_prompt() + with retrieve_proxy(): + client = OpenAI(api_key=openai.api_key) + try: + response = client.images.generate( + model="dall-e-3", + prompt=prompt, + size="1024x1024", + quality="standard", + n=1, + ) + except openai.BadRequestError as e: + msg = str(e) + match = re.search(r"'message': '([^']*)'", msg) + return match.group(1), 0 + return f'{response.data[0].revised_prompt}', 0 diff --git a/modules/models/base_model.py b/modules/models/base_model.py index 9615fb9b..52fcef34 100644 --- a/modules/models/base_model.py +++ b/modules/models/base_model.py @@ -21,7 +21,7 @@ from enum import Enum from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler -from langchain.callbacks.manager import BaseCallbackManager +from langchain.callbacks.base import BaseCallbackManager from typing import Any, Dict, List, Optional, Union @@ -153,6 +153,7 @@ class ModelType(Enum): Qwen = 15 OpenAIVision = 16 ERNIE = 17 + DALLE3 = 18 @classmethod def get_type(cls, model_name: str): @@ -195,6 +196,8 @@ def get_type(cls, model_name: str): model_type = ModelType.Qwen elif "ernie" in model_name_lower: model_type = ModelType.ERNIE + elif "dall" in model_name_lower: + model_type = ModelType.DALLE3 else: model_type = ModelType.LLaMA return model_type @@ -876,7 +879,7 @@ def auto_name_chat_history( if type(user_question) == list: user_question = user_question[0]["text"] filename = replace_special_symbols(user_question)[:16] + ".json" - return self.rename_chat_history(filename, chatbot, self.user_name) + return self.rename_chat_history(filename, chatbot) else: return gr.update() diff --git a/modules/models/models.py b/modules/models/models.py index c5f0767f..9e67c8cd 100644 --- a/modules/models/models.py +++ b/modules/models/models.py @@ -129,6 +129,10 @@ def get_model( elif model_type == ModelType.ERNIE: from .ERNIE import ERNIE_Client model = ERNIE_Client(model_name, api_key=os.getenv("ERNIE_APIKEY"),secret_key=os.getenv("ERNIE_SECRETKEY")) + elif model_type == ModelType.DALLE3: + from .DALLE3 import OpenAI_DALLE3_Client + access_key = os.environ.get("OPENAI_API_KEY", access_key) + model = OpenAI_DALLE3_Client(model_name, api_key=access_key, user_name=user_name) elif model_type == ModelType.Unknown: raise ValueError(f"未知模型: {model_name}") logging.info(msg) diff --git a/modules/presets.py b/modules/presets.py index 576cac5a..61c9b895 100644 --- a/modules/presets.py +++ b/modules/presets.py @@ -65,6 +65,7 @@ LOCAL_MODELS = [ "川虎助理", "川虎助理 Pro", + "DALL-E 3", "GooglePaLM", "xmchat", "Azure OpenAI", diff --git a/modules/utils.py b/modules/utils.py index 30689220..d6e8dc8a 100644 --- a/modules/utils.py +++ b/modules/utils.py @@ -243,7 +243,7 @@ def clip_rawtext(chat_message, need_escape=True): message_clipped = chat_message[: hr_match.start()] if hr_match else chat_message # second, avoid agent-prefix being escaped agent_prefix_pattern = ( - r'(

.*?<\/p>)' + r'(.*?)' ) # agent_matches = re.findall(agent_prefix_pattern, message_clipped) agent_parts = re.split(agent_prefix_pattern, message_clipped, flags=re.DOTALL) @@ -257,6 +257,7 @@ def clip_rawtext(chat_message, need_escape=True): else f'

{part}
' ) else: + part = part.replace(' data-fancybox="gallery"', '') final_message += part return final_message @@ -385,6 +386,7 @@ def save_file(filename, model, chatbot): "system": system, "history": history, "chatbot": chatbot, + "model_name": model.model_name, "single_turn": model.single_turn, "temperature": model.temperature, "top_p": model.top_p, @@ -429,6 +431,7 @@ def sorted_by_last_modified_time(list, dir): def get_file_names_by_type(dir, filetypes=[".json"]): + os.makedirs(dir, exist_ok=True) logging.debug(f"获取文件名列表,目录为{dir},文件类型为{filetypes}") files = [] for type in filetypes: diff --git a/modules/webui.py b/modules/webui.py index a9308d39..0d25c112 100644 --- a/modules/webui.py +++ b/modules/webui.py @@ -55,6 +55,7 @@ def reload_javascript(): js = javascript_html() js += '' js += '' + js += '' meta = """ diff --git a/readme/README_en.md b/readme/README_en.md index 138d745f..1873d56d 100644 --- a/readme/README_en.md +++ b/readme/README_en.md @@ -1,6 +1,6 @@
- 简体中文 | English | 日本語 | Russian + 简体中文 | English | 日本語 | Russian | 한국어

川虎 Chat 🐯 Chuanhu Chat

diff --git a/readme/README_ja.md b/readme/README_ja.md index b8bb9da5..46bb181c 100644 --- a/readme/README_ja.md +++ b/readme/README_ja.md @@ -1,6 +1,6 @@
- 简体中文 | English | 日本語 | Russian + 简体中文 | English | 日本語 | Russian | 한국어

川虎 Chat 🐯 Chuanhu Chat

diff --git a/readme/README_ko.md b/readme/README_ko.md new file mode 100644 index 00000000..f621bcfe --- /dev/null +++ b/readme/README_ko.md @@ -0,0 +1,190 @@ +
+ + 简体中文 | English | 日本語 | Russian | 한국어 +
+ +

川虎 Chat 🐯 Chuanhu Chat

+
+ + Logo + + +

+

ChatGPT/ChatGLM/LLaMA등의 LLM을 위한 가벼운 사용자 친화적 Web-UI

+

+ + Tests Passing + + + GitHub Contributors + + + GitHub pull requests + +

+ GPT-4 지원 · 파일에 대한 채팅 · LLMs 로컬 배포 · 웹 검색 · Chuanhu Agent · 파인튜닝 +

+ 영상 튜토리얼 + · + 2.0 소개 + · + 3.0 소개 & 튜토리얼 + || + 온라인 테스트 + · + 원클릭 배포 +

+

+
+ +[![Video Title](https://github.com/GaiZhenbiao/ChuanhuChatGPT/assets/51039745/0eee1598-c2fd-41c6-bda9-7b059a3ce6e7.jpg)](https://github.com/GaiZhenbiao/ChuanhuChatGPT/assets/51039745/0eee1598-c2fd-41c6-bda9-7b059a3ce6e7?autoplay=1) + +## ✨ 5.0 업데이트! + +![ChuanhuChat5update](https://github.com/GaiZhenbiao/ChuanhuChatGPT/assets/70903329/f2c2be3a-ea93-4edf-8221-94eddd4a0178) + + +New! 완전히 새로운 사용자 인터페이스! 반투명 유리효과를 지원합니다! + +New! 모든 모바일 장치에 적합한 UI. + +New! 대화 기록이 왼쪽으로 이동하여 더 편리하게 사용할 수 있습니다. 검색, 삭제, 이름 변경이 가능합니다. + +New! 자동으로 대화 기록의 이름을 설정할 수 있습니다. (설정에서 활성화 필요). + +New! Chuanhu Chat는 이제 Chrome/Edge/Safari 등 브라우저를 지원하는 PWA입니다. + +New! 아이콘들이 플랫폼에 맞게 조정되어, 더 자연스럽습니다. + +New! GPT 3.5! 파인튜닝을 지원합니다. + +## 지원 모델들 + +| API 호출 모델들 | 설명 | 로컬 배포 모델 | 설명 | +|:-------------------------------------------------------------------------------------:|-----------------------|:-------------------------------------------------------------------------------------------------:|---------------------| +| [ChatGPT(GPT-4)](https://chat.openai.com) | gpt-3.5 파인튜닝 지원 | [ChatGLM](https://github.com/THUDM/ChatGLM-6B) ([ChatGLM2](https://github.com/THUDM/ChatGLM2-6B)) | +| [Azure OpenAI](https://azure.microsoft.com/en-us/products/ai-services/openai-service) | | [LLaMA](https://github.com/facebookresearch/llama) | Lora 모델 지원 +| [Google PaLM](https://developers.generativeai.google/products/palm) | 스트리밍 미지원 | [StableLM](https://github.com/Stability-AI/StableLM) +| [iFlytek Starfire Cognition Large Model](https://xinghuo.xfyun.cn) | | [MOSS](https://github.com/OpenLMLab/MOSS) +| [Inspur Yuan 1.0](https://air.inspur.com/home) | | [Qwen](https://github.com/QwenLM/Qwen/tree/main) +| [MiniMax](https://api.minimax.chat/) | +| [XMChat](https://github.com/MILVLG/xmchat) | 스트리밍 미지원 +| [Midjourney](https://www.midjourney.com/) | 스트리밍 미지원 +| [Claude](https://www.anthropic.com/) | + +## 사용 팁 + +### 💪 강력한 기능 +- **Chuanhu Assistant**: AutoGPT와 같이,문제를 자동으로 해결합니다. +- **온라인 검색**: ChatGPT의 데이터가 너무 오래되었나요? LLM과 인터넷의 정보를 함께 사용하세요. +- **Knowledge Base**: ChatGPT가 당신의 읽기 속도를 높여줍니다! 파일에 대해 질문하세요. +- **LLM 로컬 배포**: 원클릭 LLM 배포로 당신만의 LLM을 가지세요. + +### 🤖 시스템 프롬프트 +- 시스템 프롬프트를 통해 사전 조건을 설정하면 역할극을 효과적으로 할 수 있습니다. +- ChuanhuChat는 프롬프트 프리셋을 제공합니다. `프롬프트 템플릿 불러오기`탭에서 프롬프트를 불러온 후 아래 리스트에서 원하는 프롬프트를 설정하세요. + +### 💬 기본 대화 +- 답변이 만족스럽지 않다면 `재생성` 버튼으로 다시 시도하거나 `이 라운드의 질문과 답변 삭제` 버튼을 사용할 수 있습니다. +- 입력창은 줄 바꿈을 지원합니다. Shift + Enter 를 사용하세요. +- 입력창에서 를 사용해 이전 전송 기록으로 이동할 수 있습니다. +- 매번 새로운 대화를 만드는 것이 귀찮다면 `단일 대화` 기능을 사용하세요; +- 답변 옆의 버튼들은 `일괄 복사`, `원본 Markdown 보기` 기능을 제공합니다. +- ChatGPT가 특정 언어로 응답할 수 있도록 답장 언어를 지정하세요. + +### 📜 대화 기록 +- 대화 기록은 자동으로 저장됩니다. +- 다중 사용자모드 사용시 본인 대화는 본인만 볼 수 있습니다. +- 대화 기록명을 바꿔 추후 검색을 용이하게 할 수 있습니다. +- New! LLM이 대화 기록을 요약하여 대화 기록명을 자동으로 설정하게 할 수 있습니다. +- New! 정규식을 사용하여 검색할 수 있습니다. + +### 🖼️ 간단하고 아름다운 UI +- 자체 개발한 Small-and-Beautiful 테마는 간단하고 아름다운 UI를 제공합니다. +- 자동 다크/라이트 테마 전환으로 아침부터 밤까지 편안한 경험을 제공합니다. +- 완벽한 LaTeX / 표 / 소스 코드 렌더링; +- New! 비선형 애니메이션, 반투명 유리효과 +- New! Windows / macOS / Linux / iOS / Android 각 플랫폼에 최적화된 경험을 제공합니다. +- New! PWA앱 설치로 더 자연스러운 경험을 제공합니다. + +### 👨‍💻 전문가용 기능 +- New! gpt-3.5 파인튜닝 제공! +- LLM의 다양한 파라미터들을 조정할 수 있습니다. +- API-host 변경 지원 +- 커스텀 프록시 제공 +- 다중 api키 로드밸런싱 기능 제공 + +### ⚒️ 배포 관련 +- 서버에 배포: `config.json`에서 다음 항목을 설정하세요 `"server_name": "0.0.0.0", "server_port": ,`. +- 공개 주소 가져오기: `config.json`에서 다음 항목을 설정하세요 `"share": true,`. +- Hugging Face에서 사용: 앱이 더 빠르게 반응할 수 있도록 우측 상단의 버튼에서 **Duplicate the Space** 를 사용하세요 + +## 빠른 시작 + +터미널에서 다음 명령을 실행합니다. + +```shell +git clone https://github.com/GaiZhenbiao/ChuanhuChatGPT.git +cd ChuanhuChatGPT +pip install -r requirements.txt +``` + +`config_example.json`의 복제본을 만들고, 이름을 `config.json`로 변경합니다, 이후 파일에서 API키와 다른 세팅들을 수정합니다. + +```shell +python ChuanhuChatbot.py +``` + +브라우저가 자동으로 열리고 **Chuanhu Chat**를 사용해 ChatGPT 또는 다른 모델들을 사용할 수 있습니다. + +> **참고** +> +> [wiki page](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程) 에서 자세한 정보를 확인하세요 + + +## 문제해결 + +문제가 발생하면 **최신 코드로 업데이트하고1** **종속성을 업데이트2** 한 후 재시도 해보세요. 단계는 다음과 같습니다.: + +1. Github 웹 페이지의 `Download ZIP`버튼으로 최신 코드를 다운로드하거나 다음 코드를 사용하세요 + ```shell + git pull https://github.com/GaiZhenbiao/ChuanhuChatGPT.git main -f + ``` +2. 다음 코드로 종속성을 업데이트하세요 + ``` + pip install -r requirements.txt + ``` + +보통 이 방법으로 문제가 해결됩니다. + +문제가 해결되지 않는다면 다음 페이지를 확인해보세요: [Frequently Asked Questions (FAQ)](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/常见问题) + +이 페이지에는 거의 대부분의 문제와 해결법이 있습니다. 자세히 읽어보세요 + +## 더 알아보기 + +더 많은 정보가 [wiki](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki) 에 있습니다. + +- [어떻게 번역에 기여하나요?](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/Localization) +- [어떻게 이 프로젝트에 기여하나요?](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/贡献指南) +- [어떻게 이 프로젝트를 인용하나요?](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用许可#如何引用该项目) +- [업데이트 기록](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/更新日志) +- [프로젝트 라이선스](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用许可) + +## Starchart + +[![Star History Chart](https://api.star-history.com/svg?repos=GaiZhenbiao/ChuanhuChatGPT&type=Date)](https://star-history.com/#GaiZhenbiao/ChuanhuChatGPT&Date) + +## 기여자들 + + + + + +## 기부 + +🐯 이 프로젝트가 도움이되었다면, 저에게 커피나 콜라를 사주세요~ + +Buy Me A Coffee + +image diff --git a/readme/README_ru.md b/readme/README_ru.md index 93ea4c8d..c36da38a 100644 --- a/readme/README_ru.md +++ b/readme/README_ru.md @@ -1,6 +1,6 @@
- 简体中文 | English | 日本語 | Russian + 简体中文 | English | 日本語 | Russian | 한국어

川虎 Chat 🐯 Chuanhu Chat

diff --git a/requirements.txt b/requirements.txt index 301d2f9c..dbc82da7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,7 +8,8 @@ tqdm colorama googlesearch-python Pygments -langchain==0.0.316 +openai==1.3.7 +langchain==0.0.345 markdown PyPDF2 pdfplumber @@ -22,14 +23,13 @@ duckduckgo-search>=3.9.5 arxiv wikipedia google.generativeai -openai==0.28.1 unstructured google-api-python-client tabulate ujson python-docx websocket_client -pydantic==1.10.8 +pydantic==2.5.2 google-search-results anthropic==0.3.11 Pillow>=10.1.0 diff --git a/web_assets/html/header_title.html b/web_assets/html/header_title.html index 024b3aa3..dbba9326 100644 --- a/web_assets/html/header_title.html +++ b/web_assets/html/header_title.html @@ -1,20 +1,11 @@
- +
- -
-
{app_title}
-
+ + +
+
{app_title}
\ No newline at end of file diff --git a/web_assets/javascript/ChuanhuChat.js b/web_assets/javascript/ChuanhuChat.js index b7829d86..b1b8de55 100644 --- a/web_assets/javascript/ChuanhuChat.js +++ b/web_assets/javascript/ChuanhuChat.js @@ -349,6 +349,7 @@ function chatbotContentChanged(attempt = 1, force = false) { disableSendBtn(); updateSlider(); updateCheckboxes(); + bindFancyBox(); gradioApp().querySelectorAll('#chuanhu-chatbot .message-wrap .message.bot').forEach(addChuanhuButton); diff --git a/web_assets/javascript/utils.js b/web_assets/javascript/utils.js index 516baee8..1ba2e264 100644 --- a/web_assets/javascript/utils.js +++ b/web_assets/javascript/utils.js @@ -71,6 +71,16 @@ function downloadFile(fileUrl, filename = "", format = "", retryTimeout = 200, m } +function bindFancyBox() { + Fancybox.bind('[data-fancybox]', { + Carousel: { + Panzoom: { + decelFriction: 0.5 + } + } + }); +} + /* NOTE: These reload functions are not used in the current version of the code. * From stable-diffusion-webui diff --git a/web_assets/stylesheet/chatbot.css b/web_assets/stylesheet/chatbot.css index a7be4a0a..8089c759 100644 --- a/web_assets/stylesheet/chatbot.css +++ b/web_assets/stylesheet/chatbot.css @@ -243,6 +243,14 @@ hr.append-display { border-radius: 8px !important; margin: 4px !important } +.message.bot img { + border-radius: 8px !important; + width: 512px; + max-height: unset !important; + max-width: 100% !important; + margin: unset !important; + margin-bottom: .8em !important; +} /* custom buttons */ .chuanhu-btn {