morphik 0.2.2__tar.gz → 0.2.4__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: morphik
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: Morphik Python Client
5
5
  Author-email: Morphik <founders@morphik.ai>
6
6
  Requires-Python: >=3.8
@@ -12,4 +12,4 @@ __all__ = [
12
12
  "Document",
13
13
  ]
14
14
 
15
- __version__ = "0.2.2"
15
+ __version__ = "0.2.4"
@@ -253,6 +253,7 @@ class _MorphikClientLogic:
253
253
  end_user_id: Optional[str],
254
254
  chat_id: Optional[str] = None,
255
255
  schema: Optional[Union[Type[BaseModel], Dict[str, Any]]] = None,
256
+ llm_config: Optional[Dict[str, Any]] = None,
256
257
  ) -> Dict[str, Any]:
257
258
  """Prepare request for query endpoint"""
258
259
  payload = {
@@ -274,6 +275,8 @@ class _MorphikClientLogic:
274
275
  payload["end_user_id"] = end_user_id
275
276
  if chat_id:
276
277
  payload["chat_id"] = chat_id
278
+ if llm_config:
279
+ payload["llm_config"] = llm_config
277
280
 
278
281
  # Add schema to payload if provided
279
282
  if schema:
@@ -356,6 +356,7 @@ class AsyncFolder:
356
356
  additional_folders: Optional[List[str]] = None,
357
357
  schema: Optional[Union[Type[BaseModel], Dict[str, Any]]] = None,
358
358
  chat_id: Optional[str] = None,
359
+ llm_config: Optional[Dict[str, Any]] = None,
359
360
  ) -> CompletionResponse:
360
361
  """
361
362
  Generate completion using relevant chunks as context within this folder.
@@ -395,6 +396,7 @@ class AsyncFolder:
395
396
  None,
396
397
  chat_id,
397
398
  schema,
399
+ llm_config,
398
400
  )
399
401
 
400
402
  # Add schema to payload if provided
@@ -892,6 +894,7 @@ class AsyncUserScope:
892
894
  additional_folders: Optional[List[str]] = None,
893
895
  schema: Optional[Union[Type[BaseModel], Dict[str, Any]]] = None,
894
896
  chat_id: Optional[str] = None,
897
+ llm_config: Optional[Dict[str, Any]] = None,
895
898
  ) -> CompletionResponse:
896
899
  """
897
900
  Generate completion using relevant chunks as context, scoped to the end user.
@@ -931,6 +934,7 @@ class AsyncUserScope:
931
934
  self._end_user_id,
932
935
  chat_id,
933
936
  schema,
937
+ llm_config,
934
938
  )
935
939
 
936
940
  # Add schema to payload if provided
@@ -1556,6 +1560,7 @@ class AsyncMorphik:
1556
1560
  folder_name: Optional[Union[str, List[str]]] = None,
1557
1561
  chat_id: Optional[str] = None,
1558
1562
  schema: Optional[Union[Type[BaseModel], Dict[str, Any]]] = None,
1563
+ llm_config: Optional[Dict[str, Any]] = None,
1559
1564
  ) -> CompletionResponse:
