pyxecm 3.0.1__py3-none-any.whl → 3.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pyxecm might be problematic. Click here for more details.
- pyxecm/avts.py +4 -4
- pyxecm/coreshare.py +14 -15
- pyxecm/helper/data.py +2 -1
- pyxecm/helper/web.py +11 -11
- pyxecm/helper/xml.py +41 -10
- pyxecm/otac.py +1 -1
- pyxecm/otawp.py +19 -19
- pyxecm/otca.py +870 -67
- pyxecm/otcs.py +1567 -280
- pyxecm/otds.py +332 -153
- pyxecm/otkd.py +4 -4
- pyxecm/otmm.py +1 -1
- pyxecm/otpd.py +246 -30
- {pyxecm-3.0.1.dist-info → pyxecm-3.1.0.dist-info}/METADATA +2 -1
- pyxecm-3.1.0.dist-info/RECORD +82 -0
- pyxecm_api/app.py +45 -35
- pyxecm_api/auth/functions.py +2 -2
- pyxecm_api/auth/router.py +2 -3
- pyxecm_api/common/functions.py +164 -12
- pyxecm_api/settings.py +0 -8
- pyxecm_api/terminal/router.py +1 -1
- pyxecm_api/v1_csai/router.py +33 -18
- pyxecm_customizer/browser_automation.py +98 -48
- pyxecm_customizer/customizer.py +43 -25
- pyxecm_customizer/guidewire.py +422 -8
- pyxecm_customizer/k8s.py +23 -27
- pyxecm_customizer/knowledge_graph.py +501 -20
- pyxecm_customizer/m365.py +45 -44
- pyxecm_customizer/payload.py +1684 -1159
- pyxecm_customizer/payload_list.py +3 -0
- pyxecm_customizer/salesforce.py +122 -79
- pyxecm_customizer/servicenow.py +27 -7
- pyxecm_customizer/settings.py +3 -1
- pyxecm_customizer/successfactors.py +2 -2
- pyxecm_customizer/translate.py +1 -1
- pyxecm-3.0.1.dist-info/RECORD +0 -96
- pyxecm_api/agents/__init__.py +0 -7
- pyxecm_api/agents/app.py +0 -13
- pyxecm_api/agents/functions.py +0 -119
- pyxecm_api/agents/models.py +0 -10
- pyxecm_api/agents/otcm_knowledgegraph/__init__.py +0 -1
- pyxecm_api/agents/otcm_knowledgegraph/functions.py +0 -85
- pyxecm_api/agents/otcm_knowledgegraph/models.py +0 -61
- pyxecm_api/agents/otcm_knowledgegraph/router.py +0 -74
- pyxecm_api/agents/otcm_user_agent/__init__.py +0 -1
- pyxecm_api/agents/otcm_user_agent/models.py +0 -20
- pyxecm_api/agents/otcm_user_agent/router.py +0 -65
- pyxecm_api/agents/otcm_workspace_agent/__init__.py +0 -1
- pyxecm_api/agents/otcm_workspace_agent/models.py +0 -40
- pyxecm_api/agents/otcm_workspace_agent/router.py +0 -200
- {pyxecm-3.0.1.dist-info → pyxecm-3.1.0.dist-info}/WHEEL +0 -0
- {pyxecm-3.0.1.dist-info → pyxecm-3.1.0.dist-info}/entry_points.txt +0 -0
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
"""Define router for workspace endpoints."""
|
|
2
|
-
|
|
3
|
-
import logging
|
|
4
|
-
from typing import Annotated
|
|
5
|
-
|
|
6
|
-
from fastapi import APIRouter, Body, Depends, HTTPException, status
|
|
7
|
-
from pyxecm.otcs import OTCS
|
|
8
|
-
|
|
9
|
-
from pyxecm_api.agents.models import Context
|
|
10
|
-
from pyxecm_api.common.functions import get_otcs_object_from_otcsticket
|
|
11
|
-
|
|
12
|
-
from .models import WorkspaceModel
|
|
13
|
-
|
|
14
|
-
router = APIRouter(prefix="/otcm_workspace_agent", tags=["csai agents"])
|
|
15
|
-
|
|
16
|
-
logger = logging.getLogger("pyxecm_api.agents.otcm_workspace_agent")
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
@router.post(
|
|
20
|
-
path="/find_workspace",
|
|
21
|
-
response_model=WorkspaceModel,
|
|
22
|
-
summary="Find the markdown link to a workspace by workspace name and workspace type and display the link.",
|
|
23
|
-
responses={
|
|
24
|
-
200: {"description": "Workspace found"},
|
|
25
|
-
403: {"description": "Invalid credentials"},
|
|
26
|
-
404: {"description": "Workspace not found"},
|
|
27
|
-
},
|
|
28
|
-
)
|
|
29
|
-
def otcm_workspace_agent_find_workspace(
|
|
30
|
-
context: Context,
|
|
31
|
-
otcs: Annotated[OTCS, Depends(get_otcs_object_from_otcsticket)],
|
|
32
|
-
workspace: Annotated[WorkspaceModel, Body()],
|
|
33
|
-
) -> WorkspaceModel | None:
|
|
34
|
-
"""Find a workspace by workspace name and workspace type.
|
|
35
|
-
|
|
36
|
-
The returned workspace is an OTCS workspace object. Show the markdown link in the chat response, sothat the user can click on it.
|
|
37
|
-
"""
|
|
38
|
-
|
|
39
|
-
logger.info("Got context -> %s", context)
|
|
40
|
-
|
|
41
|
-
response = otcs.get_workspace_by_type_and_name(type_name=workspace.type, name="contains_" + workspace.name)
|
|
42
|
-
|
|
43
|
-
if response and len(response["results"]) == 1:
|
|
44
|
-
result = WorkspaceModel(
|
|
45
|
-
id=otcs.get_result_value(response=response, key="id"),
|
|
46
|
-
name=otcs.get_result_value(response=response, key="name"),
|
|
47
|
-
type=workspace.type,
|
|
48
|
-
)
|
|
49
|
-
logger.info("Workspace found -> %s", result)
|
|
50
|
-
return result
|
|
51
|
-
|
|
52
|
-
if response is None or not response["results"]:
|
|
53
|
-
response = otcs.search(search_term=workspace.name)
|
|
54
|
-
|
|
55
|
-
if response is None or not response["results"]:
|
|
56
|
-
raise HTTPException(
|
|
57
|
-
status_code=status.HTTP_404_NOT_FOUND,
|
|
58
|
-
detail="Workspace not found.",
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
try:
|
|
62
|
-
return WorkspaceModel(
|
|
63
|
-
id=otcs.get_result_value(response=response, key="id"),
|
|
64
|
-
name=otcs.get_result_value(response=response, key="name"),
|
|
65
|
-
type=workspace.type,
|
|
66
|
-
)
|
|
67
|
-
except Exception as e:
|
|
68
|
-
raise HTTPException(
|
|
69
|
-
status_code=status.HTTP_404_NOT_FOUND,
|
|
70
|
-
detail="Workspace not found.",
|
|
71
|
-
) from e
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
# end function definition
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
@router.post(
|
|
78
|
-
path="/lookup_workspace",
|
|
79
|
-
response_model=WorkspaceModel,
|
|
80
|
-
summary="Lookup a workspace based on its type and a value of one of the workspace attributes.",
|
|
81
|
-
responses={
|
|
82
|
-
200: {"description": "Workspace found"},
|
|
83
|
-
403: {"description": "Invalid credentials"},
|
|
84
|
-
400: {"description": "Workspace not found"},
|
|
85
|
-
},
|
|
86
|
-
)
|
|
87
|
-
def otcm_workspace_agent_lookup_workspace(
|
|
88
|
-
otcs: Annotated[OTCS, Depends(get_otcs_object_from_otcsticket)],
|
|
89
|
-
workspace: Annotated[WorkspaceModel, Body()],
|
|
90
|
-
) -> WorkspaceModel | None:
|
|
91
|
-
"""Lookup a workspace based on its type and a value of one of the workspace attributes.
|
|
92
|
-
|
|
93
|
-
Use this tool if the workspace name is _not_ specified but the user asks for a specific
|
|
94
|
-
workspace attribute value like cities, products, or other attributes.
|
|
95
|
-
|
|
96
|
-
Return the workspace data if it is found. If it is not found confirm with the user if the workspace should be created or not.
|
|
97
|
-
If it should be created call the tool: otcm_workspace_agent_create_workspace
|
|
98
|
-
"""
|
|
99
|
-
|
|
100
|
-
# otcs._otcs_ticket = otcsticket
|
|
101
|
-
|
|
102
|
-
workspace_attributes = workspace.attributes or {}
|
|
103
|
-
if not workspace_attributes:
|
|
104
|
-
raise HTTPException(
|
|
105
|
-
status_code=status.HTTP_400_BAD_REQUEST,
|
|
106
|
-
detail="Workspace attributes must be provided for lookup.",
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
category = next((attr.category for attr in workspace_attributes if attr.category), None)
|
|
110
|
-
attribute = next((attr.attribute for attr in workspace_attributes if attr.attribute), None)
|
|
111
|
-
attribute_set = next((attr.set for attr in workspace_attributes if attr.set), None)
|
|
112
|
-
value = next((attr.value for attr in workspace_attributes if attr.value), None)
|
|
113
|
-
|
|
114
|
-
response = otcs.lookup_workspace(
|
|
115
|
-
type_name=workspace.type, category=category, attribute=attribute, attribute_set=attribute_set, value=value
|
|
116
|
-
)
|
|
117
|
-
if response is None or not response["results"]:
|
|
118
|
-
raise HTTPException(
|
|
119
|
-
status_code=status.HTTP_404_NOT_FOUND,
|
|
120
|
-
detail="No workspace of type -> '{}' with attribute -> '{}'{} and value -> '{}' found!".format(
|
|
121
|
-
workspace.type, attribute, " (set -> {})".format(attribute_set), value
|
|
122
|
-
),
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
try:
|
|
126
|
-
return WorkspaceModel(
|
|
127
|
-
id=otcs.get_result_value(response=response, key="id"),
|
|
128
|
-
name=otcs.get_result_value(response=response, key="name"),
|
|
129
|
-
type=workspace.type,
|
|
130
|
-
)
|
|
131
|
-
except Exception as e:
|
|
132
|
-
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Workspace not found") from e
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
# end function definition
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
@router.post(
|
|
139
|
-
path="/create_workspace",
|
|
140
|
-
response_model=WorkspaceModel,
|
|
141
|
-
summary="Create a workspace with given workspace name and workspace type and display the link.",
|
|
142
|
-
responses={
|
|
143
|
-
200: {"description": "Workspace created"},
|
|
144
|
-
403: {"description": "Invalid credentials"},
|
|
145
|
-
404: {"description": "Workspace creation failed"},
|
|
146
|
-
},
|
|
147
|
-
)
|
|
148
|
-
def otcm_workspace_agent_create_workspace(
|
|
149
|
-
otcs: Annotated[OTCS, Depends(get_otcs_object_from_otcsticket)],
|
|
150
|
-
workspace: Annotated[WorkspaceModel, Body()],
|
|
151
|
-
) -> WorkspaceModel | None:
|
|
152
|
-
"""Create a workspace with given workspace name and workspace type.
|
|
153
|
-
|
|
154
|
-
The ID of the created workspace, the final workspace name, and the workspace type will be returned.
|
|
155
|
-
|
|
156
|
-
"""
|
|
157
|
-
|
|
158
|
-
workspace_type_id, workspace_templates = otcs.get_workspace_templates(type_name=workspace.type)
|
|
159
|
-
if workspace_type_id is None:
|
|
160
|
-
raise HTTPException(
|
|
161
|
-
status_code=status.HTTP_404_NOT_FOUND, detail="Workspace type -> '{}' not found!".format(workspace.type)
|
|
162
|
-
)
|
|
163
|
-
if not workspace_templates:
|
|
164
|
-
raise HTTPException(
|
|
165
|
-
status_code=status.HTTP_404_NOT_FOUND,
|
|
166
|
-
detail="Workspace type -> '{}' has no templates!".format(workspace.type),
|
|
167
|
-
)
|
|
168
|
-
|
|
169
|
-
workspace_template_id = workspace_templates[0].get("id")
|
|
170
|
-
|
|
171
|
-
response = otcs.create_workspace(
|
|
172
|
-
workspace_template_id=workspace_template_id,
|
|
173
|
-
workspace_type=workspace_type_id,
|
|
174
|
-
workspace_name=workspace.name,
|
|
175
|
-
workspace_description="",
|
|
176
|
-
)
|
|
177
|
-
|
|
178
|
-
if response is None or not response["results"]:
|
|
179
|
-
raise HTTPException(
|
|
180
|
-
status_code=status.HTTP_404_NOT_FOUND, detail="Failed to create workspace -> '{}'".format(workspace.name)
|
|
181
|
-
)
|
|
182
|
-
|
|
183
|
-
try:
|
|
184
|
-
workspace_id = response.get("results", {}).get("id")
|
|
185
|
-
|
|
186
|
-
# The resulting workspace name can be different from the given name,
|
|
187
|
-
# so we need to fetch the workspace details again to get the final name.
|
|
188
|
-
response = otcs.get_workspace(node_id=workspace_id)
|
|
189
|
-
workspace_name = otcs.get_result_value(response=response, key="name")
|
|
190
|
-
|
|
191
|
-
return WorkspaceModel(
|
|
192
|
-
id=workspace_id,
|
|
193
|
-
name=workspace_name,
|
|
194
|
-
type=workspace.type,
|
|
195
|
-
)
|
|
196
|
-
except Exception as e:
|
|
197
|
-
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Workspace not found") from e
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
# end function definition
|
|
File without changes
|
|
File without changes
|