simile 0.3.6__py3-none-any.whl → 0.3.8__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/client.py CHANGED
@@ -1,6 +1,6 @@
1
1
  import httpx
2
2
  from httpx import AsyncClient
3
- from typing import List, Dict, Any, Optional, Union, Type
3
+ from typing import List, Dict, Any, Optional, Union, Type, AsyncGenerator
4
4
  import uuid
5
5
  from pydantic import BaseModel
6
6
 
@@ -312,6 +312,68 @@ class Simile:
312
312
  )
313
313
  return response_data
314
314
 
315
+ async def stream_open_response(
316
+ self,
317
+ agent_id: uuid.UUID,
318
+ question: str,
319
+ data_types: Optional[List[str]] = None,
320
+ exclude_data_types: Optional[List[str]] = None,
321
+ images: Optional[Dict[str, str]] = None,
322
+ ) -> AsyncGenerator[str, None]:
323
+ """Streams an open response from an agent."""
324
+ endpoint = f"/generation/open-stream/{str(agent_id)}"
325
+ request_payload = OpenGenerationRequest(
326
+ question=question,
327
+ data_types=data_types,
328
+ exclude_data_types=exclude_data_types,
329
+ images=images,
330
+ )
331
+
332
+ url = self.base_url + endpoint # assuming self.base_url is defined
333
+
334
+ async with httpx.AsyncClient(timeout=None) as client:
335
+ async with client.stream("POST", url, json=request_payload.model_dump()) as response:
336
+ response.raise_for_status()
337
+ async for line in response.aiter_lines():
338
+ if line.strip(): # skip empty lines
339
+ if line.startswith("data: "): # optional, if using SSE format
340
+ yield line.removeprefix("data: ").strip()
341
+ else:
342
+ yield line.strip()
343
+
344
+ async def stream_closed_response(
345
+ self,
346
+ agent_id: uuid.UUID,
347
+ question: str,
348
+ options: List[str],
349
+ data_types: Optional[List[str]] = None,
350
+ exclude_data_types: Optional[List[str]] = None,
351
+ images: Optional[Dict[str, str]] = None,
352
+ ) -> AsyncGenerator[str, None]:
353
+ """Streams a closed response from an agent."""
354
+ endpoint = f"/generation/closed-stream/{str(agent_id)}"
355
+
356
+ request_payload = {
357
+ "question": question,
358
+ "options": options,
359
+ "data_types": data_types,
360
+ "exclude_data_types": exclude_data_types,
361
+ "images": images,
362
+ }
363
+
364
+ url = self.base_url + endpoint # assuming self.base_url is defined
365
+
366
+ async with httpx.AsyncClient(timeout=None) as client:
367
+ async with client.stream("POST", url, json=request_payload) as response:
368
+ response.raise_for_status()
369
+ async for line in response.aiter_lines():
370
+ if line.strip(): # skip empty lines
371
+ if line.startswith("data: "): # optional, if using SSE format
372
+ yield line.removeprefix("data: ").strip()
373
+ else:
374
+ yield line.strip()
375
+
376
+
315
377
  async def generate_open_response(
316
378
  self,
317
379
  agent_id: uuid.UUID,
simile/models.py CHANGED
@@ -46,6 +46,7 @@ class CreatePopulationPayload(BaseModel):
46
46
  class InitialDataItemPayload(BaseModel):
47
47
  data_type: str
48
48
  content: Any
49
+ metadata: Optional[Dict[str, Any]] = None
49
50
 
50
51
 
51
52
  class CreateAgentPayload(BaseModel):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: simile
3
- Version: 0.3.6
3
+ Version: 0.3.8
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
@@ -0,0 +1,11 @@
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=GG7hOWGv5sIhpg7tzRzeLR4NR1DLMCz99PPVqcnCDLc,5533
6
+ simile/resources.py,sha256=Juoa32SlN8LdvzCFaobq7uV2itmcwbk5dM_mlc4bCVk,10420
7
+ simile-0.3.8.dist-info/licenses/LICENSE,sha256=tpxX3bpODfyOQVyEM6kCMvPHFCpkjFDj0AICRqKqOFA,1066
8
+ simile-0.3.8.dist-info/METADATA,sha256=z49F7MZ6BcwCH5wp8Q63rDlqs23usTC1KSMJk7W8JQw,1276
9
+ simile-0.3.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
+ simile-0.3.8.dist-info/top_level.txt,sha256=41lJneubAG4-ZOAs5qn7iDtDb-MDxa6DdvgBKwNX84M,7
11
+ simile-0.3.8.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=zJcB2l7pqrgCK7FlY_9eG3ATe39eMRpawEASwTwKXn0,13779
4
- simile/exceptions.py,sha256=-rJ3KZcpvNRi9JXbDpxWDSL2lU1mEJX2piwYRZvhKmg,1406
5
- simile/models.py,sha256=vbWrK5VKDPsiI9K4n2dCC41Y9who7cgTHSL9ARs25K0,5487
6
- simile/resources.py,sha256=Juoa32SlN8LdvzCFaobq7uV2itmcwbk5dM_mlc4bCVk,10420
7
- simile-0.3.6.dist-info/licenses/LICENSE,sha256=tpxX3bpODfyOQVyEM6kCMvPHFCpkjFDj0AICRqKqOFA,1066
8
- simile-0.3.6.dist-info/METADATA,sha256=-LjtcX15bPSTz4t8TjEgsZ6XOnfOdmkhLff75hJIBPY,1276
9
- simile-0.3.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
- simile-0.3.6.dist-info/top_level.txt,sha256=41lJneubAG4-ZOAs5qn7iDtDb-MDxa6DdvgBKwNX84M,7
11
- simile-0.3.6.dist-info/RECORD,,
File without changes