langgraph-api 0.0.1__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 langgraph-api might be problematic. Click here for more details.

Files changed (86) hide show
  1. LICENSE +93 -0
  2. langgraph_api/__init__.py +0 -0
  3. langgraph_api/api/__init__.py +63 -0
  4. langgraph_api/api/assistants.py +326 -0
  5. langgraph_api/api/meta.py +71 -0
  6. langgraph_api/api/openapi.py +32 -0
  7. langgraph_api/api/runs.py +463 -0
  8. langgraph_api/api/store.py +116 -0
  9. langgraph_api/api/threads.py +263 -0
  10. langgraph_api/asyncio.py +201 -0
  11. langgraph_api/auth/__init__.py +0 -0
  12. langgraph_api/auth/langsmith/__init__.py +0 -0
  13. langgraph_api/auth/langsmith/backend.py +67 -0
  14. langgraph_api/auth/langsmith/client.py +145 -0
  15. langgraph_api/auth/middleware.py +41 -0
  16. langgraph_api/auth/noop.py +14 -0
  17. langgraph_api/cli.py +209 -0
  18. langgraph_api/config.py +70 -0
  19. langgraph_api/cron_scheduler.py +60 -0
  20. langgraph_api/errors.py +52 -0
  21. langgraph_api/graph.py +314 -0
  22. langgraph_api/http.py +168 -0
  23. langgraph_api/http_logger.py +89 -0
  24. langgraph_api/js/.gitignore +2 -0
  25. langgraph_api/js/build.mts +49 -0
  26. langgraph_api/js/client.mts +849 -0
  27. langgraph_api/js/global.d.ts +6 -0
  28. langgraph_api/js/package.json +33 -0
  29. langgraph_api/js/remote.py +673 -0
  30. langgraph_api/js/server_sent_events.py +126 -0
  31. langgraph_api/js/src/graph.mts +88 -0
  32. langgraph_api/js/src/hooks.mjs +12 -0
  33. langgraph_api/js/src/parser/parser.mts +443 -0
  34. langgraph_api/js/src/parser/parser.worker.mjs +12 -0
  35. langgraph_api/js/src/schema/types.mts +2136 -0
  36. langgraph_api/js/src/schema/types.template.mts +74 -0
  37. langgraph_api/js/src/utils/importMap.mts +85 -0
  38. langgraph_api/js/src/utils/pythonSchemas.mts +28 -0
  39. langgraph_api/js/src/utils/serde.mts +21 -0
  40. langgraph_api/js/tests/api.test.mts +1566 -0
  41. langgraph_api/js/tests/compose-postgres.yml +56 -0
  42. langgraph_api/js/tests/graphs/.gitignore +1 -0
  43. langgraph_api/js/tests/graphs/agent.mts +127 -0
  44. langgraph_api/js/tests/graphs/error.mts +17 -0
  45. langgraph_api/js/tests/graphs/langgraph.json +8 -0
  46. langgraph_api/js/tests/graphs/nested.mts +44 -0
  47. langgraph_api/js/tests/graphs/package.json +7 -0
  48. langgraph_api/js/tests/graphs/weather.mts +57 -0
  49. langgraph_api/js/tests/graphs/yarn.lock +159 -0
  50. langgraph_api/js/tests/parser.test.mts +870 -0
  51. langgraph_api/js/tests/utils.mts +17 -0
  52. langgraph_api/js/yarn.lock +1340 -0
  53. langgraph_api/lifespan.py +41 -0
  54. langgraph_api/logging.py +121 -0
  55. langgraph_api/metadata.py +101 -0
  56. langgraph_api/models/__init__.py +0 -0
  57. langgraph_api/models/run.py +229 -0
  58. langgraph_api/patch.py +42 -0
  59. langgraph_api/queue.py +245 -0
  60. langgraph_api/route.py +118 -0
  61. langgraph_api/schema.py +190 -0
  62. langgraph_api/serde.py +124 -0
  63. langgraph_api/server.py +48 -0
  64. langgraph_api/sse.py +118 -0
  65. langgraph_api/state.py +67 -0
  66. langgraph_api/stream.py +289 -0
  67. langgraph_api/utils.py +60 -0
  68. langgraph_api/validation.py +141 -0
  69. langgraph_api-0.0.1.dist-info/LICENSE +93 -0
  70. langgraph_api-0.0.1.dist-info/METADATA +26 -0
  71. langgraph_api-0.0.1.dist-info/RECORD +86 -0
  72. langgraph_api-0.0.1.dist-info/WHEEL +4 -0
  73. langgraph_api-0.0.1.dist-info/entry_points.txt +3 -0
  74. langgraph_license/__init__.py +0 -0
  75. langgraph_license/middleware.py +21 -0
  76. langgraph_license/validation.py +11 -0
  77. langgraph_storage/__init__.py +0 -0
  78. langgraph_storage/checkpoint.py +94 -0
  79. langgraph_storage/database.py +190 -0
  80. langgraph_storage/ops.py +1523 -0
  81. langgraph_storage/queue.py +108 -0
  82. langgraph_storage/retry.py +27 -0
  83. langgraph_storage/store.py +28 -0
  84. langgraph_storage/ttl_dict.py +54 -0
  85. logging.json +22 -0
  86. openapi.json +4304 -0
