mirror of
https://github.com/langchain-ai/opengpts.git
synced 2026-07-01 18:23:41 -04:00
Task replace put with post (#266)
* Use POST to create a thread * POST over PUT * no analytics sending from unstructured * lint format
This commit is contained in:
+2
-1
@@ -12,4 +12,5 @@ PROXY_URL=your_proxy_url
|
||||
POSTGRES_PORT=placeholder
|
||||
POSTGRES_DB=placeholder
|
||||
POSTGRES_USER=placeholder
|
||||
POSTGRES_PASSWORD=placeholder
|
||||
POSTGRES_PASSWORD=placeholder
|
||||
SCARF_NO_ANALYTICS=true
|
||||
@@ -80,6 +80,7 @@ jobs:
|
||||
POSTGRES_DB: postgres
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
SCARF_NO_ANALYTICS: true
|
||||
run: make test
|
||||
|
||||
frontend-lint-and-build:
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { useCallback, useEffect, useReducer } from "react";
|
||||
import orderBy from "lodash/orderBy";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
export interface Message {
|
||||
type: string;
|
||||
@@ -72,26 +71,19 @@ export function useChatList(): ChatListProps {
|
||||
fetchChats();
|
||||
}, []);
|
||||
|
||||
const createChat = useCallback(
|
||||
async (
|
||||
name: string,
|
||||
assistant_id: string,
|
||||
thread_id: string = uuidv4(),
|
||||
) => {
|
||||
const response = await fetch(`/threads/${thread_id}`, {
|
||||
method: "PUT",
|
||||
body: JSON.stringify({ assistant_id, name }),
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
},
|
||||
});
|
||||
const saved = await response.json();
|
||||
setChats(saved);
|
||||
return saved;
|
||||
},
|
||||
[],
|
||||
);
|
||||
const createChat = useCallback(async (name: string, assistant_id: string) => {
|
||||
const response = await fetch(`/threads`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ assistant_id, name }),
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
},
|
||||
});
|
||||
const saved = await response.json();
|
||||
setChats(saved);
|
||||
return saved;
|
||||
}, []);
|
||||
|
||||
return {
|
||||
chats,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { useCallback, useEffect, useReducer } from "react";
|
||||
import orderBy from "lodash/orderBy";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
export interface Config {
|
||||
assistant_id: string;
|
||||
@@ -65,34 +64,33 @@ export function useConfigList(): ConfigListProps {
|
||||
config: Config["config"],
|
||||
files: File[],
|
||||
isPublic: boolean,
|
||||
assistant_id: string = uuidv4(),
|
||||
): Promise<string> => {
|
||||
const formData = files.reduce((formData, file) => {
|
||||
formData.append("files", file);
|
||||
return formData;
|
||||
}, new FormData());
|
||||
formData.append(
|
||||
"config",
|
||||
JSON.stringify({ configurable: { assistant_id } }),
|
||||
);
|
||||
const [saved] = await Promise.all([
|
||||
fetch(`/assistants/${assistant_id}`, {
|
||||
method: "PUT",
|
||||
body: JSON.stringify({ name, config, public: isPublic }),
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
},
|
||||
}).then((r) => r.json()),
|
||||
files.length
|
||||
? fetch(`/ingest`, {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
: Promise.resolve(),
|
||||
]);
|
||||
setConfigs({ ...saved, mine: true });
|
||||
return saved.assistant_id;
|
||||
const confResponse = await fetch(`/assistants`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ name, config, public: isPublic }),
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
},
|
||||
});
|
||||
const savedConfig = (await confResponse.json()) as Config;
|
||||
if (files.length) {
|
||||
const assistant_id = savedConfig.assistant_id;
|
||||
const formData = files.reduce((formData, file) => {
|
||||
formData.append("files", file);
|
||||
return formData;
|
||||
}, new FormData());
|
||||
formData.append(
|
||||
"config",
|
||||
JSON.stringify({ configurable: { assistant_id } }),
|
||||
);
|
||||
await fetch(`/ingest`, {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
});
|
||||
}
|
||||
setConfigs({ ...savedConfig, mine: true });
|
||||
return savedConfig.assistant_id;
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user