simile 0.4.2__tar.gz → 0.4.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.

Potentially problematic release.


This version of simile might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: simile
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Summary: Package for interfacing with Simile AI agents for simulation
5
5
  Author-email: Simile AI <cqz@simile.ai>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "simile"
7
- version = "0.4.2"
7
+ version = "0.4.4"
8
8
  authors = [
9
9
  { name="Simile AI", email="cqz@simile.ai" },
10
10
  ]
@@ -7,6 +7,7 @@ from pydantic import BaseModel
7
7
  from .models import (
8
8
  Population,
9
9
  PopulationInfo,
10
+ UpdatePopulationMetadataPayload,
10
11
  Agent as AgentModel,
11
12
  DataItem,
12
13
  DeletionResponse,
@@ -164,6 +165,32 @@ class Simile:
164
165
  )
165
166
  return response_data
166
167
 
168
+ async def update_population_metadata(
169
+ self,
170
+ population_id: Union[str, uuid.UUID],
171
+ metadata: Dict[str, Any],
172
+ mode: str = "merge",
173
+ ) -> Population:
174
+ """
175
+ Update a population's metadata (jsonb).
176
+
177
+ Args:
178
+ population_id: The ID of the population
179
+ metadata: A dictionary of metadata to merge or replace
180
+ mode: Either "merge" (default) or "replace"
181
+
182
+ Returns:
183
+ Updated Population object
184
+ """
185
+ payload = UpdatePopulationMetadataPayload(metadata=metadata, mode=mode)
186
+ response_data = await self._request(
187
+ "PATCH",
188
+ f"populations/{str(population_id)}/metadata",
189
+ json=payload,
190
+ response_model=Population,
191
+ )
192
+ return response_data
193
+
167
194
  async def get_population(self, population_id: Union[str, uuid.UUID]) -> Population:
168
195
  response_data = await self._request(
169
196
  "GET", f"populations/get/{str(population_id)}", response_model=Population
@@ -255,16 +282,16 @@ class Simile:
255
282
  "DELETE", f"agents/{str(agent_id)}/populations/{str(population_id)}"
256
283
  )
257
284
  return raw_response.json()
258
-
285
+
259
286
  async def batch_add_agents_to_population(
260
- self, agent_ids: List[Union[str, uuid.UUID]], population_id: Union[str, uuid.UUID]
287
+ self,
288
+ agent_ids: List[Union[str, uuid.UUID]],
289
+ population_id: Union[str, uuid.UUID],
261
290
  ) -> Dict[str, Any]:
262
291
  """Add multiple agents to a population in a single batch operation."""
263
292
  agent_id_strs = [str(aid) for aid in agent_ids]
264
293
  raw_response = await self._request(
265
- "POST",
266
- f"populations/{str(population_id)}/agents/batch",
267
- json=agent_id_strs
294
+ "POST", f"populations/{str(population_id)}/agents/batch", json=agent_id_strs
268
295
  )
269
296
  return raw_response.json()
270
297
 
@@ -346,6 +373,8 @@ class Simile:
346
373
  exclude_data_types: Optional[List[str]] = None,
347
374
  images: Optional[Dict[str, str]] = None,
348
375
  reasoning: bool = False,
376
+ evidence: bool = False,
377
+ confidence: bool = False,
349
378
  memory_stream: Optional[MemoryStream] = None,
350
379
  ) -> AsyncGenerator[str, None]:
351
380
  """Streams an open response from an agent."""
@@ -356,6 +385,8 @@ class Simile:
356
385
  exclude_data_types=exclude_data_types,
357
386
  images=images,
358
387
  reasoning=reasoning,
388
+ evidence=evidence,
389
+ confidence=confidence,
359
390
  )
360
391
 
361
392
  url = self.base_url + endpoint # assuming self.base_url is defined
@@ -412,13 +443,19 @@ class Simile:
412
443
  exclude_data_types: Optional[List[str]] = None,
413
444
  images: Optional[Dict[str, str]] = None,
414
445
  reasoning: bool = False,
446
+ evidence: bool = False,
447
+ confidence: bool = False,
415
448
  memory_stream: Optional[MemoryStream] = None,
416
- use_memory: Optional[Union[str, uuid.UUID]] = None, # Session ID to load memory from
449
+ use_memory: Optional[
450
+ Union[str, uuid.UUID]
451
+ ] = None, # Session ID to load memory from
417
452
  exclude_memory_ids: Optional[List[str]] = None, # Study/question IDs to exclude
418
- save_memory: Optional[Union[str, uuid.UUID]] = None, # Session ID to save memory to
453
+ save_memory: Optional[
454
+ Union[str, uuid.UUID]
455
+ ] = None, # Session ID to save memory to
419
456
  ) -> OpenGenerationResponse:
