mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-05-28 12:39:54 +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 SlackPollConnector
|
||||
from danswer.connectors.web.connector import WebConnector
|
||||
from danswer.connectors.zulip.connector import ZulipConnector
|
||||
from danswer.connectors.zendesk.connector import ZendeskConnector
|
||||
from danswer.connectors.zulip.connector import ZulipConnector
|
||||
|
||||
|
||||
class ConnectorMissingException(Exception):
|
||||
|
@ -1,27 +1,28 @@
|
||||
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.constants import DocumentSource
|
||||
from danswer.connectors.models import Document, Section
|
||||
from danswer.connectors.interfaces import GenerateDocumentsOutput, LoadConnector, PollConnector, SecondsSinceUnixEpoch
|
||||
from danswer.connectors.interfaces import GenerateDocumentsOutput
|
||||
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):
|
||||
def __init__(self) -> None:
|
||||
super().__init__(
|
||||
"Zendesk Client is not set up, was load_credentials called?"
|
||||
)
|
||||
super().__init__("Zendesk Client is not set up, was load_credentials called?")
|
||||
|
||||
|
||||
class ZendeskConnector(LoadConnector, PollConnector):
|
||||
def __init__(
|
||||
self,
|
||||
batch_size: int = INDEX_BATCH_SIZE
|
||||
) -> None:
|
||||
def __init__(self, batch_size: int = INDEX_BATCH_SIZE) -> None:
|
||||
self.batch_size = batch_size
|
||||
self.zendesk_client: Zenpy | None = None
|
||||
|
||||
|
||||
def load_credentials(self, credentials: dict[str, Any]) -> dict[str, Any] | None:
|
||||
self.zendesk_client = Zenpy(
|
||||
subdomain=credentials["zendesk_subdomain"],
|
||||
@ -29,10 +30,10 @@ class ZendeskConnector(LoadConnector, PollConnector):
|
||||
token=credentials["zendesk_token"],
|
||||
)
|
||||
return None
|
||||
|
||||
|
||||
def load_from_state(self) -> GenerateDocumentsOutput:
|
||||
return self.poll_source(None, None)
|
||||
|
||||
|
||||
def _article_to_document(self, article: Article) -> Document:
|
||||
return Document(
|
||||
id=f"article:{article.id}",
|
||||
@ -42,15 +43,22 @@ class ZendeskConnector(LoadConnector, PollConnector):
|
||||
metadata={
|
||||
"type": "article",
|
||||
"updated_at": article.updated_at,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def poll_source(self, start: SecondsSinceUnixEpoch | None, end: SecondsSinceUnixEpoch | None) -> GenerateDocumentsOutput:
|
||||
def poll_source(
|
||||
self, start: SecondsSinceUnixEpoch | None, end: SecondsSinceUnixEpoch | None
|
||||
) -> GenerateDocumentsOutput:
|
||||
if self.zendesk_client is None:
|
||||
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 = []
|
||||
for article in articles:
|
||||
if article.body is None:
|
||||
@ -60,4 +68,3 @@ class ZendeskConnector(LoadConnector, PollConnector):
|
||||
if len(doc_batch) >= self.batch_size:
|
||||
yield doc_batch
|
||||
doc_batch.clear()
|
||||
|
||||
|
@ -1,15 +1,16 @@
|
||||
# This file is purely for development use, not included in any builds
|
||||
import requests
|
||||
import os
|
||||
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__)))
|
||||
sys.path.append(parent_dir)
|
||||
|
||||
|
||||
from danswer.configs.app_configs import DOCUMENT_INDEX_NAME
|
||||
from danswer.document_index.vespa.index import DOCUMENT_ID_ENDPOINT
|
||||
from danswer.utils.logger import setup_logger
|
||||
from danswer.configs.app_configs import DOCUMENT_INDEX_NAME # noqa: E402
|
||||
from danswer.document_index.vespa.index import DOCUMENT_ID_ENDPOINT # noqa: E402
|
||||
from danswer.utils.logger import setup_logger # noqa: E402
|
||||
|
||||
logger = setup_logger()
|
||||
|
||||
|
@ -1,17 +1,18 @@
|
||||
import psycopg2
|
||||
|
||||
import os
|
||||
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__)))
|
||||
sys.path.append(parent_dir)
|
||||
|
||||
from danswer.configs.app_configs import POSTGRES_DB
|
||||
from danswer.configs.app_configs import POSTGRES_HOST
|
||||
from danswer.configs.app_configs import POSTGRES_PASSWORD
|
||||
from danswer.configs.app_configs import POSTGRES_PORT
|
||||
from danswer.configs.app_configs import POSTGRES_USER
|
||||
from danswer.db.credentials import create_initial_public_credential
|
||||
from danswer.configs.app_configs import POSTGRES_DB # noqa: E402
|
||||
from danswer.configs.app_configs import POSTGRES_HOST # noqa: E402
|
||||
from danswer.configs.app_configs import POSTGRES_PASSWORD # noqa: E402
|
||||
from danswer.configs.app_configs import POSTGRES_PORT # noqa: E402
|
||||
from danswer.configs.app_configs import POSTGRES_USER # noqa: E402
|
||||
from danswer.db.credentials import create_initial_public_credential # noqa: E402
|
||||
|
||||
|
||||
def wipe_all_rows(database: str) -> None:
|
||||
|
@ -103,12 +103,13 @@ const Main = () => {
|
||||
<>
|
||||
<p className="text-sm">
|
||||
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
|
||||
(e.g. https://<subdomain>.zendesk.com/admin/). Proceed to the "Apps and
|
||||
Integrations" section and "Zendesk API" page. Add a new API token and provide
|
||||
it with a name. You will also need to provide the e-mail address of a user that
|
||||
the system will impersonate. This is of little consequence as we are only performing
|
||||
read actions.
|
||||
instance. You can generate this by access the Admin Center of your
|
||||
instance (e.g. https://<subdomain>.zendesk.com/admin/).
|
||||
Proceed to the "Apps and Integrations" section and
|
||||
"Zendesk API" page. Add a new API token and provide it
|
||||
with a name. You will also need to provide the e-mail address of a
|
||||
user that the system will impersonate. This is of little consequence
|
||||
as we are only performing read actions.
|
||||
</p>
|
||||
<div className="border-solid border-gray-600 border rounded-md p-6 mt-2 mb-4">
|
||||
<CredentialForm<ZendeskCredentialJson>
|
||||
@ -189,29 +190,28 @@ const Main = () => {
|
||||
</>
|
||||
)}
|
||||
|
||||
{zendeskCredential &&
|
||||
zendeskConnectorIndexingStatuses.length === 0 && (
|
||||
<>
|
||||
<div className="border-solid border-gray-600 border rounded-md p-6 mt-4">
|
||||
<h2 className="font-bold mb-3">Create Connection</h2>
|
||||
<p className="text-sm mb-4">
|
||||
Press connect below to start the connection to your Zendesk
|
||||
instance.
|
||||
</p>
|
||||
<ConnectorForm<ZendeskConfig>
|
||||
nameBuilder={(values) => `ZendeskConnector`}
|
||||
ccPairNameBuilder={(values) => `ZendeskConnector`}
|
||||
source="zendesk"
|
||||
inputType="poll"
|
||||
formBody={<></>}
|
||||
validationSchema={Yup.object().shape({})}
|
||||
initialValues={{}}
|
||||
refreshFreq={10 * 60} // 10 minutes
|
||||
credentialId={zendeskCredential.id}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{zendeskCredential && zendeskConnectorIndexingStatuses.length === 0 && (
|
||||
<>
|
||||
<div className="border-solid border-gray-600 border rounded-md p-6 mt-4">
|
||||
<h2 className="font-bold mb-3">Create Connection</h2>
|
||||
<p className="text-sm mb-4">
|
||||
Press connect below to start the connection to your Zendesk
|
||||
instance.
|
||||
</p>
|
||||
<ConnectorForm<ZendeskConfig>
|
||||
nameBuilder={(values) => `ZendeskConnector`}
|
||||
ccPairNameBuilder={(values) => `ZendeskConnector`}
|
||||
source="zendesk"
|
||||
inputType="poll"
|
||||
formBody={<></>}
|
||||
validationSchema={Yup.object().shape({})}
|
||||
initialValues={{}}
|
||||
refreshFreq={10 * 60} // 10 minutes
|
||||
credentialId={zendeskCredential.id}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{!zendeskCredential && (
|
||||
<>
|
||||
|
@ -26,7 +26,7 @@ import {
|
||||
GoogleSitesIcon,
|
||||
GongIcon,
|
||||
ZoomInIcon,
|
||||
ZendeskIcon
|
||||
ZendeskIcon,
|
||||
} from "@/components/icons/icons";
|
||||
import { getAuthDisabledSS, getCurrentUserSS } from "@/lib/userSS";
|
||||
import { redirect } from "next/navigation";
|
||||
@ -240,7 +240,7 @@ export async function Layout({ children }: { children: React.ReactNode }) {
|
||||
</div>
|
||||
),
|
||||
link: "/admin/connectors/zendesk",
|
||||
}
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
@ -492,4 +492,4 @@ export const ZendeskIcon = ({
|
||||
>
|
||||
<Image src={zendeskIcon} alt="Logo" width="96" height="96" />
|
||||
</div>
|
||||
);
|
||||
);
|
||||
|
@ -142,7 +142,7 @@ export const getSourceMetadata = (sourceType: ValidSources): SourceMetadata => {
|
||||
icon: ZendeskIcon,
|
||||
displayName: "Zendesk",
|
||||
adminPageLink: "/admin/connectors/zendesk",
|
||||
}
|
||||
};
|
||||
default:
|
||||
throw new Error("Invalid source type");
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ export interface GoogleSitesConfig {
|
||||
base_url: string;
|
||||
}
|
||||
|
||||
export interface ZendeskConfig{}
|
||||
export interface ZendeskConfig {}
|
||||
|
||||
export interface IndexAttemptSnapshot {
|
||||
id: number;
|
||||
|
Loading…
x
Reference in New Issue
Block a user