Merge pull request #191 from arc53/features/little-fixes

Features/little fixes
This commit is contained in:
Alex 2023-03-27 22:28:55 +01:00 committed by GitHub
commit 70bc7465c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 80 additions and 23 deletions

View File

@ -196,7 +196,7 @@ def api_answer():
else:
qa_chain = load_qa_chain(llm=llm, chain_type="map_reduce",
combine_prompt=c_prompt, question_prompt=q_prompt)
chain = VectorDBQA(combine_documents_chain=qa_chain, vectorstore=docsearch, k=4)
chain = VectorDBQA(combine_documents_chain=qa_chain, vectorstore=docsearch, k=3)
result = chain({"query": question})
print(result)
@ -285,7 +285,17 @@ def combined_json():
"""Provide json file with combined available indexes."""
# get json from https://d3dg1063dc54p9.cloudfront.net/combined.json
data = []
data = [{
"name": 'default',
"language": 'default',
"version": '',
"description": 'default',
"fullName": 'default',
"date": 'default',
"docLink": 'default',
"model": embeddings_choice,
"location": "local"
}]
# structure: name, language, version, description, fullName, date, docLink
# append data from vectors_collection
for index in vectors_collection.find({'user': user}):
@ -335,7 +345,7 @@ def upload_file():
os.makedirs(save_dir)
file.save(os.path.join(save_dir, filename))
task = ingest.delay('temp', [".rst", ".md", ".pdf"], job_name, filename, user)
task = ingest.delay('temp', [".rst", ".md", ".pdf", ".txt"], job_name, filename, user)
# task id
task_id = task.id
return {"status": 'ok', "task_id": task_id}

View File

@ -1,4 +1,4 @@
You are a DocsGPT, friendly and helpful AI assistant by Arc53 that provides help with documents. You give thorough answers with code examples if possible.
Use the following pieces of context to help answer the users question.
Use the following pieces of context to help answer the users question. If its not relevant to the question, provide friendly responses.
----------------
{summaries}

View File

@ -96,4 +96,4 @@ def ingest_worker(self, directory, formats, name_job, filename, user):
# delete local
shutil.rmtree(full_path)
return {'directory': directory, 'formats': formats, 'name_job': name_job, 'filename': filename, 'user': user}
return {'directory': directory, 'formats': formats, 'name_job': name_job, 'filename': filename, 'user': user, 'limited': False}

View File

@ -21,7 +21,9 @@ services:
ports:
- "5001:5001"
volumes:
- app_data_container:/app
- ./application/indexes:/app/indexes
- ./application/inputs:/app/inputs
- ./application/vectors:/app/vectors
depends_on:
- redis
- mongo
@ -55,5 +57,4 @@ services:
volumes:
mongodb_data_container:
app_data_container:
mongodb_data_container:

View File

@ -1 +1 @@
VITE_API_HOST = https://docsapi.arc53.com
VITE_API_HOST = https://gptcloud.arc53.com

View File

@ -38,9 +38,8 @@ export default function Navigation({
const [isDocsListOpen, setIsDocsListOpen] = useState(false);
const isApiKeySet = useSelector(selectApiKeyStatus);
const [apiKeyModalState, setApiKeyModalState] = useState<ActiveState>(
isApiKeySet ? 'INACTIVE' : 'ACTIVE',
);
const [apiKeyModalState, setApiKeyModalState] =
useState<ActiveState>('INACTIVE');
const isSelectedDocsSet = useSelector(selectSelectedDocsStatus);
const [selectedDocsModalState, setSelectedDocsModalState] =

View File

@ -71,9 +71,9 @@ export default function Conversation() {
};
return (
<div className="flex justify-center p-6">
<div className="flex justify-center p-4">
{queries.length > 0 && (
<div className="mt-20 flex w-10/12 flex-col transition-all md:w-3/4">
<div className="mt-20 flex flex-col transition-all md:w-3/4">
{queries.map((query, index) => {
return (
<Fragment key={index}>

View File

@ -13,8 +13,18 @@ interface Preference {
}
const initialState: Preference = {
apiKey: '',
selectedDocs: null,
apiKey: 'xxx',
selectedDocs: {
name: 'default',
language: 'default',
location: 'default',
version: 'default',
description: 'default',
fullName: 'default',
dat: 'default',
docLink: 'default',
model: 'openai_text-embedding-ada-002',
} as Doc,
sourceDocs: null,
};

View File

@ -19,20 +19,27 @@ export default function Upload({
type: 'UPLOAD' | 'TRAINIING';
percentage: number;
taskId?: string;
failed?: boolean;
}>();
function Progress({
title,
isCancellable = false,
isFailed = false,
}: {
title: string;
isCancellable?: boolean;
isFailed?: boolean;
}) {
return (
<div className="mt-5 flex flex-col items-center gap-2">
<p className="text-xl tracking-[0.15px]">{title}...</p>
<p className="text-sm text-gray-2000">This may take several minutes</p>
<p className={`ml-5 text-xl text-red-400 ${isFailed ? '' : 'hidden'}`}>
Over the token limit, please consider uploading smaller document
</p>
<p className="mt-10 text-2xl">{progress?.percentage || 0}%</p>
<div className="mb-10 w-[50%]">
<div className="h-1 w-[100%] bg-blue-4000"></div>
<div
@ -40,6 +47,7 @@ export default function Upload({
style={{ width: `${progress?.percentage || 0}%` }}
></div>
</div>
<button
onClick={() => {
setDocName('');
@ -71,11 +79,28 @@ export default function Upload({
.then((data) => data.json())
.then((data) => {
if (data.status == 'SUCCESS') {
getDocs().then((data) => dispatch(setSourceDocs(data)));
setProgress(
(progress) => progress && { ...progress, percentage: 100 },
);
} else {
if (data.result.limited === true) {
getDocs().then((data) => dispatch(setSourceDocs(data)));
setProgress(
(progress) =>
progress && {
...progress,
percentage: 100,
failed: true,
},
);
} else {
getDocs().then((data) => dispatch(setSourceDocs(data)));
setProgress(
(progress) =>
progress && {
...progress,
percentage: 100,
failed: false,
},
);
}
} else if (data.status == 'PROGRESS') {
setProgress(
(progress) =>
progress && {
@ -91,6 +116,7 @@ export default function Upload({
<Progress
title="Training is in progress"
isCancellable={progress?.percentage === 100}
isFailed={progress?.failed === true}
></Progress>
);
}
@ -125,10 +151,18 @@ export default function Upload({
const { getRootProps, getInputProps, isDragActive } = useDropzone({
onDrop,
multiple: true,
multiple: false,
onDragEnter: doNothing,
onDragOver: doNothing,
onDragLeave: doNothing,
maxSize: 25000000,
accept: {
'application/pdf': ['.pdf'],
'text/plain': ['.txt'],
'text/x-rst': ['.rst'],
'text/x-markdown': ['.md'],
'application/zip': ['.zip'],
},
});
let view;
@ -139,7 +173,10 @@ export default function Upload({
} else {
view = (
<>
<p className="mb-7 text-xl text-jet">Upload New Documentation</p>
<p className="text-xl text-jet">Upload New Documentation</p>
<p className="mb-3 text-xs text-gray-4000">
Please upload .pdf, .txt, .rst, .md, .zip limited to 25mb
</p>
<input
type="text"
className="h-10 w-[60%] rounded-md border-2 border-gray-5000 px-3 outline-none"