simile 0.3.9__py3-none-any.whl → 0.3.11__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 simile might be problematic. Click here for more details.

simile/__init__.py CHANGED
@@ -16,10 +16,10 @@ from .models import (
16
16
  ClosedGenerationResponse,
17
17
  )
18
18
  from .exceptions import (
19
- SimileAPIError,
20
- SimileAuthenticationError,
21
- SimileNotFoundError,
22
- SimileBadRequestError
19
+ SimileAPIError,
20
+ SimileAuthenticationError,
21
+ SimileNotFoundError,
22
+ SimileBadRequestError,
23
23
  )
24
24
 
25
25
  __all__ = [
simile/client.py CHANGED
@@ -169,10 +169,14 @@ class Simile:
169
169
  )
170
170
  return response_data
171
171
 
172
- async def get_population_info(self, population_id: Union[str, uuid.UUID]) -> PopulationInfo:
172
+ async def get_population_info(
173
+ self, population_id: Union[str, uuid.UUID]
174
+ ) -> PopulationInfo:
173
175
  """Gets basic population info (name and agent count) without full population data."""
174
176
  response_data = await self._request(
175
- "GET", f"populations/info/{str(population_id)}", response_model=PopulationInfo
177
+ "GET",
178
+ f"populations/info/{str(population_id)}",
179
+ response_model=PopulationInfo,
176
180
  )
177
181
  return response_data
178
182
 
@@ -259,10 +263,16 @@ class Simile:
259
263
  return raw_response.json()
260
264
 
261
265
  async def create_data_item(
262
- self, agent_id: Union[str, uuid.UUID], data_type: str, content: Any, metadata: Optional[Dict[str, Any]] = None
266
+ self,
267
+ agent_id: Union[str, uuid.UUID],
268
+ data_type: str,
269
+ content: Any,
270
+ metadata: Optional[Dict[str, Any]] = None,
263
271
  ) -> DataItem:
264
272
  """Creates a new data item for a specific agent."""
265
- payload = CreateDataItemPayload(data_type=data_type, content=content, metadata=metadata)
273
+ payload = CreateDataItemPayload(
274
+ data_type=data_type, content=content, metadata=metadata
275
+ )
266
276
  response_data = await self._request(
267
277
  "POST",
268
278
  f"data_item/create/{str(agent_id)}",
@@ -319,6 +329,7 @@ class Simile:
319
329
  data_types: Optional[List[str]] = None,
320
330
  exclude_data_types: Optional[List[str]] = None,
321
331
  images: Optional[Dict[str, str]] = None,
332
+ reasoning: bool = False,
322
333
  ) -> AsyncGenerator[str, None]:
323
334
  """Streams an open response from an agent."""
324
335
  endpoint = f"/generation/open-stream/{str(agent_id)}"
@@ -327,12 +338,15 @@ class Simile:
327
338
  data_types=data_types,
328
339
  exclude_data_types=exclude_data_types,
329
340
  images=images,
341
+ reasoning=reasoning,
330
342
  )
331
343
 
332
344
  url = self.base_url + endpoint # assuming self.base_url is defined
333
345
 
334
346
  async with httpx.AsyncClient(timeout=None) as client:
335
- async with client.stream("POST", url, json=request_payload.model_dump()) as response:
347
+ async with client.stream(
348
+ "POST", url, json=request_payload.model_dump()
349
+ ) as response:
336
350
  response.raise_for_status()
337
351
  async for line in response.aiter_lines():
338
352
  if line.strip(): # skip empty lines
@@ -352,7 +366,7 @@ class Simile:
352
366
  ) -> AsyncGenerator[str, None]:
353
367
  """Streams a closed response from an agent."""
354
368
  endpoint = f"/generation/closed-stream/{str(agent_id)}"
