simile 0.2.0__py3-none-any.whl → 0.2.1__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 +34 -9
- simile/models.py +6 -1
- {simile-0.2.0.dist-info → simile-0.2.1.dist-info}/METADATA +1 -1
- simile-0.2.1.dist-info/RECORD +9 -0
- simile-0.2.0.dist-info/RECORD +0 -9
- {simile-0.2.0.dist-info → simile-0.2.1.dist-info}/WHEEL +0 -0
- {simile-0.2.0.dist-info → simile-0.2.1.dist-info}/licenses/LICENSE +0 -0
- {simile-0.2.0.dist-info → simile-0.2.1.dist-info}/top_level.txt +0 -0
simile/client.py
CHANGED
|
@@ -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,
|
|
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,
|
|
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],
|
|
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
|
-
|
|
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],
|
|
104
|
-
|
|
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,
|
|
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,
|
|
123
|
-
|
|
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
|
|
simile/models.py
CHANGED
|
@@ -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[
|
|
45
|
+
agent_data: Optional[List[InitialDataItemPayload]] = None # For initial data items
|
|
41
46
|
|
|
42
47
|
|
|
43
48
|
class CreateDataItemPayload(BaseModel):
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
simile/__init__.py,sha256=2OZ1LQIkAEtSs0EI5Fzlg7QGKduCgCe_nTh9FfIuHlQ,865
|
|
2
|
+
simile/client.py,sha256=HjIwjUlkH2qVo67gcC1lwhqKQlzzTMNeLSZIKpLy36Y,7934
|
|
3
|
+
simile/exceptions.py,sha256=-rJ3KZcpvNRi9JXbDpxWDSL2lU1mEJX2piwYRZvhKmg,1406
|
|
4
|
+
simile/models.py,sha256=BV6n1zgXT1CyNSdwWd1ASm2llknC401aybrw6EtGXqM,1617
|
|
5
|
+
simile-0.2.1.dist-info/licenses/LICENSE,sha256=tpxX3bpODfyOQVyEM6kCMvPHFCpkjFDj0AICRqKqOFA,1066
|
|
6
|
+
simile-0.2.1.dist-info/METADATA,sha256=ee9w-3KBLIaH3fukxpvY65Tayoboj4kOeRxXwoO9zzI,1245
|
|
7
|
+
simile-0.2.1.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
|
|
8
|
+
simile-0.2.1.dist-info/top_level.txt,sha256=41lJneubAG4-ZOAs5qn7iDtDb-MDxa6DdvgBKwNX84M,7
|
|
9
|
+
simile-0.2.1.dist-info/RECORD,,
|
simile-0.2.0.dist-info/RECORD
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
simile/__init__.py,sha256=2OZ1LQIkAEtSs0EI5Fzlg7QGKduCgCe_nTh9FfIuHlQ,865
|
|
2
|
-
simile/client.py,sha256=8FMhdyi35CQPJFh7pMLf6c9pczN7IlcCvnBh8kocOiI,6377
|
|
3
|
-
simile/exceptions.py,sha256=-rJ3KZcpvNRi9JXbDpxWDSL2lU1mEJX2piwYRZvhKmg,1406
|
|
4
|
-
simile/models.py,sha256=3T1UYCPp3KWMBD-u7lZEMahm4fS4ltm9h0oPUWs_oyI,1530
|
|
5
|
-
simile-0.2.0.dist-info/licenses/LICENSE,sha256=tpxX3bpODfyOQVyEM6kCMvPHFCpkjFDj0AICRqKqOFA,1066
|
|
6
|
-
simile-0.2.0.dist-info/METADATA,sha256=CTeN0Kl12ehJhMPbvra6o7ruVuojOyfpPB7uvUHuHjw,1245
|
|
7
|
-
simile-0.2.0.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
|
|
8
|
-
simile-0.2.0.dist-info/top_level.txt,sha256=41lJneubAG4-ZOAs5qn7iDtDb-MDxa6DdvgBKwNX84M,7
|
|
9
|
-
simile-0.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|