@@ -0,0 +1,74 @@
1
+ import type { BaseMessage } from "@langchain/core/messages";
2
+ import type {
3
+ StateType,
4
+ UpdateType,
5
+ StateDefinition,
6
+ } from "@langchain/langgraph";
7
+ import type { Graph } from "@langchain/langgraph";
8
+ import type { Pregel } from "@langchain/langgraph/pregel";
9
+
10
+ type AnyPregel = Pregel<any, any>;
11
+ type AnyGraph = Graph<any, any, any, any, any>;
12
+
13
+ type Wrap<T> = (a: T) => void;
14
+ type MatchBaseMessage<T> = T extends BaseMessage ? BaseMessage : never;
15
+ type MatchBaseMessageArray<T> =
16
+ T extends Array<infer C>
17
+ ? Wrap<MatchBaseMessage<C>> extends Wrap<BaseMessage>
18
+ ? BaseMessage[]
19
+ : never
20
+ : never;
21
+
22
+ type Defactorify<T> = T extends (...args: any[]) => infer R
23
+ ? Awaited<R>
24
+ : Awaited<T>;
25
+
26
+ type Inspect<T> = T extends unknown
27
+ ? {
28
+ [K in keyof T]: 0 extends 1 & T[K]
29
+ ? T[K]
30
+ : Wrap<MatchBaseMessageArray<T[K]>> extends Wrap<BaseMessage[]>
31
+ ? BaseMessage[]
32
+ : Wrap<MatchBaseMessage<T[K]>> extends Wrap<BaseMessage>
33
+ ? BaseMessage
34
+ : Inspect<T[K]>;
35
+ }
36
+ : never;
37
+
38
+ type ReflectCompiled<T> = T extends { RunInput: infer S; RunOutput: infer U }
39
+ ? { state: S; update: U }
40
+ : never;
41
+
42
+ type Reflect<T> =
43
+ Defactorify<T> extends infer DT
44
+ ? DT extends {
45
+ compile(...args: any[]): infer Compiled;
46
+ }
47
+ ? ReflectCompiled<Compiled>
48
+ : ReflectCompiled<DT>
49
+ : never;
50
+
51
+ type BuilderReflectCompiled<T> = T extends {
52
+ builder: {
53
+ _inputDefinition: infer I extends StateDefinition;
54
+ _outputDefinition: infer O extends StateDefinition;
55
+ _configSchema?: infer C extends StateDefinition | undefined;
56
+ };
57
+ }
58
+ ? {
59
+ input: UpdateType<I>;
60
+ output: StateType<O>;
61
+ config: UpdateType<Exclude<C, undefined>>;
62
+ }
63
+ : never;
64
+
65
+ type BuilderReflect<T> =
66
+ Defactorify<T> extends infer DT
67
+ ? DT extends {
68
+ compile(...args: any[]): infer Compiled;
69
+ }
70
+ ? BuilderReflectCompiled<Compiled>
71
+ : BuilderReflectCompiled<DT>
72
+ : never;
73
+
74
+ type FilterAny<T> = 0 extends 1 & T ? never : T;
@@ -0,0 +1,85 @@
1
+ import {
2
+ PromptTemplate,
3
+ AIMessagePromptTemplate,
4
+ ChatMessagePromptTemplate,
5
+ ChatPromptTemplate,
6
+ HumanMessagePromptTemplate,
7
+ MessagesPlaceholder,
8
+ SystemMessagePromptTemplate,
9
+ ImagePromptTemplate,
10
+ PipelinePromptTemplate,
11
+ } from "@langchain/core/prompts";
12
+ import {
13
+ AIMessage,
14
+ AIMessageChunk,
15
+ BaseMessage,
16
+ BaseMessageChunk,
17
+ ChatMessage,
18
+ ChatMessageChunk,
19
+ FunctionMessage,
20
+ FunctionMessageChunk,
21
+ HumanMessage,
22
+ HumanMessageChunk,
23
+ SystemMessage,
24
+ SystemMessageChunk,
25
+ ToolMessage,
26
+ ToolMessageChunk,
27
+ } from "@langchain/core/messages";
28
+ import { StringPromptValue } from "@langchain/core/prompt_values";
29
+
30
+ export const prompts__prompt = {
31
+ PromptTemplate,
32
+ };
33
+
34
+ export const schema__messages = {
35
+ AIMessage,
36
+ AIMessageChunk,
37
+ BaseMessage,
38
+ BaseMessageChunk,
39
+ ChatMessage,
40
+ ChatMessageChunk,
41
+ FunctionMessage,
42
+ FunctionMessageChunk,
43
+ HumanMessage,
44
+ HumanMessageChunk,
45
+ SystemMessage,
46
+ SystemMessageChunk,
47
+ ToolMessage,
48
+ ToolMessageChunk,
49
+ };
50
+
51
+ export const schema = {
52
+ AIMessage,
53
+ AIMessageChunk,
54
+ BaseMessage,
55
+ BaseMessageChunk,
56
+ ChatMessage,
57
+ ChatMessageChunk,
58
+ FunctionMessage,
59
+ FunctionMessageChunk,
60
+ HumanMessage,
61
+ HumanMessageChunk,
62
+ SystemMessage,
63
+ SystemMessageChunk,
64
+ ToolMessage,
65
+ ToolMessageChunk,
66
+ };
67
+
68
+ export const prompts__chat = {
69
+ AIMessagePromptTemplate,
70
+ ChatMessagePromptTemplate,
71
+ ChatPromptTemplate,
72
+ HumanMessagePromptTemplate,
73
+ MessagesPlaceholder,
74
+ SystemMessagePromptTemplate,
75
+ };
76
+ export const prompts__image = {
77
+ ImagePromptTemplate,
78
+ };
79
+ export const prompts__pipeline = {
80
+ PipelinePromptTemplate,
81
+ };
82
+
83
+ export const prompts__base = {
84
+ StringPromptValue,
85
+ };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Represents a stored item with metadata.
3
+ */
4
+ export interface PyItem {
5
+ /**
6
+ * The stored data as an object. Keys are filterable.
7
+ */
8
+ value: Record<string, any>;
9
+ /**
10
+ * Unique identifier within the namespace.
11
+ */
12
+ key: string;
13
+ /**
14
+ * Hierarchical path defining the collection in which this document resides.
15
+ * Represented as an array of strings, allowing for nested categorization.
16
+ * For example: ["documents", "user123"]
17
+ */
18
+ namespace: string[];
19
+ /**
20
+ * Timestamp of item creation.
21
+ */
22
+ created_at: Date;
23
+ /**
24
+ * Timestamp of last update.
25
+ */
26
+ updated_at: Date;
27
+ }
28
+ export type PyResult = PyItem | PyItem[] | string[][] | null | undefined;
@@ -0,0 +1,21 @@
1
+ export const serialiseAsDict = (obj: unknown) => {
2
+ return JSON.stringify(
3
+ obj,
4
+ function (key: string | number, value: unknown) {
5
+ const rawValue = this[key];
6
+ if (
7
+ rawValue != null &&
8
+ typeof rawValue === "object" &&
9
+ "toDict" in rawValue &&
10
+ typeof rawValue.toDict === "function"
11
+ ) {
12
+ // TODO: we need to upstream this to LangChainJS
13
+ const { type, data } = rawValue.toDict();
14
+ return { ...data, type };
15
+ }
16
+
17
+ return value;
18
+ },
19
+ 2
20
+ );
21
+ };