355
-
369
+
356
370
  request_payload = {
357
371
  "question": question,
358
372
  "options": options,
@@ -373,7 +387,6 @@ class Simile:
373
387
  else:
374
388
  yield line.strip()
375
389
 
376
-
377
390
  async def generate_open_response(
378
391
  self,
379
392
  agent_id: uuid.UUID,
@@ -381,6 +394,7 @@ class Simile:
381
394
  data_types: Optional[List[str]] = None,
382
395
  exclude_data_types: Optional[List[str]] = None,
383
396
  images: Optional[Dict[str, str]] = None,
397
+ reasoning: bool = False,
384
398
  ) -> OpenGenerationResponse:
385
399
  """Generates an open response from an agent based on a question."""
386
400
  endpoint = f"/generation/open/{str(agent_id)}"
@@ -389,6 +403,7 @@ class Simile:
389
403
  data_types=data_types,
390
404
  exclude_data_types=exclude_data_types,
391
405
  images=images,
406
+ reasoning=reasoning,
392
407
  )
393
408
  response_data = await self._request(
394
409
  "POST",
@@ -406,6 +421,7 @@ class Simile:
406
421
  data_types: Optional[List[str]] = None,
407
422
  exclude_data_types: Optional[List[str]] = None,
408
423
  images: Optional[Dict[str, str]] = None,
424
+ reasoning: bool = False,
409
425
  ) -> ClosedGenerationResponse:
410
426
  """Generates a closed response from an agent."""
411
427
  endpoint = f"generation/closed/{str(agent_id)}"
@@ -415,6 +431,7 @@ class Simile:
415
431
  data_types=data_types,
416
432
  exclude_data_types=exclude_data_types,
417
433
  images=images,
434
+ reasoning=reasoning,
418
435
  )
