Skip to content

Commit

Permalink
feat(pandasai_server): pandasai server code commit (#1189)
Browse files Browse the repository at this point in the history
* feat(pandasai_server): pandasai server code commit

* fix(docker-compose): add pandasbi backend in docker

* fix(pandasai-lint): sort linting errors

* refactor: rename modle file name

* feat(chat): adding chat endpoint

* fix: remove some keywords from spellcheck

* fix: poetry lock file

* me api integrated

* chat api integrated

* renamed, fix and add documentation

* workspace replaced

* fix: add conversation id to response

* feat(conversation): return all user conversations

* fix: should be equal equal

---------

Co-authored-by: Shahrukh Khan <[email protected]>
  • Loading branch information
ArslanSaleem and shahrukh802 authored Jun 3, 2024
1 parent 4f95944 commit 7801577
Show file tree
Hide file tree
Showing 114 changed files with 6,213 additions and 376 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ format_diff: ## run code formatters in diff mode
poetry run ruff --select I pandasai examples tests

spell_check: ## run codespell on the project
poetry run codespell --toml pyproject.toml --skip=$(IGNORE_FORMATS)
poetry run codespell --toml pyproject.toml --ignore-words=ignore-words.txt --skip=$(IGNORE_FORMATS)

spell_fix: ## run codespell on the project and fix the errors
poetry run codespell --toml pyproject.toml --skip=$(IGNORE_FORMATS) -w
poetry run codespell --toml pyproject.toml --ignore-words=ignore-words.txt --skip=$(IGNORE_FORMATS) -w

######################
# DOCS
Expand Down
4 changes: 2 additions & 2 deletions client/app/admin/chat/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
ChatApi,
ConversationHistory,
FetchFollowUpQuestions,
} from "services/chatInterface";
} from "services/chat";
import React, { useState, useEffect, useRef } from "react";
import { ChatMessageData } from "../../../types/chat-types";
import { useSearchParams } from "next/navigation";
Expand Down Expand Up @@ -92,7 +92,7 @@ const ChatPage = () => {

const fetchChatData = async (userQuery: string) => {
await ChatApi({
space_id: spaceId,
workspace_id: spaceId,
conversation_id: conversationId,
query: userQuery,
})
Expand Down
4 changes: 2 additions & 2 deletions client/app/admin/conversations/chat-details/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use client";
import { ChatApi, ConversationHistory } from "services/chatInterface";
import { ChatApi, ConversationHistory } from "services/chat";
import React, { useState, useEffect, useRef } from "react";
import { useRouter } from "next/navigation";
import { useSearchParams } from "next/navigation";
Expand Down Expand Up @@ -165,7 +165,7 @@ const ChatDetails = () => {
setChat(chat);
const fetchChatData = async () => {
await ChatApi({
space_id: space_id,
workspace_id: space_id,
conversation_id: conversation_id,
query: query,
})
Expand Down
36 changes: 0 additions & 36 deletions client/app/auth/sign-in/page.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion client/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { redirect } from "next/navigation";
export default function Home() {
redirect("/auth/sign-in");
redirect("/workspace");
}
84 changes: 29 additions & 55 deletions client/app/workspace/page.tsx
Original file line number Diff line number Diff line change
@@ -1,70 +1,44 @@
"use client";
import { WorkSpaceLoader } from "components/Skeletons";
import ToggleDarkModeComponent from "components/ToggleDarkMode";
import { useGetAllSpaces } from "hooks/useSpaces";
import { useRouter } from "next/navigation";
import React from "react";
import React, { useEffect, useState } from "react";
import { ROUTE_ADMIN } from "utils/constants";
import WorkSpaceHeader from "components/WorkSpace/header";
import {
FETCH_CONVERSATION,
useConversationsContext,
} from "contexts/ConversationsProvider";
import Link from "next/link";
import { useGetMe } from "@/hooks/useUsers";
import { Loader } from "@/components/loader/Loader";

const WorkSpace = () => {
const firstName = localStorage.getItem("firstName") || null;
const router = useRouter();
const storeContext = useConversationsContext();
const [isLoading, setIsLoading] = useState(true);
const { data: workspaceResponse } = useGetMe();
const myDetails = workspaceResponse?.data;

const { data: workspaceResponse, isLoading } = useGetAllSpaces();
const handleSpaceClick = (e, space) => {
e.preventDefault();
localStorage.setItem("spaceId", space.id);
localStorage.setItem("spaceName", space.name);
storeContext.dispatch({
type: FETCH_CONVERSATION,
payload: [],
});
const handleSpaceClick = () => {
localStorage.setItem("firstName", myDetails?.first_name);
localStorage.setItem("email", myDetails?.email);
localStorage.setItem("user_id", myDetails?.id);
localStorage.setItem(
"selectedOrganization",
JSON.stringify(myDetails?.organizations[0])
);
localStorage.setItem("spaceId", myDetails?.space?.id);
localStorage.setItem("spaceName", myDetails?.space?.name);
router.push(ROUTE_ADMIN);
setIsLoading(false);
};

useEffect(() => {
if (workspaceResponse?.data) {
handleSpaceClick();
}
}, [workspaceResponse]);

return (
<div className={`flex flex-col dark:bg-black bg-white min-h-screen`}>
<div>
<WorkSpaceHeader />
</div>
<div className="flex flex-col justify-center items-center w-full h-[75vh]">
<div className="text-center mx-auto w-full md:w-[700px]">
<h5
className={`text-[18px] md:text-[30px] font-medium mb-[14px] dark:text-white leading-10`}
>
Hey {!firstName ? "" : ` ${firstName} 👋,`}
<br />
select your workspace
</h5>
{isLoading ? (
<WorkSpaceLoader />
) : (
<div className="flex flex-wrap items-center justify-center gap-4 mt-5">
{workspaceResponse?.data?.data?.spaces?.map((space) => (
<Link
href={ROUTE_ADMIN}
key={space.id}
className="h-[37px] min-w-[136px] px-2 border rounded-[10px] flex flex-wrap items-center justify-center cursor-pointer dark:bg-white neon-on-hover"
onClick={(e) => handleSpaceClick(e, space)}
>
<span className="font-semibold text-black">{space.name}</span>
</Link>
))}
</div>
)}
<>
{isLoading && (
<div className="flex items-center justify-center m-auto h-full w-full">
<Loader />
</div>
</div>
<div className="md:absolute absolute bottom-5 left-10 flex">
<ToggleDarkModeComponent />
</div>
</div>
)}
</>
);
};

Expand Down
15 changes: 4 additions & 11 deletions client/components/ChatScreen/AIChatBubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@ import { ChatMessageData } from "@/types/chat-types";
import ChatDataFrame from "./ChatDataFrame";
import ChatPlot from "./ChatPlot";
import ChatReaction from "./ChatReaction";
import GetChatLabel from "./ChatLabel";
import EditCodeComponent from "./EditCode";
import {
ChatMessageRetry,
ChatReactionApi,
EditCode,
} from "services/chatInterface";
import { ChatMessageRetry, ChatReactionApi, EditCode } from "services/chat";
import { toast } from "react-toastify";
import { ChatReactionLoader } from "components/Skeletons";
import ExplainView from "./ExplainView";
Expand Down Expand Up @@ -244,11 +239,9 @@ const AIChatBubble = ({ chat, chatData, setChatData, lastIndex }: IProps) => {
{response?.message}
</div>
) : response.type === "number" ? (
<GetChatLabel
chatId={chat?.id}
message={response?.message}
key={chat?.id}
/>
<h1 className="font-bold text-4xl py-4 px-3">
{response?.value as string}
</h1>
) : (
""
)}
Expand Down
2 changes: 1 addition & 1 deletion client/components/ChatScreen/ChatDataFrame.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use client";
import { FetchDataframe } from "services/chatInterface";
import { FetchDataframe } from "services/chat";
import { ChatResponseItem } from "@/types/chat-types";
import React, { useState, useRef, useEffect } from "react";
import { FaChevronDown, FaChevronUp } from "react-icons/fa";
Expand Down
2 changes: 1 addition & 1 deletion client/components/LayoutComponents/ConversationItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import {
ArchiveConversationApi,
ConversationChatBySpaceApi,
} from "services/chatInterface";
} from "services/chat";
import {
FETCH_CONVERSATION,
useConversationsContext,
Expand Down
153 changes: 0 additions & 153 deletions client/hooks/apiHook.ts

This file was deleted.

2 changes: 1 addition & 1 deletion client/hooks/useConversations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
ConversationChatBySpaceApi,
ExplainConversationMessage,
GetChatLabel,
} from "@/services/chatInterface";
} from "@/services/chat";

export const useGetConversations = (spaceId, page, rowsPerPage) => {
const { data, isLoading, error, isError, refetch, isFetching } = useQuery({
Expand Down
Loading

0 comments on commit 7801577

Please sign in to comment.