420
457
  """Generates an open response from an agent based on a question.
421
-
458
+
422
459
  Args:
423
460
  agent_id: The agent to query
424
461
  question: The question to ask
@@ -439,31 +476,33 @@ class Simile:
439
476
  "exclude_data_types": exclude_data_types,
440
477
  "images": images,
441
478
  "reasoning": reasoning,
479
+ "evidence": evidence,
480
+ "confidence": confidence,
442
481
  }
443
-
482
+
444
483
  # Pass memory parameters to API for server-side handling
445
484
  if use_memory:
446
485
  request_payload["use_memory"] = str(use_memory)
447
486
  if exclude_memory_ids:
448
487
  request_payload["exclude_memory_ids"] = exclude_memory_ids
449
-
488
+
450
489
  if save_memory:
451
490
  request_payload["save_memory"] = str(save_memory)
452
-
491
+
453
492
  # Only include explicit memory_stream if provided directly
454
493
  if memory_stream:
455
494
  request_payload["memory_stream"] = memory_stream.to_dict()
456
-
495
+
457
496
  response_data = await self._request(
458
497
  "POST",
459
498
  endpoint,
460
499
  json=request_payload,
461
500
  response_model=OpenGenerationResponse,
462
501
  )
463
-
502
+
464
503
  # Don't save memory here - API should handle it when save_memory is passed
465
504
  # Memory saving is now handled server-side for better performance
466
-
505
+
467
506
  return response_data
468
507
 
469
508
  async def generate_closed_response(
@@ -475,13 +514,19 @@ class Simile:
475
514
  exclude_data_types: Optional[List[str]] = None,
476
515
  images: Optional[Dict[str, str]] = None,
477
516
  reasoning: bool = False,
517
+ evidence: bool = False,
518
+ confidence: bool = False,
478
519
  memory_stream: Optional[MemoryStream] = None,
479
- use_memory: Optional[Union[str, uuid.UUID]] = None, # Session ID to load memory from
520
+ use_memory: Optional[
521
+ Union[str, uuid.UUID]
522
+ ] = None, # Session ID to load memory from
480
523
  exclude_memory_ids: Optional[List[str]] = None, # Study/question IDs to exclude
481
- save_memory: Optional[Union[str, uuid.UUID]] = None, # Session ID to save memory to
524
+ save_memory: Optional[
525
+ Union[str, uuid.UUID]
526
+ ] = None, # Session ID to save memory to
482
527
  ) -> ClosedGenerationResponse:
483
528
  """Generates a closed response from an agent.
484
-
529
+
485
530
  Args:
486
531
  agent_id: The agent to query
487
532
  question: The question to ask
@@ -504,35 +549,37 @@ class Simile:
504
549
  "exclude_data_types": exclude_data_types,
505
550
  "images": images,
506
551
  "reasoning": reasoning,
552
+ "evidence": evidence,
553
+ "confidence": confidence,
507
554
  }
508
-
555
+
509
556
  # Pass memory parameters to API for server-side handling
510
557
  if use_memory:
511
558
  request_payload["use_memory"] = str(use_memory)
512
559
  if exclude_memory_ids:
513
560
  request_payload["exclude_memory_ids"] = exclude_memory_ids
514
-
561
+
515
562
  if save_memory:
516
563
  request_payload["save_memory"] = str(save_memory)
517
-
564
+
518
565
  # Only include explicit memory_stream if provided directly
519
566
  if memory_stream:
520
567
  request_payload["memory_stream"] = memory_stream.to_dict()
521
-
568
+
522
569
  response_data = await self._request(
523
570
  "POST",
524
571
  endpoint,
525
572
  json=request_payload,
526
573
  response_model=ClosedGenerationResponse,
527
574
  )
528
-
575
+
529
576
  # Don't save memory here - API should handle it when save_memory is passed
530
577
  # Memory saving is now handled server-side for better performance
531
-
578
+
532
579
  return response_data
533
580
 
534
581
  # Memory Management Methods
535
-
582
+
536
583
  async def save_memory(
537
584
  self,
538
585
  agent_id: Union[str, uuid.UUID],
@@ -547,7 +594,7 @@ class Simile:
547
594
  ) -> str:
548
595
  """
549
596
  Save a response with associated memory information.
550
-
597
+
551
598
  Args:
552
599
  agent_id: The agent ID
553
600
  response: The agent's response text
@@ -558,7 +605,7 @@ class Simile:
558
605
  memory_stream_used: The memory stream that was used
559
606
  reasoning: Optional reasoning
560
607
  metadata: Additional metadata
561
-
608
+
562
609
  Returns:
563
610
  Response ID if saved successfully
564
611
  """