419
436
  response_data = await self._request(
420
437
  "POST",
simile/exceptions.py CHANGED
@@ -1,5 +1,6 @@
1
1
  class SimileAPIError(Exception):
2
2
  """Base exception for Simile API client errors."""
3
+
3
4
  def __init__(self, message: str, status_code: int = None, detail: str = None):
4
5
  super().__init__(message)
5
6
  self.status_code = status_code
@@ -15,17 +16,32 @@ class SimileAPIError(Exception):
15
16
 
16
17
  class SimileAuthenticationError(SimileAPIError):
17
18
  """Exception for authentication errors (e.g., invalid API key)."""
18
- def __init__(self, message: str = "Authentication failed. Ensure API key is valid.", status_code: int = 401, detail: str = None):
19
+
20
+ def __init__(
21
+ self,
22
+ message: str = "Authentication failed. Ensure API key is valid.",
23
+ status_code: int = 401,
24
+ detail: str = None,
25
+ ):
19
26
  super().__init__(message, status_code, detail)
20
27
 
21
28
 
22
29
  class SimileNotFoundError(SimileAPIError):
23
30
  """Exception for resource not found errors (404)."""
24
- def __init__(self, message: str = "Resource not found.", status_code: int = 404, detail: str = None):
31
+
32
+ def __init__(
33
+ self,
34
+ message: str = "Resource not found.",
35
+ status_code: int = 404,
36
+ detail: str = None,
37
+ ):
25
38
  super().__init__(message, status_code, detail)
26
39
 
27
40
 
28
41
  class SimileBadRequestError(SimileAPIError):
29
42
  """Exception for bad request errors (400)."""
30
- def __init__(self, message: str = "Bad request.", status_code: int = 400, detail: str = None):
43
+
44
+ def __init__(
45
+ self, message: str = "Bad request.", status_code: int = 400, detail: str = None
46
+ ):
31
47
  super().__init__(message, status_code, detail)
simile/models.py CHANGED
@@ -78,11 +78,13 @@ class OpenGenerationRequest(BaseModel):
78
78
  images: Optional[Dict[str, str]] = (
79
79
  None # Dict of {description: url} for multiple images
80
80
  )
81
+ reasoning: bool = False
81
82
 
82
83
 
83
84
  class OpenGenerationResponse(BaseModel):
84
85
  question: str
85
86
  answer: str
87
+ reasoning: Optional[str] = ""
86
88
 
87
89
 
88
90
  class ClosedGenerationRequest(BaseModel):
@@ -91,12 +93,14 @@ class ClosedGenerationRequest(BaseModel):
91
93
  data_types: Optional[List[str]] = None
92
94
  exclude_data_types: Optional[List[str]] = None
93
95
  images: Optional[Dict[str, str]] = None
96
+ reasoning: bool = False
94
97
 
95
98
 
96
99
  class ClosedGenerationResponse(BaseModel):
97
100
  question: str
98
101
  options: List[str]
99
102
  response: str
103
+ reasoning: Optional[str] = ""
100
104
 
101
105
 
102
106
  class AddContextRequest(BaseModel):
@@ -166,9 +170,7 @@ class ClosedQuestionTurn(BaseTurn):
166
170
  if not v:
167
171
  raise ValueError("Closed questions must have at least one option")
168
172
  if len(v) < 2:
169
- raise ValueError(
170
- "Closed questions should have at least two options"
171
- )
173
+ raise ValueError("Closed questions should have at least two options")
172
174
  return v
173
175
 
174
176
  @validator("llm_response")
@@ -183,9 +185,7 @@ class ClosedQuestionTurn(BaseTurn):
183
185
 
184
186
 
185
187
  # Union type for all possible turn types
186
- SurveySessionTurn = Union[
187
- ContextTurn, ImageTurn, OpenQuestionTurn, ClosedQuestionTurn
188
- ]
188
+ SurveySessionTurn = Union[ContextTurn, ImageTurn, OpenQuestionTurn, ClosedQuestionTurn]
189
189
 
190
190
 
191
191
  class SurveySessionCreateResponse(BaseModel):
simile/resources.py CHANGED
@@ -89,7 +89,7 @@ class SurveySession:
89
89
  async def get_details(self) -> SurveySessionDetailResponse:
90
90
  """Retrieves detailed information about this survey session including typed conversation history."""
91
91
  return await self._client.get_survey_session_details(self._id)
92
-
92
+
93
93
  async def view(self) -> SurveySessionDetailResponse:
94
94
  """Alias for get_details() - retrieves all turns in this session."""
95
95
  return await self.get_details()
@@ -100,6 +100,7 @@ class SurveySession:
100
100
  data_types: Optional[List[str]] = None,
101
101
  exclude_data_types: Optional[List[str]] = None,
102
102
  images: Optional[Dict[str, str]] = None,
103
+ reasoning: bool = False,
103
104
  ) -> OpenGenerationResponse:
104
105
  """Generates an open response within this survey session."""
105
106
  endpoint = f"sessions/{str(self._id)}/open"
@@ -108,6 +109,7 @@ class SurveySession:
108
109
  data_types=data_types,
109
110
  exclude_data_types=exclude_data_types,
110
111
  images=images,
112
+ reasoning=reasoning,
111
113
  )
112
114
  return await self._client._request(
113
115
  "POST",
@@ -123,6 +125,7 @@ class SurveySession:
123
125
  data_types: Optional[List[str]] = None,
124
126
  exclude_data_types: Optional[List[str]] = None,
125
127
  images: Optional[Dict[str, str]] = None,
128
+ reasoning: bool = False,
126
129
  ) -> ClosedGenerationResponse:
127
130
  """Generates a closed response within this survey session."""
128
131
  endpoint = f"sessions/{str(self._id)}/closed"
@@ -132,6 +135,7 @@ class SurveySession:
132
135
  data_types=data_types,
133
136
  exclude_data_types=exclude_data_types,
134
137
  images=images,
138
+ reasoning=reasoning,
135
139
  )
136
140
  return await self._client._request(
137
141
  "POST",
@@ -157,14 +161,14 @@ class SurveySession:
157
161
  timestamp: str,
158
162
  ) -> Dict:
159
163
  """Adds context to this session with a specific timestamp.
160
-
164
+
161
165
  This is a lower-level method that allows specifying when the context was added.
162
166
  For normal use, prefer the add_context() method.
163
-
167
+
164
168
  Args:
165
169
  context_text: The context text to add
166
170
  timestamp: ISO timestamp of when this interaction occurred
167
-
171
+
168
172
  Returns:
169
173
  Dictionary with success status and the added turn details
170
174
  """
@@ -174,7 +178,7 @@ class SurveySession:
174
178
  "context_text": context_text,
175
179
  "timestamp": timestamp,
176
180
  }
177
-
181
+
178
182
  return await self._client._request(
179
183
  "POST",
180
184
  endpoint,
@@ -188,11 +192,11 @@ class SurveySession:
188
192
  timestamp: Optional[str] = None,
189
193
  ) -> Dict:
190
194
  """Adds images to the session's conversation history.
191
-
195
+
192
196
  Args:
193
197
  images: Dictionary mapping image descriptions to URLs
194
198
  timestamp: Optional ISO timestamp of when this interaction occurred
195
-
199
+
196
200
  Returns:
197
201
  Dictionary with success status and the added turn details
198
202
  """
@@ -203,7 +207,7 @@ class SurveySession:
203
207
  }
204
208
  if timestamp:
205
209
  payload["timestamp"] = timestamp
206
-
210
+
207
211
  return await self._client._request(
208
212
  "POST",
209
213
  endpoint,
@@ -218,12 +222,12 @@ class SurveySession:
218
222
  timestamp: Optional[str] = None,
219
223
  ) -> Dict:
220
224
  """Adds an open question-answer pair to the session's history.
221
-
225
+
222
226
  Args:
223
227
  question: The open question text
224
228
  response: The response that was given
225
229
  timestamp: Optional ISO timestamp of when this interaction occurred
226
-
230
+
227
231
  Returns:
228
232
  Dictionary with success status and the added turn details
229
233
  """
@@ -235,7 +239,7 @@ class SurveySession:
235
239
  }
236
240
  if timestamp:
237
241
  payload["timestamp"] = timestamp
238
-
242
+
239
243
  return await self._client._request(
240
244
  "POST",
241
245
  endpoint,
@@ -258,13 +262,13 @@ class SurveySession:
258
262
  timestamp: Optional[str] = None,
259
263
  ) -> Dict:
260
264
  """Adds a closed question-answer pair to the session's history.
261
-
265
+
262
266
  Args:
263
267
  question: The closed question text
264
268
  options: List of answer options
265
269
  response: The option that was selected
266
270
  timestamp: Optional ISO timestamp of when this interaction occurred
267
-
271
+
268
272
  Returns:
269
273
  Dictionary with success status and the added turn details
270
274
  """
@@ -277,40 +281,39 @@ class SurveySession:
277
281
  }
278
282
  if timestamp:
279
283
  payload["timestamp"] = timestamp
280
-
284
+
281
285
  return await self._client._request(
282
286
  "POST",
283
287
  endpoint,
284
288
  json=payload,
285
289
  response_model=None, # Return raw dict since we don't have a specific model
286
290
  )
287
-
288
-
291
+
289
292
  async def fork(self, turn_index: int) -> "SurveySession":
290
293
  """Fork this session at a specific turn.
291
-
294
+
292
295
  Creates a new session with the same agent and copies turns from this session
293
296
  up to and including the specified turn index.
294
-
297
+
295
298
  Args:
296
299
  turn_index: The 0-based index of the last turn to include in the fork
297
-
300
+
298
301
  Returns:
299
302
  A new SurveySession object representing the forked session
300
-
303
+
301
304
  Raises:
302
305
  Simile.APIError: If the API request fails
303
306
  """
304
307
  endpoint = f"sessions/{str(self._id)}/fork"
305
308
  params = {"turn_index": turn_index}
306
-
309
+
307
310
  response = await self._client._request(
308
311
  "POST",
309
312
  endpoint,
310
313
  params=params,
311
314
  response_model=SurveySessionCreateResponse,
312
315
  )