1560
1565
  """
1561
1566
  Generate completion using relevant chunks as context.
@@ -1575,6 +1580,7 @@ class AsyncMorphik:
1575
1580
  prompt_overrides: Optional customizations for entity extraction, resolution, and query prompts
1576
1581
  Either a QueryPromptOverrides object or a dictionary with the same structure
1577
1582
  schema: Optional schema for structured output, can be a Pydantic model or a JSON schema dict
1583
+ llm_config: Optional LiteLLM-compatible model configuration (e.g., model name, API key, base URL)
1578
1584
  Returns:
1579
1585
  CompletionResponse
1580
1586
 
@@ -1662,6 +1668,7 @@ class AsyncMorphik:
1662
1668
  None,
1663
1669
  chat_id,
1664
1670
  schema,
1671
+ llm_config,
1665
1672
  )
1666
1673
 
1667
1674
  # Add schema to payload if provided
@@ -36,7 +36,22 @@ class MetadataExtractionRule(Rule):
36
36
  def to_dict(self) -> Dict[str, Any]:
37
37
  if isinstance(self.schema, type) and issubclass(self.schema, BaseModel):
38
38
  # Convert Pydantic model to dict schema
39
- schema_dict = self.schema.model_json_schema()
39
+ json_schema = self.schema.model_json_schema()
40
+ # Extract the properties from the JSON schema format
41
+ # to match the expected server format
42
+ schema_dict = {}
43
+ if "properties" in json_schema:
44
+ for field_name, field_info in json_schema["properties"].items():
45
+ # Get field description from the Pydantic field
46
+ description = field_info.get("description", f"No description for {field_name}")
47
+ field_type = field_info.get("type", "string")
48
+ schema_dict[field_name] = {
49
+ "type": field_type,
50
+ "description": description
51
+ }
52
+ else:
53
+ # Fallback if properties not found
54
+ schema_dict = json_schema
40
55
  else:
41
56
  # Assume it's already a dict schema
42
57
  schema_dict = self.schema
@@ -369,6 +369,7 @@ class Folder:
369
369
  additional_folders: Optional[List[str]] = None,
370
370
  schema: Optional[Union[Type[BaseModel], Dict[str, Any]]] = None,
371
371
  chat_id: Optional[str] = None,
372
+ llm_config: Optional[Dict[str, Any]] = None,
372
373
  ) -> CompletionResponse:
373
374
  """
374
375
  Generate completion using relevant chunks as context within this folder.
@@ -408,6 +409,7 @@ class Folder:
408
409
  None, # end_user_id not supported at this level
409
410
  chat_id,
410
411
  schema,
412
+ llm_config,
411
413
  )
412
414
 
413
415
  # Add schema to payload if provided
@@ -952,6 +954,7 @@ class UserScope:
952
954
  additional_folders: Optional[List[str]] = None,
953
955
  schema: Optional[Union[Type[BaseModel], Dict[str, Any]]] = None,
954
956
  chat_id: Optional[str] = None,
957
+ llm_config: Optional[Dict[str, Any]] = None,
955
958
  ) -> CompletionResponse:
956
959
  """
957
960
  Generate completion using relevant chunks as context as this end user.
@@ -991,6 +994,7 @@ class UserScope:
991
994
  self._end_user_id,
992
995
  chat_id,
993
996
  schema,
997
+ llm_config,
994
998
  )
995
999
 
996
1000
  # Add schema to payload if provided
@@ -1699,6 +1703,7 @@ class Morphik:
1699
1703
  folder_name: Optional[Union[str, List[str]]] = None,
1700
1704
  chat_id: Optional[str] = None,
1701
1705
  schema: Optional[Union[Type[BaseModel], Dict[str, Any]]] = None,
1706
+ llm_config: Optional[Dict[str, Any]] = None,
1702
1707
  ) -> CompletionResponse:
1703
1708
  """
1704
1709
  Generate completion using relevant chunks as context.
@@ -1719,6 +1724,7 @@ class Morphik:
1719
1724
  Either a QueryPromptOverrides object or a dictionary with the same structure
1720
1725
  folder_name: Optional folder name to further scope operations
1721
1726
  schema: Optional schema for structured output, can be a Pydantic model or a JSON schema dict
1727
+ llm_config: Optional LiteLLM-compatible model configuration (e.g., model name, API key, base URL)
1722
1728
  Returns:
1723
1729
  CompletionResponse
1724
1730
 
@@ -1806,6 +1812,7 @@ class Morphik:
1806
1812
  None, # end_user_id not supported at this level
1807
1813
  chat_id,
1808
1814
  schema,
1815
+ llm_config,
1809
1816
  )
1810
1817
 
1811
1818
  # Add schema to payload if provided
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "morphik"
7
- version = "0.2.2"
7
+ version = "0.2.4"
8
8
  authors = [
9
9
  { name = "Morphik", email = "founders@morphik.ai" },
10
10
  ]
File without changes
File without changes
File without changes
File without changes
File without changes