Skip to content

Commit fe2a26b

Browse files
committed
change the content field of message to a interface
1 parent bf22473 commit fe2a26b

File tree

6 files changed

+13
-10
lines changed

6 files changed

+13
-10
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ dist/
22
__pycache__
33
.pytest_cache/
44
*.egg-info/
5+
.DS_Store

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "CompextAI"
7-
version = "0.0.13"
7+
version = "0.0.14"
88
authors = [
99
{ name="burnerlee", email="[email protected]" },
1010
]

src/compextAI/execution.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@ class ExecuteMessagesResponse:
3737
def __init__(self, thread_execution_id:str):
3838
self.thread_execution_id = thread_execution_id
3939

40-
def execute_messages(client:APIClient, thread_execution_param_id:str, messages:list[Message],system_prompt:str="", append_assistant_response:bool=True) -> ThreadExecutionResponse:
40+
def execute_messages(client:APIClient, thread_execution_param_id:str, messages:list[Message],system_prompt:str="", append_assistant_response:bool=True, metadata:dict={}) -> ThreadExecutionResponse:
4141
thread_id = "compext_thread_null"
4242
response = client.post(f"/thread/{thread_id}/execute", data={
4343
"thread_execution_param_id": thread_execution_param_id,
4444
"append_assistant_response": append_assistant_response,
4545
"thread_execution_system_prompt": system_prompt,
46-
"messages": [message.to_dict() for message in messages]
46+
"messages": [message.to_dict() for message in messages],
47+
"metadata": metadata
4748
})
4849

4950
status_code: int = response["status"]

src/compextAI/messages.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
class Message:
55
message_id: str
66
thread_id: str
7-
content: str
7+
content: any
88
role: str
99
metadata: dict
1010
created_at: datetime
1111
updated_at: datetime
1212

13-
def __init__(self,content:str, role:str, message_id:str='', thread_id:str='', metadata:dict={}, created_at:datetime=None, updated_at:datetime=None):
13+
def __init__(self,content:any, role:str, message_id:str='', thread_id:str='', metadata:dict={}, created_at:datetime=None, updated_at:datetime=None):
1414
self.message_id = message_id
1515
self.thread_id = thread_id
1616
self.content = content
@@ -69,7 +69,7 @@ def create(client:APIClient, thread_id:str, messages:list[Message]) -> list[Mess
6969

7070
return [get_message_object_from_dict(message) for message in data]
7171

72-
def update(client:APIClient, message_id:str, content:str, role:str, metadata:dict={}) -> Message:
72+
def update(client:APIClient, message_id:str, content:any, role:str, metadata:dict={}) -> Message:
7373
response = client.put(f"/message/{message_id}", data={"content": content, "role": role, "metadata": metadata})
7474

7575
status_code: int = response["status"]

src/compextAI/params.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def create(client:APIClient, name:str, environment:str, project_name:str, templa
6868

6969
return get_thread_execution_param_object_from_dict(data)
7070

71-
def update(client:APIClient, name:str, environment:str, model:str, temperature:float, timeout:int, max_tokens:int, max_completion_tokens:int, top_p:float, max_output_tokens:int, response_format:any, system_prompt:str) -> ThreadExecutionParam:
72-
response = client.post(f"/execparams/update", data={"name": name, "environment": environment, "model": model, "temperature": temperature, "timeout": timeout, "max_tokens": max_tokens, "max_completion_tokens": max_completion_tokens, "top_p": top_p, "max_output_tokens": max_output_tokens, "response_format": response_format, "system_prompt": system_prompt})
71+
def update(client:APIClient, name:str, environment:str, templateID:str) -> ThreadExecutionParam:
72+
response = client.post(f"/execparams/update", data={"name": name, "environment": environment, "template_id": templateID})
7373

7474
status_code: int = response["status"]
7575
data: dict = response["data"]

src/compextAI/threads.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ def __init__(self, thread_id:str, title:str, metadata:dict):
2121
def __str__(self):
2222
return f"Thread(thread_id={self.thread_id}, title={self.title}, metadata={self.metadata})"
2323

24-
def execute(self, client:APIClient, thread_exec_param_id: str, system_prompt:str="", append_assistant_response:bool=True) -> ThreadExecutionResponse:
24+
def execute(self, client:APIClient, thread_exec_param_id: str, system_prompt:str="", append_assistant_response:bool=True, metadata:dict={}) -> ThreadExecutionResponse:
2525
response = client.post(f"/thread/{self.thread_id}/execute", data={
2626
"thread_execution_param_id": thread_exec_param_id,
2727
"append_assistant_response": append_assistant_response,
28-
"thread_execution_system_prompt": system_prompt
28+
"thread_execution_system_prompt": system_prompt,
29+
"metadata": metadata
2930
})
3031

3132
status_code: int = response["status"]

0 commit comments

Comments
 (0)