313
-
316
+
314
317
  # Create a new SurveySession instance from the response
315
318
  return SurveySession(
316
319
  id=response.id,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: simile
3
- Version: 0.3.9
3
+ Version: 0.3.11
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
@@ -46,3 +46,18 @@ from simile import Simile
46
46
 
47
47
  client = Simile(api_key="your_api_key")
48
48
  ```
49
+
50
+ ## Publishing
51
+
52
+ First, bump the version in `pyproject.toml`. Then, create the distribution files:
53
+ ```bash
54
+ python3 -m build
55
+ ```
56
+
57
+ Afterwards, use [Twine](https://pypi.org/project/twine/) to upload the package:
58
+ ```bash
59
+ pip install twine
60
+ twine upload dist/*
61
+ ```
62
+
63
+ If you need the PyPI credentials, please ask Carolyn or Chris.
@@ -0,0 +1,11 @@
1
+ simile/__init__.py,sha256=D88zktKWLzF2EgbNm743Ype_p4s7xXWvNEQBr6mRsCI,1034
2
+ simile/auth_client.py,sha256=ICImmaA5fZX9ADbIPIUh4RED3hBZvLf3XSiaqELDAME,7923
3
+ simile/client.py,sha256=zOg38vzTmjz6tY4j5wWaU60823u8sUZBMNtwkun4stM,16645
4
+ simile/exceptions.py,sha256=Q1lbfwR7mEn_LYmwjAnsMc8BW79JNPvmCmVoPibYisU,1502
5
+ simile/models.py,sha256=NvRWSs7jmN3CelzVQeNBD2ELH0z5LOE3Pm-45nGc7fU,5667
6
+ simile/resources.py,sha256=D6K3crR4tb3CAFH7mF-y536pJwJ3rmNDCtm7Y2vMtsc,10347
7
+ simile-0.3.11.dist-info/licenses/LICENSE,sha256=tpxX3bpODfyOQVyEM6kCMvPHFCpkjFDj0AICRqKqOFA,1066
8
+ simile-0.3.11.dist-info/METADATA,sha256=sOqNFOQvJkqh7uTo7nNpHxIyLW3wbEIjqWQxLAmLwZA,1599
9
+ simile-0.3.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
+ simile-0.3.11.dist-info/top_level.txt,sha256=41lJneubAG4-ZOAs5qn7iDtDb-MDxa6DdvgBKwNX84M,7
11
+ simile-0.3.11.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- simile/__init__.py,sha256=GgbhCv5G5F8X_DIYw0H72D8fRuVHW7SLezGJykALpd0,1036
2
- simile/auth_client.py,sha256=ICImmaA5fZX9ADbIPIUh4RED3hBZvLf3XSiaqELDAME,7923
3
- simile/client.py,sha256=bV2ih_z6c7ztZooUJetPTTTlbIFOmgx5F6TUruIKA1M,16332
4
- simile/exceptions.py,sha256=-rJ3KZcpvNRi9JXbDpxWDSL2lU1mEJX2piwYRZvhKmg,1406
5
- simile/models.py,sha256=BrrKfGbvjGiKXt3FvaIKLdrqCbNK_7mJhMRBPxsNQLs,5579
6
- simile/resources.py,sha256=Juoa32SlN8LdvzCFaobq7uV2itmcwbk5dM_mlc4bCVk,10420
7
- simile-0.3.9.dist-info/licenses/LICENSE,sha256=tpxX3bpODfyOQVyEM6kCMvPHFCpkjFDj0AICRqKqOFA,1066
8
- simile-0.3.9.dist-info/METADATA,sha256=KcED9Djr77xkU53CBRq0hpr2xtsudoi0SS62bCqhfSk,1276
9
- simile-0.3.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
- simile-0.3.9.dist-info/top_level.txt,sha256=41lJneubAG4-ZOAs5qn7iDtDb-MDxa6DdvgBKwNX84M,7
11
- simile-0.3.9.dist-info/RECORD,,