simile 0.2.0__tar.gz → 0.2.1__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.2.0
3
+ Version: 0.2.1
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.2.0"
7
+ version = "0.2.1"
8
8
  authors = [
9
9
  { name="Simile AI", email="cqz@simile.ai" },
10
10
  ]
@@ -17,6 +17,12 @@ DEFAULT_BASE_URL = "https://simile-api-3a83be7adae0.herokuapp.com/api/v1"
17
17
  TIMEOUT_CONFIG = httpx.Timeout(5.0, read=30.0, write=30.0, pool=30.0)
18
18
 
19
19
  class Simile:
20
+ # Make exceptions available as class attributes for convenience
21
+ APIError = SimileAPIError
22
+ AuthenticationError = SimileAuthenticationError
23
+ NotFoundError = SimileNotFoundError
24
+ BadRequestError = SimileBadRequestError
25
+
20
26
  def __init__(self, api_key: str, base_url: str = DEFAULT_BASE_URL):
21
27
  if not api_key:
22
28
  raise ValueError("API key is required.")
@@ -59,7 +65,9 @@ class Simile:
59
65
  raise SimileAPIError(f"Request error: {e}")
60
66
 
61
67
  # --- Population Endpoints ---
62
- async def create_population(self, payload: CreatePopulationPayload) -> Population:
68
+ async def create_population(self, name: str, description: Optional[str] = None) -> Population:
69
+ """Creates a new population."""
70
+ payload = CreatePopulationPayload(name=name, description=description)
63
71
  response_data = await self._request("POST", "populations/create", json=payload.model_dump(mode='json', exclude_none=True), response_model=Population)
64
72
  return response_data
65
73
 
@@ -72,7 +80,14 @@ class Simile:
72
80
  return response_data
73
81
 
74
82
  # --- Agent Endpoints ---
75
- async def create_agent(self, payload: CreateAgentPayload) -> Agent:
83
+ async def create_agent(self, name: str, population_id: Optional[Union[str, uuid.UUID]] = None, agent_data: Optional[List[Dict[str, Any]]] = None) -> Agent:
84
+ """Creates a new agent, optionally within a population and with initial data items."""
85
+ # Ensure population_id is uuid if provided
86
+ pop_id_uuid: Optional[uuid.UUID] = None
87
+ if population_id:
88
+ pop_id_uuid = uuid.UUID(str(population_id)) if not isinstance(population_id, uuid.UUID) else population_id
89
+
90
+ payload = CreateAgentPayload(name=name, population_id=pop_id_uuid, agent_data=agent_data)
76
91
  response_data = await self._request("POST", "agents/create", json=payload.model_dump(mode='json', exclude_none=True), response_model=Agent)
77
92
  return response_data
78
93
 
@@ -85,7 +100,9 @@ class Simile:
85
100
  return response_data
86
101
 
87
102
  # --- Data Item Endpoints ---
88
- async def create_data_item(self, agent_id: Union[str, uuid.UUID], payload: CreateDataItemPayload) -> DataItem:
103
+ async def create_data_item(self, agent_id: Union[str, uuid.UUID], data_type: str, content: Any) -> DataItem:
104
+ """Creates a new data item for a specific agent."""
105
+ payload = CreateDataItemPayload(data_type=data_type, content=content)
89
106
  response_data = await self._request("POST", f"data_item/create/{str(agent_id)}", json=payload.model_dump(mode='json'), response_model=DataItem)
90
107
  return response_data
91
108
 
@@ -97,11 +114,15 @@ class Simile:
97
114
  params = {}
98
115
  if data_type:
99
116
  params["data_type"] = data_type
100
- raw_response = await self._request("GET", f"data_item/list/{str(agent_id)}", params=params)
117
+ # Ensure agent_id is string for URL
118
+ agent_id_str = str(agent_id)
119
+ raw_response = await self._request("GET", f"data_item/list/{agent_id_str}", params=params)
101
120
  return [DataItem(**item) for item in raw_response.json()]
102
121
 
103
- async def update_data_item(self, data_item_id: Union[str, uuid.UUID], payload: UpdateDataItemPayload) -> DataItem:
104
- response_data = await self._request("POST", f"data_item/update/{data_item_id}", json=payload.model_dump(), response_model=DataItem)
122
+ async def update_data_item(self, data_item_id: Union[str, uuid.UUID], content: Any) -> DataItem:
123
+ """Updates an existing data item."""
124
+ payload = UpdateDataItemPayload(content=content)
125
+ response_data = await self._request("POST", f"data_item/update/{str(data_item_id)}", json=payload.model_dump(), response_model=DataItem)
105
126
  return response_data
106
127
 
107
128
  async def delete_data_item(self, data_item_id: Union[str, uuid.UUID]) -> DeletionResponse:
@@ -109,8 +130,10 @@ class Simile:
109
130
  return response_data
110
131
 
111
132
  # --- LLM Generation Methods ---
112
- async def generate_qual_response(self, agent_id: uuid.UUID, request_payload: QualGenerationRequest) -> QualGenerationResponse:
133
+ async def generate_qual_response(self, agent_id: uuid.UUID, question: str) -> QualGenerationResponse:
134
+ """Generates a qualitative response from an agent based on a question."""
113
135
  endpoint = f"/generation/qual/{str(agent_id)}"
136
+ request_payload = QualGenerationRequest(question=question) # Create payload internally
114
137
  response_data = await self._request(
115
138
  "POST",
116
139
  endpoint,
@@ -119,8 +142,10 @@ class Simile:
119
142
  )
120
143
  return response_data
121
144
 
122
- async def generate_mc_response(self, agent_id: uuid.UUID, request_payload: MCGenerationRequest) -> MCGenerationResponse:
123
- endpoint = f"generation/mc/{agent_id}"
145
+ async def generate_mc_response(self, agent_id: uuid.UUID, question: str, options: List[str]) -> MCGenerationResponse:
146
+ """Generates a multiple-choice response from an agent."""
147
+ endpoint = f"generation/mc/{str(agent_id)}" # Ensured str(agent_id)
148
+ request_payload = MCGenerationRequest(question=question, options=options) # Create payload internally
124
149
  response_data = await self._request("POST", endpoint, json=request_payload.model_dump(), response_model=MCGenerationResponse)
125
150
  return response_data
126
151
 
@@ -34,10 +34,15 @@ class CreatePopulationPayload(BaseModel):
34
34
  description: Optional[str] = None
35
35
 
36
36
 
37
+ class InitialDataItemPayload(BaseModel):
38
+ data_type: str
39
+ content: Any
40
+
41
+
37
42
  class CreateAgentPayload(BaseModel):
38
43
  name: str
39
44
  population_id: Optional[uuid.UUID] = None
40
- agent_data: Optional[List[Dict[str, Any]]] = None # For initial data items
45
+ agent_data: Optional[List[InitialDataItemPayload]] = None # For initial data items
41
46
 
42
47
 
43
48
  class CreateDataItemPayload(BaseModel):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: simile
3
- Version: 0.2.0
3
+ Version: 0.2.1
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