docs: update the framework of doc site (#207)
Signed-off-by: Carson Yang <yangchuansheng33@gmail.com>
@@ -1,437 +0,0 @@
|
||||
{
|
||||
"theme.ErrorPageContent.title": {
|
||||
"message": "页面已崩溃。",
|
||||
"description": "The title of the fallback page when the page crashed"
|
||||
},
|
||||
"theme.ErrorPageContent.tryAgain": {
|
||||
"message": "重试",
|
||||
"description": "The label of the button to try again rendering when the React error boundary captures an error"
|
||||
},
|
||||
"theme.NotFound.title": {
|
||||
"message": "找不到页面",
|
||||
"description": "The title of the 404 page"
|
||||
},
|
||||
"theme.NotFound.p1": {
|
||||
"message": "我们找不到您要找的页面。",
|
||||
"description": "The first paragraph of the 404 page"
|
||||
},
|
||||
"theme.NotFound.p2": {
|
||||
"message": "请联系原始链接来源网站的所有者,并告知他们链接已损坏。",
|
||||
"description": "The 2nd paragraph of the 404 page"
|
||||
},
|
||||
"theme.AnnouncementBar.closeButtonAriaLabel": {
|
||||
"message": "关闭",
|
||||
"description": "The ARIA label for close button of announcement bar"
|
||||
},
|
||||
"theme.BackToTopButton.buttonAriaLabel": {
|
||||
"message": "回到顶部",
|
||||
"description": "The ARIA label for the back to top button"
|
||||
},
|
||||
"theme.blog.paginator.navAriaLabel": {
|
||||
"message": "博文列表分页导航",
|
||||
"description": "The ARIA label for the blog pagination"
|
||||
},
|
||||
"theme.blog.paginator.newerEntries": {
|
||||
"message": "较新的博文",
|
||||
"description": "The label used to navigate to the newer blog posts page (previous page)"
|
||||
},
|
||||
"theme.blog.paginator.olderEntries": {
|
||||
"message": "较旧的博文",
|
||||
"description": "The label used to navigate to the older blog posts page (next page)"
|
||||
},
|
||||
"theme.blog.archive.title": {
|
||||
"message": "历史博文",
|
||||
"description": "The page & hero title of the blog archive page"
|
||||
},
|
||||
"theme.blog.archive.description": {
|
||||
"message": "历史博文",
|
||||
"description": "The page & hero description of the blog archive page"
|
||||
},
|
||||
"theme.blog.post.readingTime.plurals": {
|
||||
"message": "{readingTime} 分钟阅读",
|
||||
"description": "Pluralized label for \"{readingTime} min read\". Use as much plural forms (separated by \"|\") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)"
|
||||
},
|
||||
"theme.blog.post.readMoreLabel": {
|
||||
"message": "阅读 {title} 的全文",
|
||||
"description": "The ARIA label for the link to full blog posts from excerpts"
|
||||
},
|
||||
"theme.blog.post.readMore": {
|
||||
"message": "阅读更多",
|
||||
"description": "The label used in blog post item excerpts to link to full blog posts"
|
||||
},
|
||||
"theme.blog.post.paginator.navAriaLabel": {
|
||||
"message": "博文分页导航",
|
||||
"description": "The ARIA label for the blog posts pagination"
|
||||
},
|
||||
"theme.blog.post.paginator.newerPost": {
|
||||
"message": "较新一篇",
|
||||
"description": "The blog post button label to navigate to the newer/previous post"
|
||||
},
|
||||
"theme.blog.post.paginator.olderPost": {
|
||||
"message": "较旧一篇",
|
||||
"description": "The blog post button label to navigate to the older/next post"
|
||||
},
|
||||
"theme.blog.post.plurals": {
|
||||
"message": "{count} 篇博文",
|
||||
"description": "Pluralized label for \"{count} posts\". Use as much plural forms (separated by \"|\") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)"
|
||||
},
|
||||
"theme.blog.tagTitle": {
|
||||
"message": "{nPosts} 含有标签「{tagName}」",
|
||||
"description": "The title of the page for a blog tag"
|
||||
},
|
||||
"theme.tags.tagsPageLink": {
|
||||
"message": "查看所有标签",
|
||||
"description": "The label of the link targeting the tag list page"
|
||||
},
|
||||
"theme.colorToggle.ariaLabel": {
|
||||
"message": "切换浅色/暗黑模式(当前为{mode})",
|
||||
"description": "The ARIA label for the navbar color mode toggle"
|
||||
},
|
||||
"theme.colorToggle.ariaLabel.mode.dark": {
|
||||
"message": "暗黑模式",
|
||||
"description": "The name for the dark color mode"
|
||||
},
|
||||
"theme.colorToggle.ariaLabel.mode.light": {
|
||||
"message": "浅色模式",
|
||||
"description": "The name for the light color mode"
|
||||
},
|
||||
"theme.docs.breadcrumbs.home": {
|
||||
"message": "主页面",
|
||||
"description": "The ARIA label for the home page in the breadcrumbs"
|
||||
},
|
||||
"theme.docs.breadcrumbs.navAriaLabel": {
|
||||
"message": "页面路径",
|
||||
"description": "The ARIA label for the breadcrumbs"
|
||||
},
|
||||
"theme.docs.DocCard.categoryDescription": {
|
||||
"message": "{count} 个项目",
|
||||
"description": "The default description for a category card in the generated index about how many items this category includes"
|
||||
},
|
||||
"theme.docs.paginator.navAriaLabel": {
|
||||
"message": "文档分页导航",
|
||||
"description": "The ARIA label for the docs pagination"
|
||||
},
|
||||
"theme.docs.paginator.previous": {
|
||||
"message": "上一页",
|
||||
"description": "The label used to navigate to the previous doc"
|
||||
},
|
||||
"theme.docs.paginator.next": {
|
||||
"message": "下一页",
|
||||
"description": "The label used to navigate to the next doc"
|
||||
},
|
||||
"theme.docs.tagDocListPageTitle.nDocsTagged": {
|
||||
"message": "{count} 篇文档带有标签",
|
||||
"description": "Pluralized label for \"{count} docs tagged\". Use as much plural forms (separated by \"|\") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)"
|
||||
},
|
||||
"theme.docs.tagDocListPageTitle": {
|
||||
"message": "{nDocsTagged}「{tagName}」",
|
||||
"description": "The title of the page for a docs tag"
|
||||
},
|
||||
"theme.docs.versionBadge.label": {
|
||||
"message": "版本:{versionLabel}"
|
||||
},
|
||||
"theme.docs.versions.unreleasedVersionLabel": {
|
||||
"message": "此为 {siteTitle} {versionLabel} 版尚未发行的文档。",
|
||||
"description": "The label used to tell the user that he's browsing an unreleased doc version"
|
||||
},
|
||||
"theme.docs.versions.unmaintainedVersionLabel": {
|
||||
"message": "此为 {siteTitle} {versionLabel} 版的文档,现已不再积极维护。",
|
||||
"description": "The label used to tell the user that he's browsing an unmaintained doc version"
|
||||
},
|
||||
"theme.docs.versions.latestVersionSuggestionLabel": {
|
||||
"message": "最新的文档请参阅 {latestVersionLink} ({versionLabel})。",
|
||||
"description": "The label used to tell the user to check the latest version"
|
||||
},
|
||||
"theme.docs.versions.latestVersionLinkLabel": {
|
||||
"message": "最新版本",
|
||||
"description": "The label used for the latest version suggestion link label"
|
||||
},
|
||||
"theme.common.editThisPage": {
|
||||
"message": "编辑此页",
|
||||
"description": "The link label to edit the current page"
|
||||
},
|
||||
"theme.common.headingLinkTitle": {
|
||||
"message": "标题的直接链接",
|
||||
"description": "Title for link to heading"
|
||||
},
|
||||
"theme.lastUpdated.atDate": {
|
||||
"message": "于 {date} ",
|
||||
"description": "The words used to describe on which date a page has been last updated"
|
||||
},
|
||||
"theme.lastUpdated.byUser": {
|
||||
"message": "由 {user} ",
|
||||
"description": "The words used to describe by who the page has been last updated"
|
||||
},
|
||||
"theme.lastUpdated.lastUpdatedAtBy": {
|
||||
"message": "最后{byUser}{atDate}更新",
|
||||
"description": "The sentence used to display when a page has been last updated, and by who"
|
||||
},
|
||||
"theme.navbar.mobileVersionsDropdown.label": {
|
||||
"message": "选择版本",
|
||||
"description": "The label for the navbar versions dropdown on mobile view"
|
||||
},
|
||||
"theme.common.skipToMainContent": {
|
||||
"message": "跳到主要内容",
|
||||
"description": "The skip to content label used for accessibility, allowing to rapidly navigate to main content with keyboard tab/enter navigation"
|
||||
},
|
||||
"theme.tags.tagsListLabel": {
|
||||
"message": "标签:",
|
||||
"description": "The label alongside a tag list"
|
||||
},
|
||||
"theme.blog.sidebar.navAriaLabel": {
|
||||
"message": "最近博文导航",
|
||||
"description": "The ARIA label for recent posts in the blog sidebar"
|
||||
},
|
||||
"theme.CodeBlock.copied": {
|
||||
"message": "复制成功",
|
||||
"description": "The copied button label on code blocks"
|
||||
},
|
||||
"theme.CodeBlock.copyButtonAriaLabel": {
|
||||
"message": "复制代码到剪贴板",
|
||||
"description": "The ARIA label for copy code blocks button"
|
||||
},
|
||||
"theme.CodeBlock.copy": {
|
||||
"message": "复制",
|
||||
"description": "The copy button label on code blocks"
|
||||
},
|
||||
"theme.CodeBlock.wordWrapToggle": {
|
||||
"message": "切换自动换行",
|
||||
"description": "The title attribute for toggle word wrapping button of code block lines"
|
||||
},
|
||||
"theme.DocSidebarItem.toggleCollapsedCategoryAriaLabel": {
|
||||
"message": "打开/收起侧边栏菜单「{label}」",
|
||||
"description": "The ARIA label to toggle the collapsible sidebar category"
|
||||
},
|
||||
"theme.navbar.mobileLanguageDropdown.label": {
|
||||
"message": "选择语言",
|
||||
"description": "The label for the mobile language switcher dropdown"
|
||||
},
|
||||
"theme.TOCCollapsible.toggleButtonLabel": {
|
||||
"message": "本页总览",
|
||||
"description": "The label used by the button on the collapsible TOC component"
|
||||
},
|
||||
"theme.docs.sidebar.collapseButtonTitle": {
|
||||
"message": "收起侧边栏",
|
||||
"description": "The title attribute for collapse button of doc sidebar"
|
||||
},
|
||||
"theme.docs.sidebar.collapseButtonAriaLabel": {
|
||||
"message": "收起侧边栏",
|
||||
"description": "The title attribute for collapse button of doc sidebar"
|
||||
},
|
||||
"theme.navbar.mobileSidebarSecondaryMenu.backButtonLabel": {
|
||||
"message": "← 回到主菜单",
|
||||
"description": "The label of the back button to return to main menu, inside the mobile navbar sidebar secondary menu (notably used to display the docs sidebar)"
|
||||
},
|
||||
"theme.docs.sidebar.expandButtonTitle": {
|
||||
"message": "展开侧边栏",
|
||||
"description": "The ARIA label and title attribute for expand button of doc sidebar"
|
||||
},
|
||||
"theme.docs.sidebar.expandButtonAriaLabel": {
|
||||
"message": "展开侧边栏",
|
||||
"description": "The ARIA label and title attribute for expand button of doc sidebar"
|
||||
},
|
||||
"Powerful": {
|
||||
"message": "强大",
|
||||
"description": "homepage powerful"
|
||||
},
|
||||
"The cloud services can be easily found and acquired in the application marketplace, offering simplicity and power.": {
|
||||
"message": "通过应用商店来灵活满足各类用户的需求,形成强大的应用生态",
|
||||
"description": "homepage flexible intro"
|
||||
},
|
||||
"Kernel Arch": {
|
||||
"message": "以 kubernetes 为云内核架构"
|
||||
},
|
||||
"Cloud Driver": {
|
||||
"message": "云驱动"
|
||||
},
|
||||
"Cloud Kernel": {
|
||||
"message": "云内核"
|
||||
},
|
||||
"Distributed Applications": {
|
||||
"message": "分布式应用程序"
|
||||
},
|
||||
"Used By": {
|
||||
"message": "客户列表"
|
||||
},
|
||||
"theme.SearchBar.seeAll": {
|
||||
"message": "查看全部 {count} 个结果"
|
||||
},
|
||||
"theme.SearchBar.label": {
|
||||
"message": "搜索",
|
||||
"description": "The ARIA label and placeholder for search button"
|
||||
},
|
||||
"theme.SearchPage.documentsFound.plurals": {
|
||||
"message": "找到 {count} 份文件",
|
||||
"description": "Pluralized label for \"{count} documents found\". Use as much plural forms (separated by \"|\") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)"
|
||||
},
|
||||
"theme.SearchPage.existingResultsTitle": {
|
||||
"message": "「{query}」的搜索结果",
|
||||
"description": "The search page title for non-empty query"
|
||||
},
|
||||
"theme.SearchPage.emptyResultsTitle": {
|
||||
"message": "在文档中搜索",
|
||||
"description": "The search page title for empty query"
|
||||
},
|
||||
"theme.SearchPage.inputPlaceholder": {
|
||||
"message": "在此输入搜索字词",
|
||||
"description": "The placeholder for search page input"
|
||||
},
|
||||
"theme.SearchPage.inputLabel": {
|
||||
"message": "搜索",
|
||||
"description": "The ARIA label for search page input"
|
||||
},
|
||||
"theme.SearchPage.algoliaLabel": {
|
||||
"message": "通过 Algolia 搜索",
|
||||
"description": "The ARIA label for Algolia mention"
|
||||
},
|
||||
"theme.SearchPage.noResultsText": {
|
||||
"message": "未找到任何结果",
|
||||
"description": "The paragraph for empty search result"
|
||||
},
|
||||
"theme.SearchPage.fetchingNewResults": {
|
||||
"message": "正在获取新的搜索结果...",
|
||||
"description": "The paragraph for fetching new search results"
|
||||
},
|
||||
"Docs": {
|
||||
"message": "Doc"
|
||||
},
|
||||
"Contact": {
|
||||
"message": "联系我们"
|
||||
},
|
||||
"theme.admonition.note": {
|
||||
"message": "备注",
|
||||
"description": "The default label used for the Note admonition (:::note)"
|
||||
},
|
||||
"theme.admonition.tip": {
|
||||
"message": "提示",
|
||||
"description": "The default label used for the Tip admonition (:::tip)"
|
||||
},
|
||||
"theme.admonition.danger": {
|
||||
"message": "危险",
|
||||
"description": "The default label used for the Danger admonition (:::danger)"
|
||||
},
|
||||
"theme.admonition.info": {
|
||||
"message": "信息",
|
||||
"description": "The default label used for the Info admonition (:::info)"
|
||||
},
|
||||
"theme.admonition.caution": {
|
||||
"message": "警告",
|
||||
"description": "The default label used for the Caution admonition (:::caution)"
|
||||
},
|
||||
"theme.docs.sidebar.closeSidebarButtonAriaLabel": {
|
||||
"message": "Close navigation bar",
|
||||
"description": "The ARIA label for close button of mobile sidebar"
|
||||
},
|
||||
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": {
|
||||
"message": "Toggle navigation bar",
|
||||
"description": "The ARIA label for hamburger menu button of mobile navigation"
|
||||
},
|
||||
"theme.SearchModal.searchBox.resetButtonTitle": {
|
||||
"message": "清除查询",
|
||||
"description": "The label and ARIA label for search box reset button"
|
||||
},
|
||||
"theme.SearchModal.searchBox.cancelButtonText": {
|
||||
"message": "取消",
|
||||
"description": "The label and ARIA label for search box cancel button"
|
||||
},
|
||||
"theme.SearchModal.startScreen.recentSearchesTitle": {
|
||||
"message": "最近搜索",
|
||||
"description": "The title for recent searches"
|
||||
},
|
||||
"theme.SearchModal.startScreen.noRecentSearchesText": {
|
||||
"message": "没有最近搜索",
|
||||
"description": "The text when no recent searches"
|
||||
},
|
||||
"theme.SearchModal.startScreen.saveRecentSearchButtonTitle": {
|
||||
"message": "保存这个搜索",
|
||||
"description": "The label for save recent search button"
|
||||
},
|
||||
"theme.SearchModal.startScreen.removeRecentSearchButtonTitle": {
|
||||
"message": "从历史记录中删除这个搜索",
|
||||
"description": "The label for remove recent search button"
|
||||
},
|
||||
"theme.SearchModal.startScreen.favoriteSearchesTitle": {
|
||||
"message": "收藏",
|
||||
"description": "The title for favorite searches"
|
||||
},
|
||||
"theme.SearchModal.startScreen.removeFavoriteSearchButtonTitle": {
|
||||
"message": "从收藏列表中删除这个搜索",
|
||||
"description": "The label for remove favorite search button"
|
||||
},
|
||||
"theme.SearchModal.errorScreen.titleText": {
|
||||
"message": "无法获取结果",
|
||||
"description": "The title for error screen of search modal"
|
||||
},
|
||||
"theme.SearchModal.errorScreen.helpText": {
|
||||
"message": "你可能需要检查网络连接。",
|
||||
"description": "The help text for error screen of search modal"
|
||||
},
|
||||
"theme.SearchModal.footer.selectText": {
|
||||
"message": "选中",
|
||||
"description": "The explanatory text of the action for the enter key"
|
||||
},
|
||||
"theme.SearchModal.footer.selectKeyAriaLabel": {
|
||||
"message": "Enter 键",
|
||||
"description": "The ARIA label for the Enter key button that makes the selection"
|
||||
},
|
||||
"theme.SearchModal.footer.navigateText": {
|
||||
"message": "导航",
|
||||
"description": "The explanatory text of the action for the Arrow up and Arrow down key"
|
||||
},
|
||||
"theme.SearchModal.footer.navigateUpKeyAriaLabel": {
|
||||
"message": "向上键",
|
||||
"description": "The ARIA label for the Arrow up key button that makes the navigation"
|
||||
},
|
||||
"theme.SearchModal.footer.navigateDownKeyAriaLabel": {
|
||||
"message": "向下键",
|
||||
"description": "The ARIA label for the Arrow down key button that makes the navigation"
|
||||
},
|
||||
"theme.SearchModal.footer.closeText": {
|
||||
"message": "关闭",
|
||||
"description": "The explanatory text of the action for Escape key"
|
||||
},
|
||||
"theme.SearchModal.footer.closeKeyAriaLabel": {
|
||||
"message": "Esc 键",
|
||||
"description": "The ARIA label for the Escape key button that close the modal"
|
||||
},
|
||||
"theme.SearchModal.footer.searchByText": {
|
||||
"message": "搜索提供",
|
||||
"description": "The text explain that the search is making by Algolia"
|
||||
},
|
||||
"theme.SearchModal.noResultsScreen.noResultsText": {
|
||||
"message": "没有结果:",
|
||||
"description": "The text explains that there are no results for the following search"
|
||||
},
|
||||
"theme.SearchModal.noResultsScreen.suggestedQueryText": {
|
||||
"message": "试试搜索",
|
||||
"description": "The text for the suggested query when no results are found for the following search"
|
||||
},
|
||||
"theme.SearchModal.noResultsScreen.reportMissingResultsText": {
|
||||
"message": "认为这个查询应该有结果?",
|
||||
"description": "The text for the question where the user thinks there are missing results"
|
||||
},
|
||||
"theme.SearchModal.noResultsScreen.reportMissingResultsLinkText": {
|
||||
"message": "请告知我们。",
|
||||
"description": "The text for the link to report missing results"
|
||||
},
|
||||
"theme.SearchModal.placeholder": {
|
||||
"message": "搜索文档",
|
||||
"description": "The placeholder of the input of the DocSearch pop-up modal"
|
||||
},
|
||||
"theme.tags.tagsPageTitle": {
|
||||
"message": "标签",
|
||||
"description": "The title of the tag list page"
|
||||
},
|
||||
"Features": {
|
||||
"message": "特性"
|
||||
},
|
||||
"Copy": {
|
||||
"message": "复制"
|
||||
},
|
||||
"START NOW": {
|
||||
"message": "在线使用"
|
||||
},
|
||||
"CONTACT US NOW": {
|
||||
"message": "联系我们"
|
||||
}
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
{
|
||||
"sidebar.docSidebar.intro": {
|
||||
"message": "介绍"
|
||||
},
|
||||
"sidebar.docSidebar.category.Develop": {
|
||||
"message": "开发"
|
||||
},
|
||||
"sidebar.docSidebar.category.Proxy": {
|
||||
"message": "Proxy 方案"
|
||||
},
|
||||
"sidebar.docSidebar.category.Data Config": {
|
||||
"message": "Config 配置"
|
||||
},
|
||||
"sidebar.docSidebar.category.Deploy": {
|
||||
"message": "部署"
|
||||
},
|
||||
"sidebar.docSidebar.category.Version Updating": {
|
||||
"message": "版本更新"
|
||||
},
|
||||
"sidebar.docSidebar.category.Datasets": {
|
||||
"message": "知识库实践"
|
||||
},
|
||||
"sidebar.docSidebar.category.Flow Modules": {
|
||||
"message": "高级编排"
|
||||
},
|
||||
"sidebar.docSidebar.category.Modules Intro": {
|
||||
"message": "模块介绍"
|
||||
},
|
||||
"sidebar.docSidebar.category.Examples": {
|
||||
"message": "例子"
|
||||
},
|
||||
"sidebar.docSidebar.category.Other": {
|
||||
"message": "其他"
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 240 KiB |
Before Width: | Height: | Size: 328 KiB |
Before Width: | Height: | Size: 294 KiB |
Before Width: | Height: | Size: 302 KiB |
Before Width: | Height: | Size: 150 KiB |
Before Width: | Height: | Size: 86 KiB |
Before Width: | Height: | Size: 101 KiB |
Before Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 77 KiB |
Before Width: | Height: | Size: 80 KiB |
Before Width: | Height: | Size: 101 KiB |
Before Width: | Height: | Size: 165 KiB |
Before Width: | Height: | Size: 335 KiB |
Before Width: | Height: | Size: 137 KiB |
Before Width: | Height: | Size: 115 KiB |
Before Width: | Height: | Size: 193 KiB |
Before Width: | Height: | Size: 307 KiB |
@@ -1,123 +0,0 @@
|
||||
# 利用 FastGpt 打造高质量 AI 知识库
|
||||
|
||||
## 前言
|
||||
|
||||
自从去年 12 月 chatgpt 发布后,带动了新的一轮应用交互革命。尤其是 gpt35 接口全面放开后,LLM 应用雨后春笋般快速涌现,但因为 gpt 的可控性、随机性和合规性等问题,很多应用场景都没法落地。
|
||||
3 月时候,在 twitter 上刷到一个老哥使用 gpt 训练自己的博客记录,并且成本非常低(比起 FT)。他给出了一个完整的流程图:
|
||||
|
||||

|
||||
|
||||
看到这个推文后,我灵机一动,应用场景就十分清晰了。直接上手开干,在经过不到 1 个月时间,FastGpt 在原来多助手管理基础上,加入了向量搜索。于是便有了最早的一期视频:https://www.bilibili.com/video/BV1Wo4y1p7i1/?vd_source=92041a1a395f852f9d89158eaa3f61b4
|
||||
|
||||
3 个月过去了,FastGpt 延续着早期的思路去完善和扩展,目前在向量搜索 + LLM 线性问答方面的功能基本上完成了。不过我们始终没有出一期关于如何构建知识库的教程,趁着 V4 在开发中,我们计划介绍一期《如何在 FastGpt 上构建高质量知识库》,以便大家更好的使用。
|
||||
|
||||
## FastGpt 知识库完整逻辑
|
||||
|
||||
在正式构建知识库前,我们先来了解下 FastGpt 是如何进行知识库检索的。首先了解几个基本概念:
|
||||
|
||||
1. 向量:将人类直观的语言(文字、图片、视频等)转成计算机可识别的语言(数组)。
|
||||
2. 向量相似度:两个向量之间可以进行计算,得到一个相似度,即代表:两个语言相似的程度。
|
||||
3. 语言大模型的一些特点:上下文理解、总结和推理。
|
||||
|
||||
结合上述 3 个概念,便有了 “向量搜索 + 大模型 = 知识库问答” 的公式。下图是 FastGpt V3 中知识库问答功能的完整逻辑:
|
||||
|
||||

|
||||
|
||||
与大部分其他知识库问答产品不一样的是, FastGpt 采用了 QA 问答对进行存储,而不是仅进行 chunk(文本分块)处理。目的是为了减少向量化内容的长度,让向量能更好的表达文本的含义,从而提高搜索精准度。
|
||||
此外 FastGpt 还提供了搜索测试和对话测试两种途径对数据进行调整,从而方便用户调整自己的数据。根据上述流程和方式,我们以构建一个 FastGpt 常见问题机器人为例,展示如何构建一个高质量的 AI 知识库。
|
||||
|
||||
## 构建知识库应用
|
||||
|
||||
首先,先创建一个 FastGpt 常见问题知识库
|
||||
|
||||

|
||||
|
||||
### 通过 QA 拆分,获取基础知识
|
||||
|
||||
我们先直接把 FastGpt Git 上一些已有文档,进行 QA 拆分,从而获取一些 FastGpt 基础的知识。下面是 README 例子。
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
### 修正 QA
|
||||
|
||||
通过 README 我们一共得到了 11 组数据,整体的质量还是不错的,图片和链接都提取出来了。不过最后一个知识点出现了一些截断,我们需要手动的修正一下。
|
||||
|
||||
此外,我们观察到第一列第三个知识点。这个知识点是介绍了 FastGpt 一些资源链接,但是 QA 拆分将答案放置在了 A 中,但通常来说用户的提问并不会直接问“有哪些链接”,通常会问:“部署教程”,“问题文档”之类的。因此,我们需要将这个知识点进行简单的一个处理,如下图:
|
||||
|
||||

|
||||
|
||||
我们先来创建一个应用,看看效果如何。 首先需要去创建一个应用,并且在知识库中关联相关的知识库。另外还需要在配置页的提示词中,告诉 GPT:“知识库的范围”。
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
整体的效果还是不错的,链接和对应的图片都可以顺利的展示。
|
||||
|
||||
### 录入社区常见问题
|
||||
|
||||
接着,我们再把 FastGPT 常见问题的文档导入,由于平时整理不当,我们只能手动的录入对应的问答。
|
||||
|
||||

|
||||
|
||||
导入结果如上图。可以看到,我们均采用的是问答对的格式,而不是粗略的直接导入。目的就是为了模拟用户问题,进一步的提高向量搜索的匹配效果。可以为同一个问题设置多种问法,效果更佳。
|
||||
FastGpt 还提供了 openapi 功能,你可以在本地对特殊格式的文件进行处理后,再上传到 FastGpt,具体可以参考:[FastGpt Api Docs](https://kjqvjse66l.feishu.cn/docx/DmLedTWtUoNGX8xui9ocdUEjnNh)
|
||||
|
||||
## 知识库微调和参数调整
|
||||
|
||||
FastGpt 提供了搜索测试和对话测试两种途径对知识库进行微调,我们先来使用搜索测试对知识库进行调整。我们建议你提前收集一些用户问题进行测试,根据预期效果进行跳转。可以先进行搜索测试调整,判断知识点是否合理。
|
||||
|
||||
### 搜索测试
|
||||
|
||||

|
||||
|
||||
你可能会遇到下面这种情况,由于“知识库”这个关键词导致一些无关内容的相似度也被搜索进去,此时就需要给第四条记录也增加一个“知识库”关键词,从而去提高它的相似度。
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
### 提示词设置
|
||||
|
||||
提示词的作用是引导模型对话的方向。在设置提示词时,遵守 2 个原则:
|
||||
|
||||
1. 告诉 Gpt 回答什么方面内容。
|
||||
2. 给知识库一个基本描述,从而让 Gpt 更好的判断用户的问题是否属于知识库范围。
|
||||
|
||||

|
||||
|
||||
### 更好的限定模型聊天范围
|
||||
|
||||
首先,你可以通过调整知识库搜索时的相似度和最大搜索数量,实现从知识库层面限制聊天范围。通常我们可以设置相似度为 0.82,并设置空搜索回复内容。这意味着,如果用户的问题无法在知识库中匹配时,会直接回复预设的内容。
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
由于 openai 向量模型并不是针对中文,所以当问题中有一些知识库内容的关键词时,相似度
|
||||
会较高,此时无法从知识库层面进行限定。需要通过限定词进行调整,例如:
|
||||
|
||||
> 我的问题如果不是关于 FastGpt 的,请直接回复:“我不确定”。你仅需要回答知识库中的内容,不在其中的内容,不需要回答。
|
||||
|
||||
效果如下:
|
||||
|
||||

|
||||
|
||||
当然,gpt35 在一定情况下依然是不可控的。
|
||||
|
||||
### 通过对话调整知识库
|
||||
|
||||
与搜索测试类似,你可以直接在对话页里,点击“引用”,来随时修改知识库内容。
|
||||
|
||||

|
||||
|
||||
## 总结
|
||||
|
||||
1. 向量搜索是一种可以比较文本相似度的技术。
|
||||
2. 大模型具有总结和推理能力,可以从给定的文本中回答问题。
|
||||
3. 最有效的知识库构建方式是 QA 和手动构建。
|
||||
4. Q 的长度不宜过长。
|
||||
5. 需要调整提示词,来引导模型回答知识库内容。
|
||||
6. 可以通过调整搜索相似度、最大搜索数量和限定词来控制模型回复的范围。
|
@@ -1,67 +0,0 @@
|
||||
# 配置其他对话模型
|
||||
|
||||
默认情况下,FastGPT 只配置了 GPT 的 3 个模型,如果你需要接入其他模型,需要进行一些额外配置。
|
||||
|
||||
## 一、安装 OneAPI
|
||||
|
||||
首先你需要部署一个 [OneAPI](/docs/develop/oneapi),并添加对应的【渠道】
|
||||
|
||||

|
||||
|
||||
## 二、添加 FastGPT 配置
|
||||
|
||||
可以在 /client/src/data/config.json 里找到配置文件(本地开发需要复制成 config.local.json),配置文件中有一项是对话模型配置:
|
||||
|
||||
```json
|
||||
"ChatModels": [
|
||||
{
|
||||
"model": "gpt-3.5-turbo", // 这里的模型需要对应 OneAPI 的模型
|
||||
"name": "FastAI-4k", // 对外展示的名称
|
||||
"contextMaxToken": 4000, // 最大长下文 token,无论什么模型都按 GPT35 的计算。GPT 外的模型需要自行大致计算下这个值。可以调用官方接口去比对 Token 的倍率,然后在这里粗略计算。
|
||||
// 例如:文心一言的中英文 token 基本是 1:1,而 GPT 的中文 Token 是 2:1,如果文心一言官方最大 Token 是 4000,那么这里就可以填 8000,保险点就填 7000.
|
||||
"quoteMaxToken": 2000, // 引用知识库的最大 Token
|
||||
"maxTemperature": 1.2, // 最大温度
|
||||
"price": 1.5, // 1个token 价格 => 1.5 / 100000 * 1000 = 0.015元/1k token
|
||||
"defaultSystem": "" // 默认的系统提示词
|
||||
},
|
||||
{
|
||||
"model": "gpt-3.5-turbo-16k",
|
||||
"name": "FastAI-16k",
|
||||
"contextMaxToken": 16000,
|
||||
"quoteMaxToken": 8000,
|
||||
"maxTemperature": 1.2,
|
||||
"price": 3,
|
||||
"defaultSystem": ""
|
||||
},
|
||||
{
|
||||
"model": "gpt-4",
|
||||
"name": "FastAI-Plus",
|
||||
"contextMaxToken": 8000,
|
||||
"quoteMaxToken": 4000,
|
||||
"maxTemperature": 1.2,
|
||||
"price": 45,
|
||||
"defaultSystem": ""
|
||||
}
|
||||
],
|
||||
```
|
||||
|
||||
### 添加新模型
|
||||
|
||||
以添加文心一言为例:
|
||||
|
||||
```json
|
||||
"ChatModels": [
|
||||
...
|
||||
{
|
||||
"model": "ERNIE-Bot",
|
||||
"name": "文心一言",
|
||||
"contextMaxToken": 4000,
|
||||
"quoteMaxToken": 2000,
|
||||
"maxTemperature": 1,
|
||||
"price": 1.2
|
||||
}
|
||||
...
|
||||
]
|
||||
```
|
||||
|
||||
添加完后,重启应用即可在选择文心一言模型进行对话。
|
@@ -1,72 +0,0 @@
|
||||
---
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
# 默认配置文件
|
||||
|
||||
```json
|
||||
{
|
||||
"FeConfig": {
|
||||
"show_emptyChat": true,
|
||||
"show_register": false,
|
||||
"show_appStore": false,
|
||||
"show_userDetail": false,
|
||||
"show_git": true,
|
||||
"systemTitle": "FastGPT",
|
||||
"authorText": "Made by FastGPT Team.",
|
||||
"gitLoginKey": "",
|
||||
"scripts": []
|
||||
},
|
||||
"SystemParams": {
|
||||
"gitLoginSecret": "",
|
||||
"vectorMaxProcess": 15,
|
||||
"qaMaxProcess": 15,
|
||||
"pgIvfflatProbe": 20
|
||||
},
|
||||
"plugins": {},
|
||||
"ChatModels": [
|
||||
{
|
||||
"model": "gpt-3.5-turbo",
|
||||
"name": "GPT35-4k",
|
||||
"contextMaxToken": 4000,
|
||||
"quoteMaxToken": 2000,
|
||||
"maxTemperature": 1.2,
|
||||
"price": 0,
|
||||
"defaultSystem": ""
|
||||
},
|
||||
{
|
||||
"model": "gpt-3.5-turbo-16k",
|
||||
"name": "GPT35-16k",
|
||||
"contextMaxToken": 16000,
|
||||
"quoteMaxToken": 8000,
|
||||
"maxTemperature": 1.2,
|
||||
"price": 0,
|
||||
"defaultSystem": ""
|
||||
},
|
||||
{
|
||||
"model": "gpt-4",
|
||||
"name": "GPT4-8k",
|
||||
"contextMaxToken": 8000,
|
||||
"quoteMaxToken": 4000,
|
||||
"maxTemperature": 1.2,
|
||||
"price": 0,
|
||||
"defaultSystem": ""
|
||||
}
|
||||
],
|
||||
"QAModels": [
|
||||
{
|
||||
"model": "gpt-3.5-turbo-16k",
|
||||
"name": "GPT35-16k",
|
||||
"maxToken": 16000,
|
||||
"price": 0
|
||||
}
|
||||
],
|
||||
"VectorModels": [
|
||||
{
|
||||
"model": "text-embedding-ada-002",
|
||||
"name": "Embedding-2",
|
||||
"price": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
Before Width: | Height: | Size: 176 KiB |
@@ -1,41 +0,0 @@
|
||||
---
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
# 快速介绍
|
||||
|
||||
由于环境变量不利于配置复杂的内容,新版 FastGPT 采用了 ConfigMap 的形式挂载配置文件,你可以在 client/data/config.json 看到默认的配置文件。可以参考 [docker-compose 部署](/docs/develop/deploy/docker) 来挂载配置文件。
|
||||
|
||||
开发环境下,你需要复制一份 config.json 成 config.local.json 文件才会生效。
|
||||
|
||||
这个配置文件中包含了前端页面定制、系统级参数、AI 对话的模型等……
|
||||
|
||||
**注意:下面的配置介绍仅是局部介绍,你需要完整挂载整个 config.jso ,不能仅挂载一部分。你可以直接在给的 config.json 基础上根据下面的介绍进行修改。**
|
||||
|
||||
## 基础字段粗略说明
|
||||
|
||||
这里会介绍一些基础的配置字段。
|
||||
|
||||
```json
|
||||
// 这个配置会控制前端的一些样式
|
||||
"FeConfig": {
|
||||
"show_emptyChat": true, // 对话页面,空内容时,是否展示介绍页
|
||||
"show_register": false, // 是否展示注册按键(包括忘记密码,注册账号和三方登录)
|
||||
"show_appStore": false, // 是否展示应用市场(不过目前权限还没做好,放开也没用)
|
||||
"show_userDetail": false, // 是否展示用户详情(账号余额、OpenAI 绑定)
|
||||
"show_git": true, // 是否展示 Git
|
||||
"systemTitle": "FastGPT", // 系统的 title
|
||||
"authorText": "Made by FastGPT Team.", // 签名
|
||||
"gitLoginKey": "" // Git 登录凭证
|
||||
}
|
||||
```
|
||||
|
||||
```json
|
||||
// 这个配置文件是系统级参数
|
||||
"SystemParams": {
|
||||
"gitLoginSecret": "", // Git 登录凭证
|
||||
"vectorMaxProcess": 15, // 向量生成最大进程,结合数据库性能和 key 来设置
|
||||
"qaMaxProcess": 15, // QA 生成最大进程,结合数据库性能和 key 来设置
|
||||
"pgIvfflatProbe": 20 // pg vector 搜索探针。没有设置索引前可忽略,通常 50w 组以上才需要设置。
|
||||
},
|
||||
```
|
@@ -1,263 +0,0 @@
|
||||
# docker-compose 快速部署
|
||||
|
||||
## 一、预先准备
|
||||
|
||||
### 1. 准备好代理环境(国外服务器可忽略)
|
||||
|
||||
确保可访问到 OpenAI,方案可参考:[sealos nginx 中转](../proxy/sealos)
|
||||
|
||||
### 2. OneAPI (可选,需要多模型和 key 轮询时使用)
|
||||
|
||||
推荐使用 [one-api](https://github.com/songquanpeng/one-api) 项目来管理 key 池,兼容 openai 、微软和国内主流模型等。
|
||||
|
||||
部署可以看该项目的 [README.md](https://github.com/songquanpeng/one-api),也可以看 [在 Sealos 1 分钟部署 one-api](../oneapi)
|
||||
|
||||
## 二、安装 docker 和 docker-compose
|
||||
|
||||
这个不同系统略有区别,百度安装下。验证安装成功后进行下一步。下面给出 centos 一个例子:
|
||||
|
||||
```bash
|
||||
# 安装docker
|
||||
curl -L https://get.daocloud.io/docker | sh
|
||||
sudo systemctl start docker
|
||||
# 安装 docker-compose
|
||||
curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
|
||||
sudo chmod +x /usr/local/bin/docker-compose
|
||||
# 验证安装
|
||||
docker -v
|
||||
docker-compose -v
|
||||
```
|
||||
|
||||
## 三、创建 docker-compose.yml 文件
|
||||
|
||||
随便找一个目录,创建一个 `docker-compose.yml` 文件,粘贴下面的内容。只需要改 fastgpt 容器的 3 个参数即可启动。
|
||||
|
||||
```yml
|
||||
# 非 host 版本, 不使用本机代理
|
||||
version: '3.3'
|
||||
services:
|
||||
pg:
|
||||
image: ankane/pgvector:v0.4.2 # docker
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector:v0.4.2 # 阿里云
|
||||
container_name: pg
|
||||
restart: always
|
||||
ports: # 生产环境建议不要暴露
|
||||
- 5432:5432
|
||||
networks:
|
||||
- fastgpt
|
||||
environment:
|
||||
# 这里的配置只有首次运行生效。修改后,重启镜像是不会生效的。需要把持久化数据删除再重启,才有效果
|
||||
- POSTGRES_USER=username
|
||||
- POSTGRES_PASSWORD=password
|
||||
- POSTGRES_DB=postgres
|
||||
volumes:
|
||||
- ./pg/data:/var/lib/postgresql/data
|
||||
mongo:
|
||||
image: mongo:5.0.18
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/mongo:5.0.18 # 阿里云
|
||||
container_name: mongo
|
||||
restart: always
|
||||
ports: # 生产环境建议不要暴露
|
||||
- 27017:27017
|
||||
networks:
|
||||
- fastgpt
|
||||
environment:
|
||||
# 这里的配置只有首次运行生效。修改后,重启镜像是不会生效的。需要把持久化数据删除再重启,才有效果
|
||||
- MONGO_INITDB_ROOT_USERNAME=username
|
||||
- MONGO_INITDB_ROOT_PASSWORD=password
|
||||
volumes:
|
||||
- ./mongo/data:/data/db
|
||||
fastgpt:
|
||||
container_name: fastgpt
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:latest # 阿里云
|
||||
image: ghcr.io/labring/fastgpt:latest # github
|
||||
ports:
|
||||
- 3000:3000
|
||||
networks:
|
||||
- fastgpt
|
||||
depends_on:
|
||||
- mongo
|
||||
- pg
|
||||
restart: always
|
||||
environment:
|
||||
# root 密码,用户名为: root
|
||||
- DEFAULT_ROOT_PSW=1234
|
||||
# 中转地址,如果是用官方号,不需要管
|
||||
- OPENAI_BASE_URL=https://api.openai.com/v1
|
||||
- CHAT_API_KEY=sk-xxxx
|
||||
- DB_MAX_LINK=5 # database max link
|
||||
- TOKEN_KEY=any
|
||||
- ROOT_KEY=root_key
|
||||
# mongo 配置,不需要改. 如果连不上,可能需要去掉 ?authSource=admin
|
||||
- MONGODB_URI=mongodb://username:password@mongo:27017/fastgpt?authSource=admin
|
||||
# pg配置. 不需要改
|
||||
- PG_URL=postgresql://username:password@pg:5432/postgres
|
||||
networks:
|
||||
fastgpt:
|
||||
```
|
||||
|
||||
```yml
|
||||
# host 版本, 不推荐。
|
||||
version: '3.3'
|
||||
services:
|
||||
pg:
|
||||
image: ankane/pgvector:v0.4.2 # dockerhub
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector:v0.4.2 # 阿里云
|
||||
container_name: pg
|
||||
restart: always
|
||||
ports: # 生产环境建议不要暴露
|
||||
- 5432:5432
|
||||
environment:
|
||||
# 这里的配置只有首次运行生效。修改后,重启镜像是不会生效的。需要把持久化数据删除再重启,才有效果
|
||||
- POSTGRES_USER=username
|
||||
- POSTGRES_PASSWORD=password
|
||||
- POSTGRES_DB=postgres
|
||||
volumes:
|
||||
- ./pg/data:/var/lib/postgresql/data
|
||||
mongo:
|
||||
image: mongo:5.0.18
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/mongo:5.0.18 # 阿里云
|
||||
container_name: mongo
|
||||
restart: always
|
||||
ports: # 生产环境建议不要暴露
|
||||
- 27017:27017
|
||||
environment:
|
||||
# 这里的配置只有首次运行生效。修改后,重启镜像是不会生效的。需要把持久化数据删除再重启,才有效果
|
||||
- MONGO_INITDB_ROOT_USERNAME=username
|
||||
- MONGO_INITDB_ROOT_PASSWORD=password
|
||||
volumes:
|
||||
- ./mongo/data:/data/db
|
||||
- ./mongo/logs:/var/log/mongodb
|
||||
fastgpt:
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:latest # 阿里云
|
||||
image: ghcr.io/labring/fastgpt:latest # git
|
||||
network_mode: host
|
||||
restart: always
|
||||
container_name: fastgpt
|
||||
environment:
|
||||
# root 密码,用户名为: root
|
||||
- DEFAULT_ROOT_PSW=1234
|
||||
# 中转地址,如果是用官方号,不需要管
|
||||
- OPENAI_BASE_URL=https://api.openai.com/v1
|
||||
- CHAT_API_KEY=sk-xxxx
|
||||
- DB_MAX_LINK=5 # database max link
|
||||
# token加密凭证(随便填,作为登录凭证)
|
||||
- TOKEN_KEY=any
|
||||
# root key, 最高权限,可以内部接口互相调用
|
||||
- ROOT_KEY=root_key
|
||||
# mongo 配置,不需要改. 如果连不上,可能需要去掉 ?authSource=admin
|
||||
- MONGODB_URI=mongodb://username:password@0.0.0.0:27017/fastgpt?authSource=admin
|
||||
# pg配置. 不需要改
|
||||
- PG_URL=postgresql://username:password@0.0.0.0:5432/postgres
|
||||
```
|
||||
|
||||
## 四、运行 docker-compose
|
||||
|
||||
```bash
|
||||
# 在 docker-compose.yml 同级目录下执行
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
## 五、访问
|
||||
|
||||
如果需要域名访问,自行安装 Nginx。目前可以通过: `ip:3000` 直接访问(注意防火墙)。登录用户名为 root,密码为刚刚环境变量里设置的 `DEFAULT_ROOT_PSW`
|
||||
|
||||
## 一些问题
|
||||
|
||||
### 1. 如何更新?
|
||||
|
||||
执行 `docker-compose up -d` 会自动拉取最新镜像,一般情况下不需要执行额外操作。
|
||||
|
||||
### 2. 挂载配置文件
|
||||
|
||||
在和 `docker-compose.yml` 同级目录,创建一个 `config.json` 文件,内容如下:
|
||||
|
||||
```json
|
||||
{
|
||||
"FeConfig": {
|
||||
"show_emptyChat": true,
|
||||
"show_register": false,
|
||||
"show_appStore": false,
|
||||
"show_userDetail": false,
|
||||
"show_git": true,
|
||||
"systemTitle": "FastGPT",
|
||||
"authorText": "Made by FastGPT Team.",
|
||||
"gitLoginKey": "",
|
||||
"scripts": []
|
||||
},
|
||||
"SystemParams": {
|
||||
"gitLoginSecret": "",
|
||||
"vectorMaxProcess": 15,
|
||||
"qaMaxProcess": 15,
|
||||
"pgIvfflatProbe": 20
|
||||
},
|
||||
"plugins": {},
|
||||
"ChatModels": [
|
||||
{
|
||||
"model": "gpt-3.5-turbo",
|
||||
"name": "GPT35-4k",
|
||||
"contextMaxToken": 4000,
|
||||
"quoteMaxToken": 2000,
|
||||
"maxTemperature": 1.2,
|
||||
"price": 0,
|
||||
"defaultSystem": ""
|
||||
},
|
||||
{
|
||||
"model": "gpt-3.5-turbo-16k",
|
||||
"name": "GPT35-16k",
|
||||
"contextMaxToken": 16000,
|
||||
"quoteMaxToken": 8000,
|
||||
"maxTemperature": 1.2,
|
||||
"price": 0,
|
||||
"defaultSystem": ""
|
||||
},
|
||||
{
|
||||
"model": "gpt-4",
|
||||
"name": "GPT4-8k",
|
||||
"contextMaxToken": 8000,
|
||||
"quoteMaxToken": 4000,
|
||||
"maxTemperature": 1.2,
|
||||
"price": 0,
|
||||
"defaultSystem": ""
|
||||
}
|
||||
],
|
||||
"QAModels": [
|
||||
{
|
||||
"model": "gpt-3.5-turbo-16k",
|
||||
"name": "GPT35-16k",
|
||||
"maxToken": 16000,
|
||||
"price": 0
|
||||
}
|
||||
],
|
||||
"VectorModels": [
|
||||
{
|
||||
"model": "text-embedding-ada-002",
|
||||
"name": "Embedding-2",
|
||||
"price": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
修改 docker-compose.yml 中 fastgpt 容器内容,增加挂载。具体配置可参考 [config 配置说明](/docs/category/data-config)
|
||||
|
||||
```yml
|
||||
fastgpt:
|
||||
container_name: fastgpt
|
||||
image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:latest # 阿里云
|
||||
ports:
|
||||
- 3000:3000
|
||||
networks:
|
||||
- fastgpt
|
||||
depends_on:
|
||||
- mongo
|
||||
- pg
|
||||
restart: always
|
||||
environment:
|
||||
......
|
||||
# root 密码,用户名为: root
|
||||
- DEFAULT_ROOT_PSW=1234
|
||||
......
|
||||
volumes:
|
||||
- ./config.json:/app/data/config.json
|
||||
```
|
Before Width: | Height: | Size: 257 KiB |
Before Width: | Height: | Size: 258 KiB |
@@ -1,101 +0,0 @@
|
||||
# Mac 上部署可能遇到的问题(旧版)
|
||||
|
||||
### 前置条件
|
||||
|
||||
1、可以 curl api.openai.com
|
||||
|
||||
2、有 openai key
|
||||
|
||||
3、有邮箱 MAILE_CODE
|
||||
|
||||
4、有 docker
|
||||
|
||||
```
|
||||
docker -v
|
||||
```
|
||||
|
||||
5、有 pnpm ,可以使用`brew install pnpm`安装
|
||||
|
||||
6、需要创建一个放置 pg 和 mongo 数据的文件夹,这里创建在`~/fastgpt`目录中,里面有`pg` 和`mongo `两个文件夹
|
||||
|
||||
```
|
||||
➜ fastgpt pwd
|
||||
/Users/jie/fastgpt
|
||||
➜ fastgpt ls
|
||||
mongo pg
|
||||
```
|
||||
|
||||
### docker 部署方式
|
||||
|
||||
这种方式主要是为了方便调试,可以使用`pnpm dev ` 运行 fastgpt 项目
|
||||
|
||||
**1、.env.local 文件**
|
||||
|
||||
```
|
||||
# proxy
|
||||
AXIOS_PROXY_HOST=127.0.0.1
|
||||
AXIOS_PROXY_PORT_FAST=7890
|
||||
AXIOS_PROXY_PORT_NORMAL=7890
|
||||
# email
|
||||
MY_MAIL= {Your Mail}
|
||||
MAILE_CODE={Yoir Mail code}
|
||||
# ali ems
|
||||
aliAccessKeyId=xxx
|
||||
aliAccessKeySecret=xxx
|
||||
aliSignName=xxx
|
||||
aliTemplateCode=SMS_xxx
|
||||
# token
|
||||
TOKEN_KEY=sswada
|
||||
# 使用 oneapi
|
||||
ONEAPI_URL=[https://api.xyz.com/v1](https://xxxxx.cloud.sealos.io/v1)
|
||||
ONEAPI_KEY=sk-xxxxxx
|
||||
# openai
|
||||
OPENAIKEY=sk-xxx # 对话用的key
|
||||
OPENAI_TRAINING_KEY=sk-xxx # 训练用的key
|
||||
# db
|
||||
MONGODB_URI=mongodb://username:password@0.0.0.0:27017/test?authSource=admin
|
||||
PG_HOST=0.0.0.0
|
||||
PG_PORT=8100
|
||||
PG_USER=xxx
|
||||
PG_PASSWORD=xxx
|
||||
PG_DB_NAME=fastgpt
|
||||
```
|
||||
|
||||
**2、部署 mongo**
|
||||
|
||||
```
|
||||
docker run --name mongo -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=username -e MONGO_INITDB_ROOT_PASSWORD=password -v ~/fastgpt/mongo/data:/data/db -d mongo:4.0.1
|
||||
```
|
||||
|
||||
**3、部署 pgsql**
|
||||
|
||||
```
|
||||
docker run -it --name pg -e "POSTGRES_DB=fastgpt" -e "POSTGRES_PASSWORD=xxx" -e POSTGRES_USER=xxx -p 8100:5432 -v ~/fastgpt/pg/data:/var/lib/postgresql/data -d octoberlan/pgvector:v0.4.1
|
||||
```
|
||||
|
||||
进 pgsql 容器运行
|
||||
|
||||
```
|
||||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
|
||||
|
||||
CREATE EXTENSION IF NOT EXISTS vector;
|
||||
-- init table
|
||||
CREATE TABLE IF NOT EXISTS modeldata (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
vector VECTOR(1536) NOT NULL,
|
||||
user_id VARCHAR(50) NOT NULL,
|
||||
kb_id VARCHAR(50) NOT NULL,
|
||||
source VARCHAR(100),
|
||||
q TEXT NOT NULL,
|
||||
a TEXT NOT NULL
|
||||
);
|
||||
-- 索引设置,按需取
|
||||
-- CREATE INDEX IF NOT EXISTS modeldata_userId_index ON modeldata USING HASH (user_id);
|
||||
-- CREATE INDEX IF NOT EXISTS modeldata_kbId_index ON modeldata USING HASH (kb_id);
|
||||
-- CREATE INDEX IF NOT EXISTS idx_model_data_md5_q_a_user_id_kb_id ON modeldata (md5(q), md5(a), user_id, kb_id);
|
||||
-- CREATE INDEX modeldata_id_desc_idx ON modeldata (id DESC);
|
||||
-- vector 索引,可以参考 [pg vector](https://github.com/pgvector/pgvector) 去配置,根据数据量去配置
|
||||
EOSQL
|
||||
```
|
||||
|
||||
4、**最后在 FASTGPT 项目里面运行 pnpm dev 运行项目,然后进入 localhost:3000 看项目是否跑起来了**
|
@@ -1,19 +0,0 @@
|
||||
---
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
# Sealos 一键部署
|
||||
|
||||
无需服务器、无需魔法、无需域名,点击即可部署 👇
|
||||
|
||||
[](https://cloud.sealos.io/?openapp=system-fastdeploy%3FtemplateName%3Dfastgpt)
|
||||
|
||||
由于需要部署数据库,部署完后需要等待 2~4 分钟才能正常访问。默认用了最低配置,首次访问时会有些慢。
|
||||
|
||||

|
||||
|
||||
## 运行
|
||||
|
||||
点击 sealos 提供的【外网地址】即可使用。登录用户名为: root,密码是刚设置的环境变量,上图中设置了: 1234
|
||||
|
||||

|
@@ -1,37 +0,0 @@
|
||||
# 本地开发
|
||||
|
||||
第一次开发,需要先部署数据库,建议本地开发可以随便找一台 2c2g 的轻量小数据库实践。数据库部署教程:[Docker 快速部署](/docs/develop/deploy/docker)
|
||||
|
||||
client 目录下为 FastGPT 核心代码。NextJS 框架前后端在一起的,api 服务位于 src/pages/api 内。
|
||||
|
||||
## 初始配置
|
||||
|
||||
**1. 环境变量**
|
||||
|
||||
复制.env.template 文件,生成一个.env.local 环境变量文件夹,修改.env.local 里内容才是有效的变量。变量说明见 .env.template
|
||||
|
||||
**2. config 配置文件**
|
||||
|
||||
复制 data/config.json 文件,生成一个 data/config.local.json 配置文件。
|
||||
|
||||
这个文件大部分时候不需要修改。只需要关注 SystemParams 里的参数:
|
||||
|
||||
```
|
||||
"vectorMaxProcess": 向量生成最大进程,根据数据库和 key 的并发数来决定,通常单个 120 号,2c4g 服务器设置10~15。
|
||||
"qaMaxProcess": QA 生成最大进程
|
||||
"pgIvfflatProbe": PG vector 搜索探针,没有添加 vector 索引时可忽略。
|
||||
```
|
||||
|
||||
## 运行
|
||||
|
||||
```
|
||||
cd client
|
||||
pnpm i
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
## 镜像打包
|
||||
|
||||
```bash
|
||||
docker build -t dockername/fastgpt .
|
||||
```
|
Before Width: | Height: | Size: 6.0 MiB |
Before Width: | Height: | Size: 208 KiB |
Before Width: | Height: | Size: 215 KiB |
Before Width: | Height: | Size: 247 KiB |
Before Width: | Height: | Size: 128 KiB |
@@ -1,50 +0,0 @@
|
||||
# 部署 OneAPI,实现多模型
|
||||
|
||||
无需魔法,部署即可使用
|
||||
|
||||
## SqlLite 版本
|
||||
|
||||
sqllite 版本适合个人,少并发
|
||||
|
||||
## 一、[点击打开 Sealos 公有云](https://cloud.sealos.io/)
|
||||
|
||||
## 二、打开 AppLaunchpad(应用管理) 工具
|
||||
|
||||

|
||||
|
||||
## 三、点击创建新应用
|
||||
|
||||
## 四、填写对应参数
|
||||
|
||||
镜像:ghcr.io/songquanpeng/one-api:latest
|
||||
|
||||

|
||||
打开外网访问开关后,Sealos 会自动分配一个可访问的地址,不需要自己配置。
|
||||
|
||||

|
||||
填写完参数后,点击右上角部署即可。
|
||||
|
||||
## 5. 访问
|
||||
|
||||
点击 Sealos 提供的外网访问地址,即可访问 OneAPI 项目。
|
||||

|
||||

|
||||
|
||||
## 6. 替换 FastGpt 的环境变量
|
||||
|
||||
```
|
||||
# 下面的地址是 Sealos 提供的,务必写上 v1
|
||||
OPENAI_BASE_URL=https://xxxx.cloud.sealos.io/v1
|
||||
# 下面的 key 由 one-api 提供
|
||||
CHAT_API_KEY=sk-xxxxxx
|
||||
```
|
||||
|
||||
## MySQL 版本
|
||||
|
||||
高流量推荐使用 MySQL 版本,支持多实例扩展。
|
||||
|
||||
点击下方按键一键部署 👇
|
||||
|
||||
[](https://cloud.sealos.io/?openapp=system-fastdeploy%3FtemplateName%3Done-api)
|
||||
|
||||
部署完后会跳转【应用管理】,数据库在另一个应用里。需要等待 1~3 分钟数据库运行后才能访问成功。
|
@@ -1,68 +0,0 @@
|
||||
# 安装 clash
|
||||
|
||||
clash 会在本机启动代理。对应的,你需要配置项目的两个环境变量:
|
||||
|
||||
```
|
||||
AXIOS_PROXY_HOST=127.0.0.1
|
||||
AXIOS_PROXY_PORT=7890
|
||||
```
|
||||
|
||||
需要注的是,在你的 config.yaml 文件中,最好仅指定 api.openai.com 走代理,其他请求都直连。
|
||||
|
||||
**安装clash**
|
||||
```bash
|
||||
# 下载包
|
||||
curl https://glados.rocks/tools/clash-linux.zip -o clash.zip
|
||||
# 解压
|
||||
unzip clash.zip
|
||||
# 下载终端配置⽂件(改成自己配置文件路径)
|
||||
curl https://update.glados-config.com/clash/98980/8f30944/70870/glados-terminal.yaml > config.yaml
|
||||
# 赋予运行权限
|
||||
chmod +x ./clash-linux-amd64-v1.10.0
|
||||
```
|
||||
|
||||
**runClash.sh**
|
||||
```sh
|
||||
# 记得配置端口变量:
|
||||
export ALL_PROXY=socks5://127.0.0.1:7891
|
||||
export http_proxy=http://127.0.0.1:7890
|
||||
export https_proxy=http://127.0.0.1:7890
|
||||
export HTTP_PROXY=http://127.0.0.1:7890
|
||||
export HTTPS_PROXY=http://127.0.0.1:7890
|
||||
|
||||
# 运行脚本: 删除clash - 到 clash 目录 - 删除缓存 - 执行运行. 会生成一个 nohup.out 文件,可以看到 clash 的 logs
|
||||
OLD_PROCESS=$(pgrep clash)
|
||||
if [ ! -z "$OLD_PROCESS" ]; then
|
||||
echo "Killing old process: $OLD_PROCESS"
|
||||
kill $OLD_PROCESS
|
||||
fi
|
||||
sleep 2
|
||||
cd **/clash
|
||||
rm -f ./nohup.out || true
|
||||
rm -f ./cache.db || true
|
||||
nohup ./clash-linux-amd64-v1.10.0 -d ./ &
|
||||
echo "Restart clash"
|
||||
```
|
||||
|
||||
**config.yaml配置例子**
|
||||
```yaml
|
||||
mixed-port: 7890
|
||||
allow-lan: false
|
||||
bind-address: '*'
|
||||
mode: rule
|
||||
log-level: warning
|
||||
dns:
|
||||
enable: true
|
||||
ipv6: false
|
||||
nameserver:
|
||||
- 8.8.8.8
|
||||
- 8.8.4.4
|
||||
cache-size: 400
|
||||
proxies:
|
||||
-
|
||||
proxy-groups:
|
||||
- { name: '♻️ 自动选择', type: url-test, proxies: [香港V01×1.5], url: 'https://api.openai.com', interval: 3600}
|
||||
rules:
|
||||
- 'DOMAIN-SUFFIX,api.openai.com,♻️ 自动选择'
|
||||
- 'MATCH,DIRECT'
|
||||
```
|
@@ -1,46 +0,0 @@
|
||||
# cloudflare 代理配置
|
||||
|
||||
[来自 "不做了睡觉" 教程](https://gravel-twister-d32.notion.site/FastGPT-API-ba7bb261d5fd4fd9bbb2f0607dacdc9e)
|
||||
|
||||
**workers 配置文件**
|
||||
|
||||
```js
|
||||
const TELEGRAPH_URL = 'https://api.openai.com';
|
||||
|
||||
addEventListener('fetch', (event) => {
|
||||
event.respondWith(handleRequest(event.request));
|
||||
});
|
||||
|
||||
async function handleRequest(request) {
|
||||
// 安全校验
|
||||
if (request.headers.get('auth') !== 'auth_code') {
|
||||
return new Response('UnAuthorization', { status: 403 });
|
||||
}
|
||||
|
||||
const url = new URL(request.url);
|
||||
url.host = TELEGRAPH_URL.replace(/^https?:\/\//, '');
|
||||
|
||||
const modifiedRequest = new Request(url.toString(), {
|
||||
headers: request.headers,
|
||||
method: request.method,
|
||||
body: request.body,
|
||||
redirect: 'follow'
|
||||
});
|
||||
|
||||
const response = await fetch(modifiedRequest);
|
||||
const modifiedResponse = new Response(response.body, response);
|
||||
|
||||
// 添加允许跨域访问的响应头
|
||||
modifiedResponse.headers.set('Access-Control-Allow-Origin', '*');
|
||||
|
||||
return modifiedResponse;
|
||||
}
|
||||
```
|
||||
|
||||
**对应的环境变量**
|
||||
务必别忘了填 v1
|
||||
|
||||
```
|
||||
OPENAI_BASE_URL=https://xxxxxx/v1
|
||||
OPENAI_BASE_URL_AUTH=auth_code
|
||||
```
|
Before Width: | Height: | Size: 7.5 MiB |
Before Width: | Height: | Size: 205 KiB |
Before Width: | Height: | Size: 152 KiB |
Before Width: | Height: | Size: 88 KiB |
Before Width: | Height: | Size: 224 KiB |
@@ -1,60 +0,0 @@
|
||||
# nginx 反向代理 openai 接口
|
||||
|
||||
如果你有国外的服务器,可以通过配置 nginx 反向代理,转发 openai 相关的请求,从而让国内的服务器可以通过访问该 nginx 去访问 openai 接口。
|
||||
|
||||
```conf
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
worker_rlimit_nofile 51200;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
resolver 8.8.8.8;
|
||||
proxy_ssl_server_name on;
|
||||
|
||||
access_log off;
|
||||
server_names_hash_bucket_size 512;
|
||||
client_header_buffer_size 32k;
|
||||
large_client_header_buffers 4 32k;
|
||||
client_max_body_size 50M;
|
||||
|
||||
gzip on;
|
||||
gzip_min_length 1k;
|
||||
gzip_buffers 4 8k;
|
||||
gzip_http_version 1.1;
|
||||
gzip_comp_level 6;
|
||||
gzip_vary on;
|
||||
gzip_types text/plain application/x-javascript text/css application/javascript application/json application/xml;
|
||||
gzip_disable "MSIE [1-6]\.";
|
||||
|
||||
open_file_cache max=1000 inactive=1d;
|
||||
open_file_cache_valid 30s;
|
||||
open_file_cache_min_uses 8;
|
||||
open_file_cache_errors off;
|
||||
|
||||
server {
|
||||
listen 3999;
|
||||
server_name 你的 ip 地址;
|
||||
|
||||
location ~ /openai/(.*) {
|
||||
proxy_pass https://api.openai.com/$1$is_args$args;
|
||||
proxy_set_header Host api.openai.com;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
# 流式响应
|
||||
proxy_set_header Connection '';
|
||||
proxy_http_version 1.1;
|
||||
chunked_transfer_encoding off;
|
||||
proxy_buffering off;
|
||||
proxy_cache off;
|
||||
# 一般响应
|
||||
proxy_buffer_size 128k;
|
||||
proxy_buffers 4 256k;
|
||||
proxy_busy_buffers_size 256k;
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
@@ -1,102 +0,0 @@
|
||||
---
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
# sealos 部署 nginx 实现中转
|
||||
|
||||
## 登录 sealos cloud
|
||||
|
||||
[sealos cloud](https://cloud.sealos.io/)
|
||||
|
||||
## 一、点击创建应用
|
||||
|
||||
打开 App Launchpad -> 新建应用
|
||||
|
||||

|
||||

|
||||
|
||||
### 二、填写基本配置
|
||||
|
||||
务必开启外网访问,复制下外网访问提供的地址。
|
||||
|
||||

|
||||
|
||||
### 三、添加 configmap 文件
|
||||
|
||||
1. 复制下面这段配置文件,注意 `server_name` 后面的内容替换成第二步的外网访问地址。
|
||||
|
||||
```
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
worker_rlimit_nofile 51200;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
resolver 8.8.8.8;
|
||||
proxy_ssl_server_name on;
|
||||
|
||||
access_log off;
|
||||
server_names_hash_bucket_size 512;
|
||||
client_header_buffer_size 64k;
|
||||
large_client_header_buffers 4 64k;
|
||||
client_max_body_size 50M;
|
||||
|
||||
proxy_connect_timeout 240s;
|
||||
proxy_read_timeout 240s;
|
||||
proxy_buffer_size 128k;
|
||||
proxy_buffers 4 256k;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name tgohwtdlrmer.cloud.sealos.io; # 这个地方替换成 sealos 提供的内容
|
||||
|
||||
location ~ /openai/(.*) {
|
||||
proxy_pass https://api.openai.com/$1$is_args$args;
|
||||
proxy_set_header Host api.openai.com;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
# 如果响应是流式的
|
||||
proxy_set_header Connection '';
|
||||
proxy_http_version 1.1;
|
||||
chunked_transfer_encoding off;
|
||||
proxy_buffering off;
|
||||
proxy_cache off;
|
||||
# 如果响应是一般的
|
||||
proxy_buffer_size 128k;
|
||||
proxy_buffers 4 256k;
|
||||
proxy_busy_buffers_size 256k;
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
2. 点开高级配置
|
||||
3. 点击新增 configmap
|
||||
4. 文件名写: `/etc/nginx/nginx.conf`
|
||||
5. 文件值为刚刚复制的那段代码
|
||||
6. 点击确认
|
||||
|
||||

|
||||
|
||||
### 四、部署应用
|
||||
|
||||
填写完毕后,点击右上角的 `部署应用`,即可完成。
|
||||
|
||||
## 五、修改 FastGpt 环境变量
|
||||
|
||||
1. 进入刚刚部署应用的详情,复制外网地址
|
||||
|
||||
注意:这是个 API 地址,点击打开是无效的。如需验证,可以访问: 【\*\*\*.close.sealos.io/openai/api】,如果提示 "Invalid URL (GET /api)" 则代表成功。
|
||||
|
||||

|
||||
|
||||
2. 修改环境变量(是 FastGpt 的环境变量,不是 sealos 的):
|
||||
|
||||
```
|
||||
OPENAI_BASE_URL=https://tgohwtdlrmer.cloud.sealos.io/openai/v1
|
||||
```
|
||||
|
||||
**Done!**
|
@@ -1,56 +0,0 @@
|
||||
# V4.0 版本初始化
|
||||
|
||||
新版 mongo 表进行了不少的变更,需要执行一些初始化脚本。
|
||||
|
||||
## 重命名表名
|
||||
|
||||
需要连接上 mongo 数据库,执行两条命令:
|
||||
|
||||
`db.models.renameCollection("apps")`
|
||||
|
||||
`db.sharechats.renameCollection("outlinks")`
|
||||
|
||||
如果你已经更新部署了,mongo 会自动创建空表,需要手动删除这两个空表。
|
||||
|
||||
## 初始化几个表中的字段
|
||||
|
||||
依次执行下面 3 条命令,时间比较长,不成功可以重复执行(会跳过已经初始化的数据),直到所有数据更新完成。
|
||||
|
||||
```mongo
|
||||
db.chats.find({appId: {$exists: false}}).forEach(function(item){
|
||||
db.chats.updateOne(
|
||||
{
|
||||
_id: item._id,
|
||||
},
|
||||
{ "$set": {"appId":item.modelId}}
|
||||
)
|
||||
})
|
||||
|
||||
db.collections.find({appId: {$exists: false}}).forEach(function(item){
|
||||
db.collections.updateOne(
|
||||
{
|
||||
_id: item._id,
|
||||
},
|
||||
{ "$set": {"appId":item.modelId}}
|
||||
)
|
||||
})
|
||||
|
||||
db.outlinks.find({shareId: {$exists: false}}).forEach(function(item){
|
||||
db.outlinks.updateOne(
|
||||
{
|
||||
_id: item._id,
|
||||
},
|
||||
{ "$set": {"shareId":item._id.toString(),"appId":item.modelId}}
|
||||
)
|
||||
})
|
||||
```
|
||||
|
||||
## 执行初始化 API
|
||||
|
||||
部署新版项目,并发起 3 个 HTTP 请求(记得携带 headers.rootkey,这个值是环境变量里的)
|
||||
|
||||
1. https://xxxxx/api/admin/initv4
|
||||
2. https://xxxxx/api/admin/initChat
|
||||
3. https://xxxxx/api/admin/initOutlink
|
||||
|
||||
1 和 2,有可能会因为内存不足挂掉,可以重复执行。
|
@@ -1,20 +0,0 @@
|
||||
# V4.1 版本初始化
|
||||
|
||||
新版重新设置了对话存储结构,需要初始化原来的存储内容
|
||||
|
||||
## 更新环境变量
|
||||
|
||||
优化了 PG 和 Mongo 的连接变量,只需要 1 个 url 即可。
|
||||
|
||||
```
|
||||
# mongo 配置,不需要改. 如果连不上,可能需要去掉 ?authSource=admin
|
||||
- MONGODB_URI=mongodb://username:password@mongo:27017/fastgpt?authSource=admin
|
||||
# pg配置. 不需要改
|
||||
- PG_URL=postgresql://username:password@pg:5432/postgres
|
||||
```
|
||||
|
||||
## 执行初始化 API
|
||||
|
||||
部署新版项目,并发起 1 个 HTTP 请求(记得携带 headers.rootkey,这个值是环境变量里的)
|
||||
|
||||
https://xxxxx/api/admin/initChatItem
|
Before Width: | Height: | Size: 336 KiB |
Before Width: | Height: | Size: 280 KiB |
@@ -1 +0,0 @@
|
||||
# 实验室助手
|
@@ -1,449 +0,0 @@
|
||||
# 谷歌搜索
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
如上图,利用 HTTP 模块,你可以轻松的外接一个搜索引擎。这里以调用 google search api 为例。
|
||||
|
||||
## 注册 google search api
|
||||
|
||||
[参考这篇文章,注册 google search api](https://zhuanlan.zhihu.com/p/174666017)
|
||||
|
||||
## 写一个 google search 接口
|
||||
|
||||
[这里用 laf 快速实现一个接口,即写即发布,无需部署。点击打开 laf cloud](https://laf.dev/),务必打开 POST 请求方式。
|
||||
|
||||
```ts
|
||||
import cloud from '@lafjs/cloud';
|
||||
|
||||
const googleSearchKey = '';
|
||||
const googleCxId = '';
|
||||
const baseurl = 'https://www.googleapis.com/customsearch/v1';
|
||||
|
||||
export default async function (ctx: FunctionContext) {
|
||||
const { searchKey } = ctx.body;
|
||||
|
||||
if (!searchKey) {
|
||||
return {
|
||||
prompt: ''
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const { data } = await cloud.fetch.get(baseurl, {
|
||||
params: {
|
||||
q: searchKey,
|
||||
cx: googleCxId,
|
||||
key: googleSearchKey,
|
||||
c2coff: 1,
|
||||
start: 1,
|
||||
end: 5,
|
||||
dateRestrict: 'm[1]'
|
||||
}
|
||||
});
|
||||
const result = data.items.map((item) => item.snippet).join('\n');
|
||||
return { prompt: `搜索词: ${searchKey};google 搜索结果: ${result}` };
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
return {
|
||||
prompt: ''
|
||||
};
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 模块编排
|
||||
|
||||
复制下面配置,点击高级编排右上角的导入按键,导入该配置,导入后将接口地址复制到 【HTTP 模块】。
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"moduleId": "userChatInput",
|
||||
"name": "用户问题(对话入口)",
|
||||
"flowType": "questionInput",
|
||||
"position": {
|
||||
"x": 464.32198615344566,
|
||||
"y": 1602.2698463081606
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"key": "userChatInput",
|
||||
"type": "systemInput",
|
||||
"label": "用户问题",
|
||||
"connected": true
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"key": "userChatInput",
|
||||
"label": "用户问题",
|
||||
"type": "source",
|
||||
"valueType": "string",
|
||||
"targets": [
|
||||
{
|
||||
"moduleId": "6g2075",
|
||||
"key": "content"
|
||||
},
|
||||
{
|
||||
"moduleId": "aijmbb",
|
||||
"key": "userChatInput"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"moduleId": "history",
|
||||
"name": "聊天记录",
|
||||
"flowType": "historyNode",
|
||||
"position": {
|
||||
"x": 452.5466249541586,
|
||||
"y": 1276.3930310334215
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"key": "maxContext",
|
||||
"type": "numberInput",
|
||||
"label": "最长记录数",
|
||||
"value": 6,
|
||||
"min": 0,
|
||||
"max": 50,
|
||||
"connected": true
|
||||
},
|
||||
{
|
||||
"key": "history",
|
||||
"type": "hidden",
|
||||
"label": "聊天记录",
|
||||
"connected": true
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"key": "history",
|
||||
"label": "聊天记录",
|
||||
"valueType": "chat_history",
|
||||
"type": "source",
|
||||
"targets": [
|
||||
{
|
||||
"moduleId": "6g2075",
|
||||
"key": "history"
|
||||
},
|
||||
{
|
||||
"moduleId": "aijmbb",
|
||||
"key": "history"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"moduleId": "6g2075",
|
||||
"name": "文本内容提取",
|
||||
"flowType": "contentExtract",
|
||||
"showStatus": true,
|
||||
"position": {
|
||||
"x": 971.5119545668634,
|
||||
"y": 1118.186021718385
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"key": "switch",
|
||||
"type": "target",
|
||||
"label": "触发器",
|
||||
"valueType": "any",
|
||||
"connected": false
|
||||
},
|
||||
{
|
||||
"key": "description",
|
||||
"type": "textarea",
|
||||
"valueType": "string",
|
||||
"label": "提取要求描述",
|
||||
"description": "写一段提取要求,告诉 AI 需要提取哪些内容",
|
||||
"required": true,
|
||||
"placeholder": "例如: \n1. 你是一个实验室预约助手。根据用户问题,提取出姓名、实验室号和预约时间",
|
||||
"value": "你是谷歌搜索机器人,可以生成搜索词。你需要自行判断是否需要生成搜索词,如果不需要则返回空字符串。",
|
||||
"connected": true
|
||||
},
|
||||
{
|
||||
"key": "history",
|
||||
"type": "target",
|
||||
"label": "聊天记录",
|
||||
"valueType": "chat_history",
|
||||
"connected": true
|
||||
},
|
||||
{
|
||||
"key": "content",
|
||||
"type": "target",
|
||||
"label": "需要提取的文本",
|
||||
"required": true,
|
||||
"valueType": "string",
|
||||
"connected": true
|
||||
},
|
||||
{
|
||||
"key": "extractKeys",
|
||||
"type": "custom",
|
||||
"label": "目标字段",
|
||||
"description": "由 '描述' 和 'key' 组成一个目标字段,可提取多个目标字段",
|
||||
"value": [
|
||||
{
|
||||
"desc": "搜索词",
|
||||
"key": "searchKey",
|
||||
"required": false
|
||||
}
|
||||
],
|
||||
"connected": true
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"key": "success",
|
||||
"label": "字段完全提取",
|
||||
"valueType": "boolean",
|
||||
"type": "source",
|
||||
"targets": []
|
||||
},
|
||||
{
|
||||
"key": "failed",
|
||||
"label": "提取字段缺失",
|
||||
"valueType": "boolean",
|
||||
"type": "source",
|
||||
"targets": [
|
||||
{
|
||||
"moduleId": "aijmbb",
|
||||
"key": "switch"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "fields",
|
||||
"label": "完整提取结果",
|
||||
"description": "一个 JSON 字符串,例如:{\"name:\":\"YY\",\"Time\":\"2023/7/2 18:00\"}",
|
||||
"valueType": "string",
|
||||
"type": "source",
|
||||
"targets": []
|
||||
},
|
||||
{
|
||||
"key": "searchKey",
|
||||
"label": "提取结果-搜索词",
|
||||
"description": "无法提取时不会返回",
|
||||
"valueType": "string",
|
||||
"type": "source",
|
||||
"targets": [
|
||||
{
|
||||
"moduleId": "5fk9ru",
|
||||
"key": "searchKey"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"moduleId": "5fk9ru",
|
||||
"name": "HTTP模块",
|
||||
"flowType": "httpRequest",
|
||||
"showStatus": true,
|
||||
"position": {
|
||||
"x": 1481.5339897373183,
|
||||
"y": 1290.2958964143072
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"key": "url",
|
||||
"value": "https://d8dns0.laf.dev/google_web_search",
|
||||
"type": "input",
|
||||
"label": "请求地址",
|
||||
"description": "请求目标地址",
|
||||
"placeholder": "https://api.fastgpt.run/getInventory",
|
||||
"required": true,
|
||||
"connected": true
|
||||
},
|
||||
{
|
||||
"key": "switch",
|
||||
"type": "target",
|
||||
"label": "触发器",
|
||||
"valueType": "any",
|
||||
"connected": false
|
||||
},
|
||||
{
|
||||
"valueType": "string",
|
||||
"type": "target",
|
||||
"label": "搜索词",
|
||||
"edit": true,
|
||||
"key": "searchKey",
|
||||
"required": true,
|
||||
"connected": true
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"label": "搜索词",
|
||||
"valueType": "string",
|
||||
"type": "source",
|
||||
"edit": true,
|
||||
"targets": [],
|
||||
"key": "searchKey"
|
||||
},
|
||||
{
|
||||
"label": "搜索结果",
|
||||
"valueType": "string",
|
||||
"type": "source",
|
||||
"edit": true,
|
||||
"targets": [
|
||||
{
|
||||
"moduleId": "aijmbb",
|
||||
"key": "systemPrompt"
|
||||
}
|
||||
],
|
||||
"key": "prompt"
|
||||
},
|
||||
{
|
||||
"key": "finish",
|
||||
"label": "请求结束",
|
||||
"valueType": "boolean",
|
||||
"type": "source",
|
||||
"targets": [
|
||||
{
|
||||
"moduleId": "aijmbb",
|
||||
"key": "switch"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"moduleId": "aijmbb",
|
||||
"name": "AI 对话",
|
||||
"flowType": "chatNode",
|
||||
"showStatus": true,
|
||||
"position": {
|
||||
"x": 2086.6387991825745,
|
||||
"y": 1090.812798225035
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"key": "model",
|
||||
"type": "custom",
|
||||
"label": "对话模型",
|
||||
"value": "gpt-3.5-turbo-16k",
|
||||
"list": [],
|
||||
"connected": true
|
||||
},
|
||||
{
|
||||
"key": "temperature",
|
||||
"type": "slider",
|
||||
"label": "温度",
|
||||
"value": 0,
|
||||
"min": 0,
|
||||
"max": 10,
|
||||
"step": 1,
|
||||
"markList": [
|
||||
{
|
||||
"label": "严谨",
|
||||
"value": 0
|
||||
},
|
||||
{
|
||||
"label": "发散",
|
||||
"value": 10
|
||||
}
|
||||
],
|
||||
"connected": true
|
||||
},
|
||||
{
|
||||
"key": "maxToken",
|
||||
"type": "custom",
|
||||
"label": "回复上限",
|
||||
"value": 8000,
|
||||
"min": 100,
|
||||
"max": 4000,
|
||||
"step": 50,
|
||||
"markList": [
|
||||
{
|
||||
"label": "100",
|
||||
"value": 100
|
||||
},
|
||||
{
|
||||
"label": "4000",
|
||||
"value": 4000
|
||||
}
|
||||
],
|
||||
"connected": true
|
||||
},
|
||||
{
|
||||
"key": "systemPrompt",
|
||||
"type": "textarea",
|
||||
"label": "系统提示词",
|
||||
"valueType": "string",
|
||||
"description": "模型固定的引导词,通过调整该内容,可以引导模型聊天方向。该内容会被固定在上下文的开头。可使用变量,例如 {{language}}",
|
||||
"placeholder": "模型固定的引导词,通过调整该内容,可以引导模型聊天方向。该内容会被固定在上下文的开头。可使用变量,例如 {{language}}",
|
||||
"value": "",
|
||||
"connected": true
|
||||
},
|
||||
{
|
||||
"key": "limitPrompt",
|
||||
"type": "textarea",
|
||||
"valueType": "string",
|
||||
"label": "限定词",
|
||||
"description": "限定模型对话范围,会被放置在本次提问前,拥有强引导和限定性。可使用变量,例如 {{language}}。引导例子:\n1. 知识库是关于 Laf 的介绍,参考知识库回答问题,与 \"Laf\" 无关内容,直接回复: \"我不知道\"。\n2. 你仅回答关于 \"xxx\" 的问题,其他问题回复: \"xxxx\"",
|
||||
"placeholder": "限定模型对话范围,会被放置在本次提问前,拥有强引导和限定性。可使用变量,例如 {{language}}。引导例子:\n1. 知识库是关于 Laf 的介绍,参考知识库回答问题,与 \"Laf\" 无关内容,直接回复: \"我不知道\"。\n2. 你仅回答关于 \"xxx\" 的问题,其他问题回复: \"xxxx\"",
|
||||
"value": "上文是谷歌搜索的结果,你可以提供实时信息,根据搜索结果回答问题。当前时间是{{cTime}}。",
|
||||
"connected": true
|
||||
},
|
||||
{
|
||||
"key": "switch",
|
||||
"type": "target",
|
||||
"label": "触发器",
|
||||
"valueType": "any",
|
||||
"connected": true
|
||||
},
|
||||
{
|
||||
"key": "quoteQA",
|
||||
"type": "target",
|
||||
"label": "引用内容",
|
||||
"valueType": "kb_quote",
|
||||
"connected": false
|
||||
},
|
||||
{
|
||||
"key": "history",
|
||||
"type": "target",
|
||||
"label": "聊天记录",
|
||||
"valueType": "chat_history",
|
||||
"connected": true
|
||||
},
|
||||
{
|
||||
"key": "userChatInput",
|
||||
"type": "target",
|
||||
"label": "用户问题",
|
||||
"required": true,
|
||||
"valueType": "string",
|
||||
"connected": true
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"key": "answerText",
|
||||
"label": "模型回复",
|
||||
"description": "直接响应,无需配置",
|
||||
"type": "hidden",
|
||||
"targets": []
|
||||
},
|
||||
{
|
||||
"key": "finish",
|
||||
"label": "回复结束",
|
||||
"description": "AI 回复完成后触发",
|
||||
"valueType": "boolean",
|
||||
"type": "source",
|
||||
"targets": []
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## 流程说明
|
||||
|
||||
1. 提取模块将用户的问题提取成搜索关键词
|
||||
2. 将搜索关键词传入 HTTP 模块
|
||||
3. HTTP 模块调用谷歌搜索接口,返回搜索内容
|
||||
4. 将搜索内容传入【AI 对话】的提示词,引导模型进行回答。
|
Before Width: | Height: | Size: 437 KiB |
Before Width: | Height: | Size: 273 KiB |
Before Width: | Height: | Size: 92 KiB |
Before Width: | Height: | Size: 329 KiB |
@@ -1,90 +0,0 @@
|
||||
---
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
# 快速了解
|
||||
|
||||
FastGpt V4 后将采用新的交互方式来构建 AI 应用。使用了 Flow 节点编排的方式来实现复杂工作流,提高可玩性和扩展性。但同时也提高了上手的门槛,有一定开发背景的用户使用起来会比较容易。
|
||||
|
||||
这篇文章就来简单介绍一下模块编排基本内容。每个模块的详解会单独分出一章。
|
||||
|
||||

|
||||
|
||||
## 什么是模块?
|
||||
|
||||
在程序中,模块可以理解为一个个 function 或者接口。可以理解为它就是一个**步骤**。将多个模块一个个拼接起来,即可一步步的去实现最终的 AI 输出。
|
||||
|
||||
如下图,是一个最简单的 AI 对话。它由用户输入的问题、聊天记录以及 AI 对话模块组成。
|
||||
|
||||

|
||||
|
||||
运行的流程如下:
|
||||
|
||||
1. 用户输入问题后,会向服务器发送一个请求,并携带问题。从而得到【用户问题】模块的一个输出。
|
||||
2. 根据设置的【最长记录数】来进行获取数据库中的记录数,从而得到【聊天记录】模块的输出。
|
||||
经过上面两个流程,就得到了左侧两个蓝色点的结果。结果会被注入到右侧的【AI】对话模块。
|
||||
3. AI 对话模块根据传入的聊天记录和用户问题,调用对话接口,从而实现回答。(这里的对话结果输出隐藏了起来,默认只要触发了对话模块,就会往客户端输出内容)
|
||||
|
||||
### 模块分类
|
||||
|
||||
从功能上,可以分为 3 类:
|
||||
|
||||
1. 仅读模块:全局变量、用户引导
|
||||
2. 系统模块:聊天记录(无输入,直接从数据库取)、用户问题(流程入口)
|
||||
3. 功能模块:知识库搜索、AI 对话等剩余模块。(这些模块都有输入和输出,可以自由组合)
|
||||
|
||||
### 模块的组成
|
||||
|
||||
每个模块会包含 3 个核心部分:固定参数、外部输入(左边有个圆圈)和输出(右边有个圆圈)。
|
||||
|
||||
对于仅读模块,只需要根据提示填写即可,不参与流程运行。
|
||||
|
||||
对于系统模块,通常只有固定参数和输出,主要需要关注输出到哪个位置。
|
||||
|
||||
对于功能模块,通常这 3 部分都是重要的,以下图的 AI 对话为例
|
||||
|
||||

|
||||
|
||||
- 对话模型、温度、回复上限、系统提示词和限定词为固定参数,同时系统提示词和限定词也可以作为外部输入,意味着如果你有输入流向了系统提示词,那么原本填写的内容就会被**覆盖**。
|
||||
|
||||
- 触发器、引用内容、聊天记录和用户问题则为外部输入,需要从其他模块的输出流入。
|
||||
|
||||
- 回复结束则为该模块的输出。
|
||||
|
||||
### 模块什么时候执行?
|
||||
|
||||
记住原则:
|
||||
|
||||
1. 仅关心**已连接的**外部输入,即左边的圆圈被连接了。
|
||||
2. 当连接内容都有值时触发。
|
||||
|
||||
#### 例子 1:
|
||||
|
||||
聊天记录模块会自动执行,因此聊天记录输入会自动赋值。当用户发送问题时,【用户问题】模块会输出值,此时【AI 对话】模块的用户问题输入也会被赋值。两个连接的输入都被赋值后,会执行 【AI 对话】模块。
|
||||
|
||||

|
||||
|
||||
#### 例子 2:
|
||||
|
||||
下图是一个知识库搜索例子。
|
||||
|
||||
1. 历史记录会流入【AI】对话模块。
|
||||
2. 用户的问题会流入【知识库搜索】和【AI 对话】模块,由于【AI 对话】模块的触发器和引用内容还是空,此时不会执行。
|
||||
3. 【知识库搜索】模块仅一个外部输入,并且被赋值,开始执行。
|
||||
4. 【知识库搜索】结果为空时,“搜索结果不为空”的值为空,不会输出,因此【AI 对话】模块会因为触发器没有赋值而无法执行。而“搜索结果为空”会有输出,流向指定回复的触发器,因此【指定回复】模块进行输出。
|
||||
5. 【知识库搜索】结果不为空时,“搜索结果不为空”和“引用内容”都有输出,会流向【AI 对话】,此时【AI 对话】的 4 个外部输入都被赋值,开始执行。
|
||||
|
||||

|
||||
|
||||
## 如何连接模块
|
||||
|
||||
1. 为了方便识别不同输入输出的类型,FastGPT 给每个模块的输入输出连接点不同的颜色,你可以把相同颜色的连接点连接起来。其中,灰色代表任意类型,可以随意连接。
|
||||
2. 位于左侧的连接点为输入,右侧的为输出,连接只能将一个输入和输出连接起来,不能输入和输入/输出和输出项链。
|
||||
3. 可以点击连接线中间的 x 来删除连接线。
|
||||
4. 可以左键点击选中连接线
|
||||
|
||||
## 如何阅读?
|
||||
|
||||
1. 建议从左往右阅读。
|
||||
2. 从 **用户问题** 模块开始。用户问题模块,代表的是用户发送了一段文本,触发任务开始。
|
||||
3. 关注 AI 对话和指定回复模块,这两个模块是输出答案的地方。
|
@@ -1,64 +0,0 @@
|
||||
# AI 对话
|
||||
|
||||
- 可重复添加(复杂编排时候防止线太乱,可以更美观)
|
||||
- 有外部输入
|
||||
- 有静态配置
|
||||
- 触发执行
|
||||
- 核心模块
|
||||
|
||||

|
||||
|
||||
## 参数说明
|
||||
|
||||
### 对话模型
|
||||
|
||||
可以通过 [data/config.json](/docs/develop/data_config/chat_models) 配置可选的对话模型,通过 [OneAPI](http://localhost:3000/docs/develop/oneapi) 来实现多模型接入。
|
||||
|
||||
### 温度 & 回复上限
|
||||
|
||||
温度:越低回答越严谨,少废话(实测下来,感觉差别不大)
|
||||
|
||||
回复上限:最大回复 token 数量(只有 OpenAI 模型有效)。注意,是回复!不是总 tokens。
|
||||
|
||||
### 系统提示词(可被外部输入覆盖)
|
||||
|
||||
被放置在上下文数组的最前面,role 为 system,用于引导模型。具体用法参考各搜索引擎的教程~
|
||||
|
||||
### 限定词(可被外部输入覆盖)
|
||||
|
||||
与系统提示词类似,role 也是 system 类型,只不过位置会被放置在问题前,拥有更强的引导作用。
|
||||
|
||||
### 引用内容
|
||||
|
||||
接收一个外部输入的数组,主要是由【知识库搜索】模块生成,也可以由 Http 模块从外部引入。数据结构例子如下:
|
||||
|
||||
```ts
|
||||
type DataType = {
|
||||
kb_id?: string;
|
||||
id?: string;
|
||||
q: string;
|
||||
a: string;
|
||||
source?: string;
|
||||
};
|
||||
// 如果是外部引入的内容,尽量不要携带 kb_id 和 id
|
||||
const quoteList: DataType[] = [
|
||||
{ kb_id: '11', id: '222', q: '你还', a: '哈哈', source: '' },
|
||||
{ kb_id: '11', id: '333', q: '你还', a: '哈哈', source: '' },
|
||||
{ kb_id: '11', id: '444', q: '你还', a: '哈哈', source: '' }
|
||||
];
|
||||
```
|
||||
|
||||
## 完整上下文组成
|
||||
|
||||
最终发送给 LLM 大模型的数据是一个数组,内容和顺序如下:
|
||||
|
||||
```
|
||||
[
|
||||
系统提示词
|
||||
引用内容
|
||||
聊天记录
|
||||
限定词
|
||||
问题
|
||||
]
|
||||
|
||||
```
|
@@ -1,51 +0,0 @@
|
||||
# 内容提取
|
||||
|
||||
- 可重复添加
|
||||
- 有外部输入
|
||||
- 手动配置
|
||||
- 触发执行
|
||||
- function_call 模块
|
||||
- 核心模块
|
||||
|
||||

|
||||
|
||||
## 功能
|
||||
|
||||
从文本中提取结构化数据,通常是配合 HTTP 模块实现扩展。也可以做一些直接提取操作,例如:翻译。
|
||||
|
||||
## 参数说明
|
||||
|
||||
### 提取要求描述
|
||||
|
||||
顾名思义,给模型一个要目标,需要提取哪些内容。
|
||||
|
||||
**例子 1**
|
||||
|
||||
> 你是实验室预约助手,从对话中提取出姓名,预约时间,实验室号。当前时间 {{cTime}}
|
||||
|
||||
**例子 2**
|
||||
|
||||
> 你是谷歌搜索助手,从对话中提取出搜索关键词
|
||||
|
||||
**例子 3**
|
||||
|
||||
> 将我的问题直接翻译成英文,不要回答问题
|
||||
|
||||
### 历史记录
|
||||
|
||||
通常需要一些历史记录,才能更完整的提取用户问题。例如上图中需要提前名字、时间和实验室名,用户可能一开始只给了时间和实验室名,没有给自己的名字。再经过一轮缺失提示后,用户输入了姓名,此时需要结合上一次的记录才能完整的提取出 3 个内容。
|
||||
|
||||
### 目标字段
|
||||
|
||||
目标字段与提取的结果相对应,从上图可以看到,每增加一个字段,输出会增加一个对应的出口。
|
||||
|
||||
key: 字段的唯一标识,不可重复!
|
||||
字段描述:描述该字段是关于什么的,例如:姓名、时间、搜索词等等。
|
||||
必须:是否强制模型提取该字段,可能提取出来是空字符串。
|
||||
|
||||
## 输出介绍
|
||||
|
||||
- 字段完全提取:说明用户的问题中包含需要提取的所有内容。
|
||||
- 提取字段缺失:与 “字段完全提取” 对立,有缺失提取的字段时触发。
|
||||
- 完整提取结果: 一个 json 字符串,包含所有字段的提取结果。
|
||||
- 目标字段提取结果:类型均为字符串。
|
@@ -1,69 +0,0 @@
|
||||
# 问题分类
|
||||
|
||||
- 可重复添加
|
||||
- 有外部输入
|
||||
- 手动配置
|
||||
- 触发执行
|
||||
- function_call 模块
|
||||
|
||||

|
||||
|
||||
## 功能
|
||||
|
||||
可以将用户的问题进行分类,分类后执行不同操作。在一些较模糊的场景中,分类效果不是很明显。
|
||||
|
||||
## 参数说明
|
||||
|
||||
### 系统提示词
|
||||
|
||||
被放置在对话最前面,可用于补充说明分类内容的定义。例如问题会被分为:
|
||||
|
||||
1. 打招呼
|
||||
2. laf 常见问题
|
||||
3. 其他问题
|
||||
|
||||
由于 laf 不是一个明确的东西,需要给它一个定义,此时提示词里可以填入 laf 的定义:
|
||||
|
||||
```
|
||||
laf 是云开发平台,可以快速的开发应用
|
||||
laf 是一个开源的 BaaS 开发平台(Backend as a Service)
|
||||
laf 是一个开箱即用的 serverless 开发平台
|
||||
laf 是一个集「函数计算」、「数据库」、「对象存储」等于一身的一站式开发平台
|
||||
laf 可以是开源版的腾讯云开发、开源版的 Google Firebase、开源版的 UniCloud
|
||||
```
|
||||
|
||||
### 聊天记录
|
||||
|
||||
适当增加一些聊天记录,可以联系上下文进行分类。
|
||||
|
||||
### 用户问题
|
||||
|
||||
输入的内容。
|
||||
|
||||
### 分类内容
|
||||
|
||||
依然以这 3 个分类为例,可以看到最终组成的 function。其中返回值由系统随机生成,不需要关心。
|
||||
|
||||
1. 打招呼
|
||||
2. laf 常见问题
|
||||
3. 其他问题
|
||||
|
||||
```js
|
||||
const agentFunction = {
|
||||
name: agentFunName,
|
||||
description: '判断用户问题的类型属于哪方面,返回对应的枚举字段',
|
||||
parameters: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: {
|
||||
type: 'string',
|
||||
description: `打招呼,返回: abc;laf 常见问题,返回:vvv;其他问题,返回:aaa`
|
||||
enum: ["abc","vvv","aaa"]
|
||||
}
|
||||
},
|
||||
required: ['type']
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
上面的 function 必然会返回 type = abc,vvv,aaa 其中一个值,从而实现分类判断。
|
@@ -1,9 +0,0 @@
|
||||
# 用户引导
|
||||
|
||||
- 仅可添加 1 个
|
||||
- 无外部输入
|
||||
- 不参与实际调度
|
||||
|
||||
如图,可以在用户提问前给予一定引导。并可以设置引导问题。
|
||||
|
||||

|
@@ -1,10 +0,0 @@
|
||||
# 历史记录
|
||||
|
||||
- 可重复添加(复杂编排时候防止线太乱,可以更美观)
|
||||
- 无外部输入
|
||||
- 流程入口
|
||||
- 自动执行
|
||||
|
||||
每次对话时,会从数据库取最多 n 条聊天记录作为上下文。注意,不是指本轮对话最多 n 条上下文,本轮对话还包括:提示词、限定词、引用内容和问题。
|
||||
|
||||

|
@@ -1,95 +0,0 @@
|
||||
# HTTP 模块
|
||||
|
||||
- 可重复添加
|
||||
- 有外部输入
|
||||
- 手动配置
|
||||
- 触发执行
|
||||
- 核中核模块
|
||||
|
||||

|
||||
|
||||
## 介绍
|
||||
|
||||
HTTP 模块会向对应的地址发送一个 POST 请求,Body 中携带 json 类型的参数,具体的参数可自定义。并接收一个 json 响应值,字段也是自定义。如上图中,我们定义了一个入参:提取的字段(定义的 key 为 appointment,类型为 string),和一个出参:提取结果(定义的 key 为 response,类型为 string)。
|
||||
|
||||
那么,这个请求的 curl 为:
|
||||
|
||||
```curl
|
||||
curl --location --request POST 'https://xxxx.laf.dev/appointment-lab' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"appointment":"{\"name\":\"小明\",\"time\":\"2023/08/16 15:00\",\"labname\":\"子良A323\"}"
|
||||
}'
|
||||
```
|
||||
|
||||
响应为:
|
||||
|
||||
```json
|
||||
{
|
||||
"response": "您已经有一个预约记录了,每人仅能同时预约一个实验室:\n 姓名:小明\n 时间: 2023/08/15 15:00\n 实验室: 子良A323\n "
|
||||
}
|
||||
```
|
||||
|
||||
**如果你不想额外的部署服务,可以使用 laf 快速的搭建接口,即写即发,无需部署**
|
||||
|
||||
[laf 在线地址](https://laf.dev/)
|
||||
|
||||
下面是一个请求例子:
|
||||
|
||||
```ts
|
||||
import cloud from '@lafjs/cloud';
|
||||
const db = cloud.database();
|
||||
|
||||
export default async function (ctx: FunctionContext) {
|
||||
const { appointment } = ctx.body;
|
||||
const { name, time, labname } = JSON.parse(appointment);
|
||||
|
||||
const missData = [];
|
||||
if (!name) missData.push('你的姓名');
|
||||
if (!time) missData.push('需要预约的时间');
|
||||
if (!labname) missData.push('实验室名称');
|
||||
|
||||
if (missData.length > 0) {
|
||||
return {
|
||||
response: `请提供: ${missData.join('、')}`
|
||||
};
|
||||
}
|
||||
|
||||
const { data: record } = await db
|
||||
.collection('LabAppointment')
|
||||
.where({
|
||||
name,
|
||||
status: 'unStart'
|
||||
})
|
||||
.getOne();
|
||||
|
||||
if (record) {
|
||||
return {
|
||||
response: `您已经有一个预约记录了,每人仅能同时预约一个实验室:
|
||||
姓名:${record.name}
|
||||
时间: ${record.time}
|
||||
实验室: ${record.labname}
|
||||
`
|
||||
};
|
||||
}
|
||||
|
||||
await db.collection('LabAppointment').add({
|
||||
name,
|
||||
time,
|
||||
labname,
|
||||
status: 'unStart'
|
||||
});
|
||||
|
||||
return {
|
||||
response: `预约成功。
|
||||
姓名:${name}
|
||||
时间: ${time}
|
||||
实验室: ${labname}
|
||||
`
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
## 作用
|
||||
|
||||
基于 HTTP 模块,你可以做无限的扩展,可以操作数据库、执行联网搜索、发送邮箱等等。如果你有有趣的案例,欢迎 PR 到 [编排案例](/docs/category/examples)
|
Before Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 102 KiB |
Before Width: | Height: | Size: 66 KiB |
Before Width: | Height: | Size: 77 KiB |
Before Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 182 KiB |
Before Width: | Height: | Size: 228 KiB |
Before Width: | Height: | Size: 115 KiB |
Before Width: | Height: | Size: 121 KiB |
Before Width: | Height: | Size: 285 KiB |
Before Width: | Height: | Size: 108 KiB |
@@ -1,16 +0,0 @@
|
||||
# 指定回复
|
||||
|
||||
- 可重复添加(复杂编排时候防止线太乱,可以更美观)
|
||||
- 可手动输入
|
||||
- 可外部输入
|
||||
- 会输出结果给客户端
|
||||
|
||||
制定回复模块通常用户特殊状态回复,当然你也可以像图 2 一样,实现一些比较骚的操作~ 触发逻辑非常简单,一种是写好回复内容,通过触发器触发;一种是不写回复内容,直接由外部输入触发,并回复输入的内容。
|
||||
|
||||

|
||||
|
||||
图 1
|
||||
|
||||

|
||||
|
||||
图 2
|
@@ -1,23 +0,0 @@
|
||||
---
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
# 触发器介绍
|
||||
|
||||
细心的同学可以发现,在每个功能模块里都会有一个叫【触发器】的外部输入,并且是 any 类型。
|
||||
|
||||
它的**核心作用**就是控制模块的执行时机,以下图 2 个知识库搜索中的【AI 对话】模块为例子:
|
||||
|
||||
| 图 1 | 图 2 |
|
||||
| ---------------------------- | ---------------------------- |
|
||||
|  |  |
|
||||
|
||||
【知识库搜索】模块中,由于**引用内容**始终会有输出,会导致【AI 对话】模块的**引用内容**输入无论有没有搜到内容都会被赋值。如果此时不连接触发器(图 2),在搜索结束后必定会执行【AI 对话】模块。
|
||||
|
||||
有时候,你可能希望空搜索时候进行额外处理,例如:回复固定内容、调用其他提示词的 GPT、发送一个 HTTP 请求…… 此时就需要用到触发器,需要将 **搜索结果不为空** 和 **触发器** 连接起来。
|
||||
|
||||
当搜索结果为空时,【知识库搜索】模块不会输出 **搜索结果不为空** 的结果,因此 【AI 对话】 模块的触发器始终为空,便不会执行。
|
||||
|
||||
总之,记住模块执行的逻辑就可以灵活的使用触发器:
|
||||
|
||||
**外部输入字段(有连接的才有效)全部被赋值时候执行**
|
@@ -1,8 +0,0 @@
|
||||
# 用户问题
|
||||
|
||||
- 可重复添加(复杂编排时候防止线太乱,可以更美观)
|
||||
- 无外部输入
|
||||
- 流程入口
|
||||
- 自动执行
|
||||
|
||||

|
@@ -1,32 +0,0 @@
|
||||
---
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
# 全局变量
|
||||
|
||||
## 特点
|
||||
|
||||
- 仅可添加 1 个
|
||||
- 手动配置
|
||||
- 对其他模块有影响
|
||||
- 可作为用户引导
|
||||
|
||||
## 说明
|
||||
|
||||
可以在对话前设置一些问题,让用户输入或选择,并将用户输入/选择的结果注入到其他模块中。目前仅会注入到 string 类型的数据里(对应蓝色圆圈的输入)。
|
||||
|
||||
如下图,定义了两个变量:目标语言和下拉框测试(忽略)
|
||||
|
||||
用户在对话前会被要求先填写目标语言,配合用户引导,我们就构建了一个简单的翻译机器人。**目标语言**的 key:language 被写入到【AI 对话】模块的限定词里。
|
||||
|
||||

|
||||
|
||||
通过完整对话记录我们可以看到,实际的限定词从:“将我的问题直接翻译成{{language}}” 变成了 “将我的问题直接翻译成英语”,因为 {{language}} 被变量替换了。
|
||||
|
||||

|
||||
|
||||
## 系统级变量
|
||||
|
||||
除了用户自定义设置的变量外,还会有一些系统变量:
|
||||
|
||||
cTime: 当前时间,例如:2023/3/3 20:22
|
Before Width: | Height: | Size: 111 KiB |
Before Width: | Height: | Size: 596 KiB |
Before Width: | Height: | Size: 223 KiB |
Before Width: | Height: | Size: 428 KiB |
Before Width: | Height: | Size: 177 KiB |
Before Width: | Height: | Size: 548 KiB |
Before Width: | Height: | Size: 437 KiB |
Before Width: | Height: | Size: 574 KiB |
Before Width: | Height: | Size: 270 KiB |
@@ -1,48 +0,0 @@
|
||||
---
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
# 快速了解 FastGpt
|
||||
|
||||
FastGPT 是一个基于 LLM 大语言模型的知识库问答系统,提供开箱即用的数据处理、模型调用等能力。同时可以通过 Flow 可视化进行工作流编排,从而实现复杂的问答场景!
|
||||
|
||||
| | |
|
||||
| -------------------------- | -------------------------- |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|
||||
## FastGPT 能力
|
||||
|
||||
### 1. AI 客服
|
||||
|
||||
通过导入文档或已有问答对进行训练,让 AI 模型能根据你的文档进行回答问题。
|
||||

|
||||
|
||||
### 2. 自动数据预处理
|
||||
|
||||
提供手动输入、直接分段、LLM 自动处理和 CSV 等多种数据导入途径,兼顾精确和快速训练场景。
|
||||

|
||||
|
||||
### 3. 工作流编排
|
||||
|
||||
基于 Flow 模块的工作流编排,可以帮助你设计更加复杂的问答流程。例如查询数据库、查询库存、预约实验室等。
|
||||
|
||||

|
||||
|
||||
### 4. 无缝衔接的 OpenAPI
|
||||
|
||||
FastGPT 对外 API 接口对齐 GPT 官方接口,你可以直接在现有的 GPT 应用中通过修改 BaseURL 和 Authorization 即可接入 FastGPT。
|
||||

|
||||
|
||||
## FastGPT 特点
|
||||
|
||||
1. 项目开源。FastGPT 遵循 Apache License 2.0 开源协议,你可以在 GitHub Clone FastGPT 进行二次开发和发布。FastGPT 社区版将保留核心的功能,商业版仅在社区版基础上使用 API 的形式进行扩展,不影响学习使用。
|
||||
2. 独特的 QA 结构。针对客服问答场景设计的 QA 结构,提高在大量数据场景中的准确性。
|
||||
3. 可视化工作流。通过 Flow 模块展示了从问题输入到模型输出的完整流程,便于调试和设计复杂流程。
|
||||
4. 无限扩展。基于 HTTP 进行扩展,无需修改 FastGPT 源码,也可快速接入现有的程序中。
|
||||
5. 便捷调试。提供搜索测试、引用修改、完整对话预览等多种调试途径。
|
||||
6. 支持多种模型:支持 GPT、Claude、文心一言等多类 LLM 模型,未来也将支持自定义的向量模型。
|
||||
|
||||
## 知识库核心流程图
|
||||
|
||||

|
Before Width: | Height: | Size: 100 KiB |
@@ -1,36 +0,0 @@
|
||||
# 3分钟在Fastgpt上用上GLM
|
||||
## 前言
|
||||
Fast GPT 允许你使用自己的 openai API KEY 来快速的调用 openai 接口,目前集成了 Gpt35, Gpt4 和 embedding. 可构建自己的知识库。但考虑到数据安全的问题,我们并不能将所有的数据都交付给云端大模型。那如何在fastgpt上接入私有化模型呢,本文就以清华的ChatGLM2为例,为各位讲解如何在fastgpt中接入私有化模型。
|
||||
## ChatGLM2简介
|
||||
ChatGLM2-6B 是开源中英双语对话模型 ChatGLM-6B 的第二代版本,具体介绍请看项目:https://github.com/THUDM/ChatGLM2-6B
|
||||
注意,ChatGLM2-6B 权重对学术研究完全开放,在获得官方的书面许可后,亦允许商业使用。本教程只是介绍了一种用法,并不会给予任何授权。
|
||||
## 推荐配置
|
||||
依据官方数据,同样是生成 8192 长度,量化等级为FP16要占用12.8GB 显存、INT8为8.1GB显存、INT4为5.1GB显存,量化后会稍微影响性能,但不多。
|
||||
因此推荐配置如下:
|
||||
fp16:内存>=16GB,显存>=16GB,硬盘空间>=25GB,启动时使用命令python openai_api.py 16
|
||||
int8:内存>=16GB,显存>=9GB,硬盘空间>=25GB,启动时选择python openai_api.py 8
|
||||
int4:内存>=16GB,显存>=6GB,硬盘空间>=25GB,启动时选择python openai_api.py 4
|
||||
## 环境配置
|
||||
Python 3.8.10
|
||||
CUDA 11.8
|
||||
科学上网环境
|
||||
## 简单的步骤
|
||||
1. 根据上面的环境配置配置好环境,具体教程自行GPT;
|
||||
1. 在命令行输入pip install -r requirments.txt
|
||||
2. 打开你需要启动的py文件,在代码的第76行配置token,这里的token只是加一层验证,防止接口被人盗用
|
||||
2. python openai_api.py 16//这里的数字根据上面的配置进行选择
|
||||
|
||||
然后等待模型下载,直到模型加载完毕,出现报错先问GPT
|
||||
上面两个文件在本文档的同目录
|
||||
|
||||
启动成功后应该会显示如下地址:
|
||||

|
||||
这里的http://0.0.0.0:6006就是连接地址
|
||||
|
||||
然后现在回到.env.local文件,依照以下方式配置地址:
|
||||
|
||||
OPENAI_BASE_URL=http://127.0.0.1:6006/v1
|
||||
OPENAIKEY=sk-aaabbbcccdddeeefffggghhhiiijjjkkk //这里是你在代码中配置的token
|
||||
这里的OPENAIKEY可以任意填写
|
||||
|
||||
这样就成功接入ChatGLM2了
|
Before Width: | Height: | Size: 247 KiB |
Before Width: | Height: | Size: 355 KiB |
Before Width: | Height: | Size: 411 KiB |
@@ -1,22 +0,0 @@
|
||||
# 通过 OpenAPI 接入第三方应用
|
||||
|
||||
## 1. 获取 API 秘钥
|
||||
|
||||
注意复制,关掉了需要新建~
|
||||
|
||||

|
||||
|
||||
## 2. 组合秘钥
|
||||
|
||||
利用刚复制的 API 秘钥加上 AppId 组合成一个新的秘钥,格式为: API 秘钥-AppId,例如:`fastgpt-z51pkjqm9nrk03a1rx2funoy-642adec15f04d67d4613efdb`
|
||||
|
||||
## 3. 替换三方应用的变量
|
||||
|
||||
OPENAI_API_BASE_URL: https://fastgpt.run/api/openapi (改成自己部署的域名)
|
||||
OPENAI_API_KEY = 组合秘钥
|
||||
|
||||
**[chatgpt next](https://github.com/Yidadaa/ChatGPT-Next-Web) 示例**
|
||||

|
||||
|
||||
**[chatgpt web](https://github.com/Chanzhaoyu/chatgpt-web) 示例**
|
||||

|
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"item.label.Docs": {
|
||||
"message": "文档"
|
||||
},
|
||||
"item.label.Start Now": {
|
||||
"message": "在线使用"
|
||||
}
|
||||
}
|
32
docSite/i18n/zh-cn.toml
Normal file
@@ -0,0 +1,32 @@
|
||||
[lang_select_title]
|
||||
other = "语言切换"
|
||||
|
||||
[search_title]
|
||||
other = "搜索"
|
||||
|
||||
[search_navigate]
|
||||
other = "导航"
|
||||
|
||||
[search_select]
|
||||
other = "选中"
|
||||
|
||||
[search_close]
|
||||
other = "关闭"
|
||||
|
||||
[search_cancel]
|
||||
other = "取消"
|
||||
|
||||
[search_no_results]
|
||||
other = "没有结果:"
|
||||
|
||||
[feedback_yes]
|
||||
other = "Yes"
|
||||
|
||||
[feedback_no]
|
||||
other = "No"
|
||||
|
||||
[feedback_helpful]
|
||||
other = "Was this page helpful?"
|
||||
|
||||
[feedback_submit]
|
||||
other = "提交"
|