Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ https://github.com/labring/FastGPT/assets/15308462/7d3a38df-eb0e-4388-9250-2409b
- [x] 文本内容提取成结构化数据
- [x] HTTP 扩展
- [ ] 嵌入 Laf,实现在线编写 HTTP 模块
- [ ] 连续对话引导
- [x] 对话下一步指引
- [ ] 对话多路线选择
- [x] 源文件引用追踪
- [ ] 自定义文件阅读器
Expand All @@ -55,7 +55,7 @@ https://github.com/labring/FastGPT/assets/15308462/7d3a38df-eb0e-4388-9250-2409b
- [x] 知识库单点搜索测试
- [x] 对话时反馈引用并可修改与删除
- [x] 完整上下文呈现
- [ ] 完整模块中间值呈现
- [x] 完整模块中间值呈现
4. OpenAPI
- [x] completions 接口(对齐 GPT 接口)
- [ ] 知识库 CRUD
Expand Down
2 changes: 1 addition & 1 deletion docSite/content/docs/development/openApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ FastGPT 的 API Key 有 2 类,一类是全局通用的 key;一类是携带
**请求示例:**

```bash
curl --location --request POST 'https://fastgpt.run/api/openapi/v1/chat/completions' \
curl --location --request POST 'https://fastgpt.run/api/v1/chat/completions' \
--header 'Authorization: Bearer apikey' \
--header 'Content-Type: application/json' \
--data-raw '{
Expand Down
4 changes: 2 additions & 2 deletions docSite/content/docs/use-cases/onwechat.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ weight: 312

## 3. 创建 docker-compose.yml 文件

只需要修改 `OPEN_AI_API_KEY` 和 `OPEN_AI_API_BASE` 两个环境变量即可。其中 `OPEN_AI_API_KEY` 为第一步获取的秘钥,`OPEN_AI_API_BASE` 为 FastGPT 的 OpenAPI 地址,例如:`https://fastgpt.run/api/openapi/v1`。
只需要修改 `OPEN_AI_API_KEY` 和 `OPEN_AI_API_BASE` 两个环境变量即可。其中 `OPEN_AI_API_KEY` 为第一步获取的秘钥,`OPEN_AI_API_BASE` 为 FastGPT 的 OpenAPI 地址,例如:`https://fastgpt.run/api/v1`。

随便找一个目录,创建一个 docker-compose.yml 文件,将下面的代码复制进去。

Expand All @@ -40,7 +40,7 @@ services:
- seccomp:unconfined
environment:
OPEN_AI_API_KEY: 'fastgpt-z51pkjqm9nrk03a1rx2funoy'
OPEN_AI_API_BASE: 'https://fastgpt.run/api/openapi/v1'
OPEN_AI_API_BASE: 'https://fastgpt.run/api/v1'
MODEL: 'gpt-3.5-turbo'
CHANNEL_TYPE: 'wx'
PROXY: ''
Expand Down
2 changes: 1 addition & 1 deletion docSite/content/docs/use-cases/openapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Tips: 安全起见,你可以设置一个额度或者过期时间,放置 key
## 替换三方应用的变量

```bash
OPENAI_API_BASE_URL: https://fastgpt.run/api/openapi (改成自己部署的域名)
OPENAI_API_BASE_URL: https://fastgpt.run/api (改成自己部署的域名)
OPENAI_API_KEY = 上一步获取到的秘钥
```

Expand Down
2 changes: 1 addition & 1 deletion projects/app/src/api/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface StreamFetchProps {
abortSignal: AbortController;
}
export const streamFetch = ({
url = '/api/openapi/v1/chat/completions',
url = '/api/v1/chat/completions',
data,
onMessage,
abortSignal
Expand Down
17 changes: 14 additions & 3 deletions projects/app/src/components/ChatBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { useMarkdown } from '@/hooks/useMarkdown';
import { AppModuleItemType, VariableItemType } from '@/types/app';
import { VariableInputEnum } from '@/constants/app';
import { useForm } from 'react-hook-form';
import { MessageItemType } from '@/pages/api/openapi/v1/chat/completions';
import type { MessageItemType } from '@/types/core/chat/type';
import { fileDownload } from '@/utils/web/file';
import { htmlTemplate } from '@/constants/common';
import { useRouter } from 'next/router';
Expand Down Expand Up @@ -158,6 +158,7 @@ const ChatBox = (
onStartChat?: (e: StartChatFnProps) => Promise<{
responseText: string;
[TaskResponseKeyEnum.responseData]: ChatHistoryItemResType[];
isNewChat?: boolean;
}>;
onDelMessage?: (e: { contentId?: string; index: number }) => void;
},
Expand All @@ -173,6 +174,7 @@ const ChatBox = (
const TextareaDom = useRef<HTMLTextAreaElement>(null);
const chatController = useRef(new AbortController());
const questionGuideController = useRef(new AbortController());
const isNewChatReplace = useRef(false);

const [refresh, setRefresh] = useState(false);
const [variables, setVariables] = useState<Record<string, any>>({}); // settings variable
Expand Down Expand Up @@ -381,14 +383,20 @@ const ChatBox = (

const messages = adaptChat2GptMessages({ messages: newChatList, reserveId: true });

const { responseData, responseText } = await onStartChat({
const {
responseData,
responseText,
isNewChat = false
} = await onStartChat({
chatList: newChatList,
messages,
controller: abortSignal,
generatingMessage,
variables
});

isNewChatReplace.current = isNewChat;

// set finish status
setChatHistory((state) =>
state.map((item, index) => {
Expand Down Expand Up @@ -542,9 +550,12 @@ const ChatBox = (

// page change and abort request
useEffect(() => {
isNewChatReplace.current = false;
return () => {
chatController.current?.abort('leave');
questionGuideController.current?.abort('leave');
if (!isNewChatReplace.current) {
questionGuideController.current?.abort('leave');
}
// close voice
cancelBroadcast();
};
Expand Down
7 changes: 3 additions & 4 deletions projects/app/src/components/Markdown/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,10 @@
.markdown ol li > *:first-child {
margin-top: 0;
}
.markdown ul ul,
.markdown ul ol,
.markdown ol ol,
.markdown ol ul {
.markdown ul,
.markdown ol {
margin-bottom: 0;
padding-left: 14px;
}
.markdown dl {
padding: 0;
Expand Down
2 changes: 1 addition & 1 deletion projects/app/src/pages/api/chat/chatTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { sseErrRes } from '@/service/response';
import { sseResponseEventEnum } from '@/constants/chat';
import { sseResponse } from '@/service/utils/tools';
import { AppModuleItemType } from '@/types/app';
import { dispatchModules } from '../openapi/v1/chat/completions';
import { dispatchModules } from '@/pages/api/v1/chat/completions';
import { pushChatBill } from '@/service/common/bill/push';
import { BillSourceEnum } from '@/constants/user';
import { ChatItemType } from '@/types/chat';
Expand Down
Loading