Skip to content

Commit 9cc650c

Browse files
committed
🔖 new example chat history backend
1 parent c7ef317 commit 9cc650c

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

examples/chat_history_backend.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import os
2+
3+
os.environ["HISTORY_BACKEND"] = "redis"
4+
os.environ["REDIS_HOST"] = "redis://localhost:6379"
5+
6+
from codeinterpreterapi import CodeInterpreterSession # noqa: E402
7+
8+
9+
def main():
10+
session_id = None
11+
12+
session = CodeInterpreterSession()
13+
session.start()
14+
15+
print("Session ID:", session.session_id)
16+
session_id = session.session_id
17+
18+
response = session.generate_response_sync("Plot the bitcoin chart of 2023 YTD")
19+
response.show()
20+
21+
del session
22+
23+
assert session_id is not None
24+
session = CodeInterpreterSession.from_id(session_id)
25+
26+
response = session.generate_response_sync("Now for the last 5 years")
27+
response.show()
28+
29+
session.stop()
30+
31+
32+
if __name__ == "__main__":
33+
main()

0 commit comments

Comments
 (0)