Skip to content

Commit ac9f2ea

Browse files
committed
πŸ—œοΈ squash schemas
1 parent f88be8c commit ac9f2ea

File tree

5 files changed

+53
-69
lines changed

5 files changed

+53
-69
lines changed

β€Žsrc/codeinterpreterapi/schema/file.pyβ€Ž renamed to β€Žsrc/codeinterpreterapi/schema.pyβ€Ž

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import asyncio
22

33
from typing import Any
4+
from langchain.schema import AIMessage, HumanMessage
45
from langchain.pydantic_v1 import BaseModel
6+
from codeboxapi.schema import CodeBoxStatus
57

68

79
class File(BaseModel):
@@ -87,3 +89,54 @@ def __str__(self) -> str:
8789

8890
def __repr__(self) -> str:
8991
return f"File(name={self.name})"
92+
93+
94+
class CodeInput(BaseModel):
95+
code: str
96+
97+
98+
class FileInput(BaseModel):
99+
filename: str
100+
101+
102+
class UserRequest(HumanMessage):
103+
files: list[File] = []
104+
105+
def __str__(self) -> str:
106+
return str(self.content)
107+
108+
def __repr__(self) -> str:
109+
return f"UserRequest(content={self.content}, files={self.files})"
110+
111+
112+
class CodeInterpreterResponse(AIMessage):
113+
"""
114+
Response from the code interpreter agent.
115+
116+
files: list of files to be sent to the user (File )
117+
code_log: list[tuple[str, str]] = []
118+
"""
119+
120+
files: list[File] = []
121+
code_log: list[tuple[str, str]] = []
122+
123+
def show(self) -> None:
124+
print("AI: ", self.content)
125+
for file in self.files:
126+
print("File: ", file.name)
127+
file.show_image()
128+
129+
def __str__(self) -> str:
130+
return str(self.content)
131+
132+
def __repr__(self) -> str:
133+
return f"CodeInterpreterResponse(content={self.content}, files={self.files})"
134+
135+
136+
class SessionStatus(CodeBoxStatus):
137+
@classmethod
138+
def from_codebox_status(cls, cbs: CodeBoxStatus) -> "SessionStatus":
139+
return cls(status=cbs.status)
140+
141+
def __repr__(self) -> str:
142+
return f"<SessionStatus status={self.status}>"

β€Žsrc/codeinterpreterapi/schema/__init__.pyβ€Ž

Lines changed: 0 additions & 13 deletions
This file was deleted.

β€Žsrc/codeinterpreterapi/schema/input.pyβ€Ž

Lines changed: 0 additions & 9 deletions
This file was deleted.

β€Žsrc/codeinterpreterapi/schema/response.pyβ€Ž

Lines changed: 0 additions & 37 deletions
This file was deleted.

β€Žsrc/codeinterpreterapi/schema/status.pyβ€Ž

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
Β (0)