mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-06-18 03:50:58 +02:00
Small formatting fixes
This commit is contained in:
parent
44e3dcb19f
commit
e8786e1a20
@ -25,8 +25,8 @@ from danswer.connectors.slab.connector import SlabConnector
|
|||||||
from danswer.connectors.slack.connector import SlackLoadConnector
|
from danswer.connectors.slack.connector import SlackLoadConnector
|
||||||
from danswer.connectors.slack.connector import SlackPollConnector
|
from danswer.connectors.slack.connector import SlackPollConnector
|
||||||
from danswer.connectors.web.connector import WebConnector
|
from danswer.connectors.web.connector import WebConnector
|
||||||
from danswer.connectors.zulip.connector import ZulipConnector
|
|
||||||
from danswer.connectors.zendesk.connector import ZendeskConnector
|
from danswer.connectors.zendesk.connector import ZendeskConnector
|
||||||
|
from danswer.connectors.zulip.connector import ZulipConnector
|
||||||
|
|
||||||
|
|
||||||
class ConnectorMissingException(Exception):
|
class ConnectorMissingException(Exception):
|
||||||
|
@ -1,24 +1,25 @@
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
from zenpy import Zenpy
|
|
||||||
from zenpy.lib.api_objects.help_centre_objects import Article
|
from zenpy import Zenpy # type: ignore
|
||||||
|
from zenpy.lib.api_objects.help_centre_objects import Article # type: ignore
|
||||||
|
|
||||||
from danswer.configs.app_configs import INDEX_BATCH_SIZE
|
from danswer.configs.app_configs import INDEX_BATCH_SIZE
|
||||||
from danswer.configs.constants import DocumentSource
|
from danswer.configs.constants import DocumentSource
|
||||||
from danswer.connectors.models import Document, Section
|
from danswer.connectors.interfaces import GenerateDocumentsOutput
|
||||||
from danswer.connectors.interfaces import GenerateDocumentsOutput, LoadConnector, PollConnector, SecondsSinceUnixEpoch
|
from danswer.connectors.interfaces import LoadConnector
|
||||||
|
from danswer.connectors.interfaces import PollConnector
|
||||||
|
from danswer.connectors.interfaces import SecondsSinceUnixEpoch
|
||||||
|
from danswer.connectors.models import Document
|
||||||
|
from danswer.connectors.models import Section
|
||||||
|
|
||||||
|
|
||||||
class ZendeskClientNotSetUpError(PermissionError):
|
class ZendeskClientNotSetUpError(PermissionError):
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
super().__init__(
|
super().__init__("Zendesk Client is not set up, was load_credentials called?")
|
||||||
"Zendesk Client is not set up, was load_credentials called?"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ZendeskConnector(LoadConnector, PollConnector):
|
class ZendeskConnector(LoadConnector, PollConnector):
|
||||||
def __init__(
|
def __init__(self, batch_size: int = INDEX_BATCH_SIZE) -> None:
|
||||||
self,
|
|
||||||
batch_size: int = INDEX_BATCH_SIZE
|
|
||||||
) -> None:
|
|
||||||
self.batch_size = batch_size
|
self.batch_size = batch_size
|
||||||
self.zendesk_client: Zenpy | None = None
|
self.zendesk_client: Zenpy | None = None
|
||||||
|
|
||||||
@ -42,15 +43,22 @@ class ZendeskConnector(LoadConnector, PollConnector):
|
|||||||
metadata={
|
metadata={
|
||||||
"type": "article",
|
"type": "article",
|
||||||
"updated_at": article.updated_at,
|
"updated_at": article.updated_at,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def poll_source(
|
||||||
def poll_source(self, start: SecondsSinceUnixEpoch | None, end: SecondsSinceUnixEpoch | None) -> GenerateDocumentsOutput:
|
self, start: SecondsSinceUnixEpoch | None, end: SecondsSinceUnixEpoch | None
|
||||||
|
) -> GenerateDocumentsOutput:
|
||||||
if self.zendesk_client is None:
|
if self.zendesk_client is None:
|
||||||
raise ZendeskClientNotSetUpError()
|
raise ZendeskClientNotSetUpError()
|
||||||
|
|
||||||
articles = self.zendesk_client.help_center.articles(cursor_pagination=True) if start is None else self.zendesk_client.help_center.articles.incremental(start_time=int(start))
|
articles = (
|
||||||
|
self.zendesk_client.help_center.articles(cursor_pagination=True)
|
||||||
|
if start is None
|
||||||
|
else self.zendesk_client.help_center.articles.incremental(
|
||||||
|
start_time=int(start)
|
||||||
|
)
|
||||||
|
)
|
||||||
doc_batch = []
|
doc_batch = []
|
||||||
for article in articles:
|
for article in articles:
|
||||||
if article.body is None:
|
if article.body is None:
|
||||||
@ -60,4 +68,3 @@ class ZendeskConnector(LoadConnector, PollConnector):
|
|||||||
if len(doc_batch) >= self.batch_size:
|
if len(doc_batch) >= self.batch_size:
|
||||||
yield doc_batch
|
yield doc_batch
|
||||||
doc_batch.clear()
|
doc_batch.clear()
|
||||||
|
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
# This file is purely for development use, not included in any builds
|
# This file is purely for development use, not included in any builds
|
||||||
import requests
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
# makes it so `PYTHONPATH=.` is not required when running this script
|
||||||
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
sys.path.append(parent_dir)
|
sys.path.append(parent_dir)
|
||||||
|
|
||||||
|
from danswer.configs.app_configs import DOCUMENT_INDEX_NAME # noqa: E402
|
||||||
from danswer.configs.app_configs import DOCUMENT_INDEX_NAME
|
from danswer.document_index.vespa.index import DOCUMENT_ID_ENDPOINT # noqa: E402
|
||||||
from danswer.document_index.vespa.index import DOCUMENT_ID_ENDPOINT
|
from danswer.utils.logger import setup_logger # noqa: E402
|
||||||
from danswer.utils.logger import setup_logger
|
|
||||||
|
|
||||||
logger = setup_logger()
|
logger = setup_logger()
|
||||||
|
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
import psycopg2
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
import psycopg2
|
||||||
|
|
||||||
|
# makes it so `PYTHONPATH=.` is not required when running this script
|
||||||
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
sys.path.append(parent_dir)
|
sys.path.append(parent_dir)
|
||||||
|
|
||||||
from danswer.configs.app_configs import POSTGRES_DB
|
from danswer.configs.app_configs import POSTGRES_DB # noqa: E402
|
||||||
from danswer.configs.app_configs import POSTGRES_HOST
|
from danswer.configs.app_configs import POSTGRES_HOST # noqa: E402
|
||||||
from danswer.configs.app_configs import POSTGRES_PASSWORD
|
from danswer.configs.app_configs import POSTGRES_PASSWORD # noqa: E402
|
||||||
from danswer.configs.app_configs import POSTGRES_PORT
|
from danswer.configs.app_configs import POSTGRES_PORT # noqa: E402
|
||||||
from danswer.configs.app_configs import POSTGRES_USER
|
from danswer.configs.app_configs import POSTGRES_USER # noqa: E402
|
||||||
from danswer.db.credentials import create_initial_public_credential
|
from danswer.db.credentials import create_initial_public_credential # noqa: E402
|
||||||
|
|
||||||
|
|
||||||
def wipe_all_rows(database: str) -> None:
|
def wipe_all_rows(database: str) -> None:
|
||||||
|
@ -103,12 +103,13 @@ const Main = () => {
|
|||||||
<>
|
<>
|
||||||
<p className="text-sm">
|
<p className="text-sm">
|
||||||
To get started you'll need API token details for your Zendesk
|
To get started you'll need API token details for your Zendesk
|
||||||
instance. You can generate this by access the Admin Center of your instance
|
instance. You can generate this by access the Admin Center of your
|
||||||
(e.g. https://<subdomain>.zendesk.com/admin/). Proceed to the "Apps and
|
instance (e.g. https://<subdomain>.zendesk.com/admin/).
|
||||||
Integrations" section and "Zendesk API" page. Add a new API token and provide
|
Proceed to the "Apps and Integrations" section and
|
||||||
it with a name. You will also need to provide the e-mail address of a user that
|
"Zendesk API" page. Add a new API token and provide it
|
||||||
the system will impersonate. This is of little consequence as we are only performing
|
with a name. You will also need to provide the e-mail address of a
|
||||||
read actions.
|
user that the system will impersonate. This is of little consequence
|
||||||
|
as we are only performing read actions.
|
||||||
</p>
|
</p>
|
||||||
<div className="border-solid border-gray-600 border rounded-md p-6 mt-2 mb-4">
|
<div className="border-solid border-gray-600 border rounded-md p-6 mt-2 mb-4">
|
||||||
<CredentialForm<ZendeskCredentialJson>
|
<CredentialForm<ZendeskCredentialJson>
|
||||||
@ -189,29 +190,28 @@ const Main = () => {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{zendeskCredential &&
|
{zendeskCredential && zendeskConnectorIndexingStatuses.length === 0 && (
|
||||||
zendeskConnectorIndexingStatuses.length === 0 && (
|
<>
|
||||||
<>
|
<div className="border-solid border-gray-600 border rounded-md p-6 mt-4">
|
||||||
<div className="border-solid border-gray-600 border rounded-md p-6 mt-4">
|
<h2 className="font-bold mb-3">Create Connection</h2>
|
||||||
<h2 className="font-bold mb-3">Create Connection</h2>
|
<p className="text-sm mb-4">
|
||||||
<p className="text-sm mb-4">
|
Press connect below to start the connection to your Zendesk
|
||||||
Press connect below to start the connection to your Zendesk
|
instance.
|
||||||
instance.
|
</p>
|
||||||
</p>
|
<ConnectorForm<ZendeskConfig>
|
||||||
<ConnectorForm<ZendeskConfig>
|
nameBuilder={(values) => `ZendeskConnector`}
|
||||||
nameBuilder={(values) => `ZendeskConnector`}
|
ccPairNameBuilder={(values) => `ZendeskConnector`}
|
||||||
ccPairNameBuilder={(values) => `ZendeskConnector`}
|
source="zendesk"
|
||||||
source="zendesk"
|
inputType="poll"
|
||||||
inputType="poll"
|
formBody={<></>}
|
||||||
formBody={<></>}
|
validationSchema={Yup.object().shape({})}
|
||||||
validationSchema={Yup.object().shape({})}
|
initialValues={{}}
|
||||||
initialValues={{}}
|
refreshFreq={10 * 60} // 10 minutes
|
||||||
refreshFreq={10 * 60} // 10 minutes
|
credentialId={zendeskCredential.id}
|
||||||
credentialId={zendeskCredential.id}
|
/>
|
||||||
/>
|
</div>
|
||||||
</div>
|
</>
|
||||||
</>
|
)}
|
||||||
)}
|
|
||||||
|
|
||||||
{!zendeskCredential && (
|
{!zendeskCredential && (
|
||||||
<>
|
<>
|
||||||
|
@ -26,7 +26,7 @@ import {
|
|||||||
GoogleSitesIcon,
|
GoogleSitesIcon,
|
||||||
GongIcon,
|
GongIcon,
|
||||||
ZoomInIcon,
|
ZoomInIcon,
|
||||||
ZendeskIcon
|
ZendeskIcon,
|
||||||
} from "@/components/icons/icons";
|
} from "@/components/icons/icons";
|
||||||
import { getAuthDisabledSS, getCurrentUserSS } from "@/lib/userSS";
|
import { getAuthDisabledSS, getCurrentUserSS } from "@/lib/userSS";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
@ -240,7 +240,7 @@ export async function Layout({ children }: { children: React.ReactNode }) {
|
|||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
link: "/admin/connectors/zendesk",
|
link: "/admin/connectors/zendesk",
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -142,7 +142,7 @@ export const getSourceMetadata = (sourceType: ValidSources): SourceMetadata => {
|
|||||||
icon: ZendeskIcon,
|
icon: ZendeskIcon,
|
||||||
displayName: "Zendesk",
|
displayName: "Zendesk",
|
||||||
adminPageLink: "/admin/connectors/zendesk",
|
adminPageLink: "/admin/connectors/zendesk",
|
||||||
}
|
};
|
||||||
default:
|
default:
|
||||||
throw new Error("Invalid source type");
|
throw new Error("Invalid source type");
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ export interface GoogleSitesConfig {
|
|||||||
base_url: string;
|
base_url: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ZendeskConfig{}
|
export interface ZendeskConfig {}
|
||||||
|
|
||||||
export interface IndexAttemptSnapshot {
|
export interface IndexAttemptSnapshot {
|
||||||
id: number;
|
id: number;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user