uipath-langchain 0.0.94__py3-none-any.whl → 0.0.95__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 uipath-langchain might be problematic. Click here for more details.
- uipath_langchain/_cli/_templates/langgraph.json.template +7 -0
- uipath_langchain/_cli/_templates/main.py.template +33 -0
- uipath_langchain/_cli/cli_new.py +76 -0
- uipath_langchain/middlewares.py +2 -0
- {uipath_langchain-0.0.94.dist-info → uipath_langchain-0.0.95.dist-info}/METADATA +1 -1
- {uipath_langchain-0.0.94.dist-info → uipath_langchain-0.0.95.dist-info}/RECORD +9 -6
- {uipath_langchain-0.0.94.dist-info → uipath_langchain-0.0.95.dist-info}/WHEEL +0 -0
- {uipath_langchain-0.0.94.dist-info → uipath_langchain-0.0.95.dist-info}/entry_points.txt +0 -0
- {uipath_langchain-0.0.94.dist-info → uipath_langchain-0.0.95.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from langchain_anthropic import ChatAnthropic
|
|
2
|
+
from langchain_core.messages import HumanMessage, SystemMessage
|
|
3
|
+
from langchain_openai import ChatOpenAI
|
|
4
|
+
from langgraph.graph import START, StateGraph, END
|
|
5
|
+
from pydantic import BaseModel
|
|
6
|
+
import os
|
|
7
|
+
|
|
8
|
+
class GraphInput(BaseModel):
|
|
9
|
+
topic: str
|
|
10
|
+
|
|
11
|
+
class GraphOutput(BaseModel):
|
|
12
|
+
report: str
|
|
13
|
+
|
|
14
|
+
async def generate_report(state: GraphInput) -> GraphOutput:
|
|
15
|
+
if os.getenv("ANTHROPIC_API_KEY"):
|
|
16
|
+
llm_model = ChatAnthropic(model="claude-3-5-sonnet-latest")
|
|
17
|
+
elif os.getenv("OPENAI_API_KEY"):
|
|
18
|
+
llm_model = ChatOpenAI(model="gpt-4o-mini", temperature=0)
|
|
19
|
+
else:
|
|
20
|
+
raise Exception("Error: Missing API Key. Please define either ANTHROPIC_API_KEY or OPENAI_API_KEY.")
|
|
21
|
+
|
|
22
|
+
system_prompt = "You are a report generator. Please provide a brief report based on the given topic."
|
|
23
|
+
output = await llm_model.ainvoke([SystemMessage(system_prompt), HumanMessage(state.topic)])
|
|
24
|
+
return GraphOutput(report=output.content)
|
|
25
|
+
|
|
26
|
+
builder = StateGraph(input=GraphInput, output=GraphOutput)
|
|
27
|
+
|
|
28
|
+
builder.add_node("generate_report", generate_report)
|
|
29
|
+
|
|
30
|
+
builder.add_edge(START, "generate_report")
|
|
31
|
+
builder.add_edge("generate_report", END)
|
|
32
|
+
|
|
33
|
+
graph = builder.compile()
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import shutil
|
|
3
|
+
|
|
4
|
+
import click
|
|
5
|
+
from uipath._cli.middlewares import MiddlewareResult
|
|
6
|
+
from uipath._cli.spinner import Spinner
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def generate_script(target_directory):
|
|
10
|
+
template_script_path = os.path.join(
|
|
11
|
+
os.path.dirname(__file__), "_templates/main.py.template"
|
|
12
|
+
)
|
|
13
|
+
target_path = os.path.join(target_directory, "main.py")
|
|
14
|
+
|
|
15
|
+
shutil.copyfile(template_script_path, target_path)
|
|
16
|
+
|
|
17
|
+
template_langgraph_json_path = os.path.join(
|
|
18
|
+
os.path.dirname(__file__), "_templates/langgraph.json.template"
|
|
19
|
+
)
|
|
20
|
+
target_path = os.path.join(target_directory, "langgraph.json")
|
|
21
|
+
shutil.copyfile(template_langgraph_json_path, target_path)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def generate_pyproject(target_directory, project_name):
|
|
25
|
+
project_toml_path = os.path.join(target_directory, "pyproject.toml")
|
|
26
|
+
toml_content = f"""[project]
|
|
27
|
+
name = "{project_name}"
|
|
28
|
+
version = "0.0.1"
|
|
29
|
+
description = "{project_name}"
|
|
30
|
+
authors = [{{ name = "John Doe", email = "john.doe@myemail.com" }}]
|
|
31
|
+
dependencies = [
|
|
32
|
+
"uipath-langchain>=0.0.95",
|
|
33
|
+
"langchain-anthropic>=0.3.8",
|
|
34
|
+
]
|
|
35
|
+
requires-python = ">=3.10"
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
with open(project_toml_path, "w") as f:
|
|
39
|
+
f.write(toml_content)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def langgraph_new_middleware(name: str) -> MiddlewareResult:
|
|
43
|
+
"""Middleware to create demo langchain agent"""
|
|
44
|
+
spinner = Spinner("Creating demo agent...")
|
|
45
|
+
directory = os.getcwd()
|
|
46
|
+
|
|
47
|
+
try:
|
|
48
|
+
generate_script(directory)
|
|
49
|
+
click.echo(click.style("✓ ", fg="green", bold=True) + "Created main.py file")
|
|
50
|
+
click.echo(
|
|
51
|
+
click.style("✓ ", fg="green", bold=True) + "Created langgraph.json file"
|
|
52
|
+
)
|
|
53
|
+
generate_pyproject(directory, name)
|
|
54
|
+
click.echo(
|
|
55
|
+
click.style("✓ ", fg="green", bold=True) + "Created pyproject.toml file"
|
|
56
|
+
)
|
|
57
|
+
os.system("uv sync")
|
|
58
|
+
spinner.start()
|
|
59
|
+
ctx = click.get_current_context()
|
|
60
|
+
init_cmd = ctx.parent.command.get_command(ctx, "init") # type: ignore
|
|
61
|
+
ctx.invoke(init_cmd)
|
|
62
|
+
spinner.stop()
|
|
63
|
+
click.echo(
|
|
64
|
+
click.style("✓ ", fg="green", bold=True) + " Agent created successfully."
|
|
65
|
+
)
|
|
66
|
+
return MiddlewareResult(
|
|
67
|
+
should_continue=False,
|
|
68
|
+
info_message="""Usage example: ` uipath run agent '{"topic": "UiPath"}' `""",
|
|
69
|
+
)
|
|
70
|
+
except Exception as e:
|
|
71
|
+
spinner.stop()
|
|
72
|
+
return MiddlewareResult(
|
|
73
|
+
should_continue=False,
|
|
74
|
+
error_message=f"❌ Error creating demo agent {str(e)}",
|
|
75
|
+
should_include_stacktrace=True,
|
|
76
|
+
)
|
uipath_langchain/middlewares.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from uipath._cli.middlewares import Middlewares
|
|
2
2
|
|
|
3
3
|
from ._cli.cli_init import langgraph_init_middleware
|
|
4
|
+
from ._cli.cli_new import langgraph_new_middleware
|
|
4
5
|
from ._cli.cli_run import langgraph_run_middleware
|
|
5
6
|
|
|
6
7
|
|
|
@@ -8,3 +9,4 @@ def register_middleware():
|
|
|
8
9
|
"""This function will be called by the entry point system when uipath_langchain is installed"""
|
|
9
10
|
Middlewares.register("init", langgraph_init_middleware)
|
|
10
11
|
Middlewares.register("run", langgraph_run_middleware)
|
|
12
|
+
Middlewares.register("new", langgraph_new_middleware)
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
uipath_langchain/__init__.py,sha256=VBrvQn7d3nuOdN7zEnV2_S-uhmkjgEIlXiFVeZxZakQ,80
|
|
2
|
-
uipath_langchain/middlewares.py,sha256=
|
|
2
|
+
uipath_langchain/middlewares.py,sha256=tre7o9DFMgWk1DJiEEUmT6_wiP-PPkWtKmG0iOyvr9c,509
|
|
3
3
|
uipath_langchain/_cli/__init__.py,sha256=juqd9PbXs4yg45zMJ7BHAOPQjb7sgEbWE9InBtGZhfo,24
|
|
4
4
|
uipath_langchain/_cli/cli_init.py,sha256=PKkebO0P4Qh1N-LAx_HdypbffbGq5_JSquJY1OMsK6E,7700
|
|
5
|
+
uipath_langchain/_cli/cli_new.py,sha256=JjnDbns8ok2Bj2M6Tg-FKOfm1YxpTIq6ReLeCAl6vKM,2745
|
|
5
6
|
uipath_langchain/_cli/cli_run.py,sha256=zMn2P1gB1ogM8_EmZsIhqNpeI9Oc02Z5Gj-oni7eUV4,2915
|
|
6
7
|
uipath_langchain/_cli/_runtime/_context.py,sha256=wr4aNn06ReIXmetEZ6b6AnpAt64p13anQ2trZ5Bzgio,807
|
|
7
8
|
uipath_langchain/_cli/_runtime/_escalation.py,sha256=oA5NvZvCo8ngELFJRyhZNM69DxVHrshhMY6CUk_cukQ,8055
|
|
@@ -9,6 +10,8 @@ uipath_langchain/_cli/_runtime/_exception.py,sha256=USKkLYkG-dzjX3fEiMMOHnVUpiXJ
|
|
|
9
10
|
uipath_langchain/_cli/_runtime/_input.py,sha256=gKzPaGW-EzgeAskWJjbCWnfZRLu_BM7lCXkq0XkVGLU,5614
|
|
10
11
|
uipath_langchain/_cli/_runtime/_output.py,sha256=WQSrsvGaaclZ6GLWEh6Nk1Mz1iGaIB45PgIX3DS3AN4,16130
|
|
11
12
|
uipath_langchain/_cli/_runtime/_runtime.py,sha256=wj6e6tQdP2GjuSM-6G6Ug-FMqwOHwfUq-DGbd1gMfIg,11825
|
|
13
|
+
uipath_langchain/_cli/_templates/langgraph.json.template,sha256=eeh391Gta_hoRgaNaZ58nW1LNvCVXA7hlAH6l7Veous,107
|
|
14
|
+
uipath_langchain/_cli/_templates/main.py.template,sha256=FQIldd8PKYAxL9oAS6Y1CB0mKtY4LroXdYW8Hg_ZnHo,1202
|
|
12
15
|
uipath_langchain/_cli/_utils/_graph.py,sha256=WLBSJfPc3_C07SqJhePRe17JIc5wcBvEqLviMcNOdTA,6950
|
|
13
16
|
uipath_langchain/_utils/__init__.py,sha256=WoY66enCygRXTh6v5B1UrRcFCnQYuPJ8oqDkwomXzLc,194
|
|
14
17
|
uipath_langchain/_utils/_request_mixin.py,sha256=t_1HWBxqEl-wsSk9ubmIM-8vs9BlNy4ZVBxtDxktn6U,18489
|
|
@@ -33,8 +36,8 @@ uipath_langchain/utils/_request_mixin.py,sha256=WFyTDyAthSci1DRwUwS21I3hLntD7HdV
|
|
|
33
36
|
uipath_langchain/utils/_settings.py,sha256=MhwEVj4gVRSar0RBf2w2hTjO-5Qm-HpCuufqN3gSWjA,3390
|
|
34
37
|
uipath_langchain/utils/_sleep_policy.py,sha256=e9pHdjmcCj4CVoFM1jMyZFelH11YatsgWfpyrfXzKBQ,1251
|
|
35
38
|
uipath_langchain/vectorstores/context_grounding_vectorstore.py,sha256=eTa5sX43-ydB1pj9VNHUPbB-hC36fZK_CGrNe5U2Nrw,9393
|
|
36
|
-
uipath_langchain-0.0.
|
|
37
|
-
uipath_langchain-0.0.
|
|
38
|
-
uipath_langchain-0.0.
|
|
39
|
-
uipath_langchain-0.0.
|
|
40
|
-
uipath_langchain-0.0.
|
|
39
|
+
uipath_langchain-0.0.95.dist-info/METADATA,sha256=WZEMEDLVkErrg3hoVdG8qdcT97yNSYvWtQO17CK2IHs,3819
|
|
40
|
+
uipath_langchain-0.0.95.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
41
|
+
uipath_langchain-0.0.95.dist-info/entry_points.txt,sha256=FUtzqGOEntlJKMJIXhQUfT7ZTbQmGhke1iCmDWZaQZI,81
|
|
42
|
+
uipath_langchain-0.0.95.dist-info/licenses/LICENSE,sha256=JDpt-uotAkHFmxpwxi6gwx6HQ25e-lG4U_Gzcvgp7JY,1063
|
|
43
|
+
uipath_langchain-0.0.95.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|