@@ -566,7 +613,7 @@ class Simile:
566
613
  "agent_id": str(agent_id),
567
614
  "response": response,
568
615
  }
569
-
616
+
570
617
  if session_id:
571
618
  payload["session_id"] = str(session_id)
572
619
  if question_id:
@@ -581,13 +628,13 @@ class Simile:
581
628
  payload["reasoning"] = reasoning
582
629
  if metadata:
583
630
  payload["metadata"] = metadata
584
-
631
+
585
632
  response = await self._request("POST", "memory/save", json=payload)
586
633
  data = response.json()
587
634
  if data.get("success"):
588
635
  return data.get("response_id")
589
636
  raise SimileAPIError("Failed to save memory")
590
-
637
+
591
638
  async def get_memory(
592
639
  self,
593
640
  session_id: Union[str, uuid.UUID],
@@ -599,7 +646,7 @@ class Simile:
599
646
  ) -> Optional[MemoryStream]:
600
647
  """
601
648
  Retrieve the memory stream for an agent in a session.
602
-
649
+
603
650
  Args:
604
651
  session_id: Session ID to filter by
605
652
  agent_id: The agent ID
@@ -607,7 +654,7 @@ class Simile:
607
654
  exclude_question_ids: List of question IDs to exclude
608
655
  limit: Maximum number of turns to include
609
656
  use_memory: Whether to use memory at all
610
-
657
+
611
658
  Returns:
612
659
  MemoryStream object or None
613
660
  """
@@ -616,31 +663,31 @@ class Simile:
616
663
  "agent_id": str(agent_id),
617
664
  "use_memory": use_memory,
618
665
  }
619
-
666
+
620
667
  if exclude_study_ids:
621
668
  payload["exclude_study_ids"] = [str(id) for id in exclude_study_ids]
622
669
  if exclude_question_ids:
623
670
  payload["exclude_question_ids"] = [str(id) for id in exclude_question_ids]
624
671
  if limit:
625
672
  payload["limit"] = limit
626
-
673
+
627
674
  response = await self._request("POST", "memory/get", json=payload)
628
675
  data = response.json()
629
-
676
+
630
677
  if data.get("success") and data.get("memory_stream"):
631
678
  return MemoryStream.from_dict(data["memory_stream"])
632
679
  return None
633
-
680
+
634
681
  async def get_memory_summary(
635
682
  self,
636
683
  session_id: Union[str, uuid.UUID],
637
684
  ) -> Dict[str, Any]:
638
685
  """
639
686
  Get a summary of memory usage for a session.
640
-
687
+
641
688
  Args:
642
689
  session_id: Session ID to analyze
643
-
690
+
644
691
  Returns:
645
692
  Dictionary with memory statistics
646
693
  """
@@ -649,7 +696,7 @@ class Simile:
649
696
  if data.get("success"):
650
697
  return data.get("summary", {})
651
698
  return {}
652
-
699
+
653
700
  async def clear_memory(
654
701
  self,
655
702
  session_id: Union[str, uuid.UUID],
@@ -658,28 +705,28 @@ class Simile:
658
705
  ) -> bool:
659
706
  """
660
707
  Clear memory for a session, optionally filtered by agent or study.
661
-
708
+
662
709
  Args:
663
710
  session_id: Session ID to clear memory for
664
711
  agent_id: Optional agent ID to filter by
665
712
  study_id: Optional study ID to filter by
666
-
713
+
667
714
  Returns:
668
715
  True if cleared successfully, False otherwise
669
716
  """
670
717
  payload = {
671
718
  "session_id": str(session_id),
672
719
  }
673
-
720
+
674
721
  if agent_id:
675
722
  payload["agent_id"] = str(agent_id)
676
723
  if study_id:
677
724
  payload["study_id"] = str(study_id)
678
-
725
+
679
726
  response = await self._request("POST", "memory/clear", json=payload)
680
727
  data = response.json()
681
728
  return data.get("success", False)
682
-
729
+
683
730
  async def copy_memory(
684
731
  self,
685
732
  from_session_id: Union[str, uuid.UUID],
@@ -688,12 +735,12 @@ class Simile:
688
735
  ) -> int:
689
736
  """
690
737
  Copy memory from one session to another.
691
-
738
+
692
739
  Args:
693
740
  from_session_id: Source session ID
694
741
  to_session_id: Destination session ID
695
742
  agent_id: Optional agent ID to filter by
696
-
743
+
697
744
  Returns:
698
745
  Number of memory turns copied
699
746
  """
@@ -701,10 +748,10 @@ class Simile:
701
748
  "from_session_id": str(from_session_id),
702
749
  "to_session_id": str(to_session_id),
703
750
  }
704
-
751
+
705
752
  if agent_id:
706
753
  payload["agent_id"] = str(agent_id)
707
-
754
+
708
755
  response = await self._request("POST", "memory/copy", json=payload)
709
756
  data = response.json()
710
757
  if data.get("success"):
@@ -11,6 +11,7 @@ class Population(BaseModel):
11
11
  description: Optional[str] = None
12
12
  created_at: datetime
13
13
  updated_at: datetime
14
+ metadata: Optional[Dict[str, Any]] = None
14
15
 
15
16
 
16
17
  class PopulationInfo(BaseModel):
@@ -18,6 +19,7 @@ class PopulationInfo(BaseModel):
18
19
  name: str
19
20
  description: Optional[str] = None
20
21
  agent_count: int
22
+ metadata: Optional[Dict[str, Any]] = None
21
23
 
22
24
 
23
25
  class DataItem(BaseModel):
@@ -44,6 +46,11 @@ class CreatePopulationPayload(BaseModel):
44
46
  description: Optional[str] = None
45
47
 
46
48
 
49
+ class UpdatePopulationMetadataPayload(BaseModel):
50
+ metadata: Dict[str, Any]
51
+ mode: Optional[Literal["merge", "replace"]] = "merge"
52
+
53
+
47
54
  class InitialDataItemPayload(BaseModel):
48
55
  data_type: str
49
56
  content: Any
@@ -80,6 +87,8 @@ class OpenGenerationRequest(BaseModel):
80
87
  None # Dict of {description: url} for multiple images
81
88
  )
82
89
  reasoning: bool = False
90
+ evidence: bool = False
91
+ confidence: bool = False
83
92
  memory_stream: Optional["MemoryStream"] = None
84
93
 
85
94
 
@@ -87,6 +96,8 @@ class OpenGenerationResponse(BaseModel):
87
96
  question: str
88
97
  answer: str
89
98
  reasoning: Optional[str] = ""
99
+ evidence: Optional[str] = ""
100
+ confidence: Optional[float] = None
90
101
 
91
102
 
92
103
  class ClosedGenerationRequest(BaseModel):
@@ -96,6 +107,8 @@ class ClosedGenerationRequest(BaseModel):
96
107
  exclude_data_types: Optional[List[str]] = None
97
108
  images: Optional[Dict[str, str]] = None
98
109
  reasoning: bool = False
110
+ evidence: bool = False
111
+ confidence: bool = False
99
112
  memory_stream: Optional["MemoryStream"] = None
100
113
 
101
114
 
@@ -104,6 +117,8 @@ class ClosedGenerationResponse(BaseModel):
104
117
  options: List[str]
105
118
  response: str
106
119
  reasoning: Optional[str] = ""
120
+ evidence: Optional[str] = ""
121
+ confidence: Optional[float] = None
107
122
 
108
123
 
109
124
  class AddContextRequest(BaseModel):
@@ -251,7 +266,7 @@ class BaseMemoryTurn(BaseModel):
251
266
 
252
267
  class Config:
253
268
  use_enum_values = True
254
-
269
+
255
270
  def to_dict(self) -> Dict[str, Any]:
256
271
  """Convert to dictionary for serialization."""
257
272
  data = self.model_dump()
@@ -346,9 +361,7 @@ class MemoryStream(BaseModel):
346
361
 
347
362
  def to_dict(self) -> Dict[str, Any]:
348
363
  """Convert memory stream to a dictionary for serialization."""
349
- return {
350
- "turns": [turn.to_dict() for turn in self.turns]
351
- }
364
+ return {"turns": [turn.to_dict() for turn in self.turns]}
352
365
 
353
366
  @classmethod
354
367
  def from_dict(cls, data: Dict[str, Any]) -> "MemoryStream":
@@ -369,7 +382,9 @@ class MemoryStream(BaseModel):
369
382
  def fork(self, up_to_index: Optional[int] = None) -> "MemoryStream":
370
383
  """Create a copy of this memory stream, optionally up to a specific index."""
371
384
  new_memory = MemoryStream()
372
- turns_to_copy = self.turns[:up_to_index] if up_to_index is not None else self.turns
385
+ turns_to_copy = (
386
+ self.turns[:up_to_index] if up_to_index is not None else self.turns
387
+ )
373
388
  for turn in turns_to_copy:
374
389
  new_memory.add_turn(turn.model_copy())
375
390
  return new_memory
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: simile
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Summary: Package for interfacing with Simile AI agents for simulation
5
5
  Author-email: Simile AI <cqz@simile.ai>
6
6
  License: MIT
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes