codebind 0.2.0__py3-none-any.whl → 0.3.0__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.
codebind/session.py CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import asyncio
5
6
  import json
6
7
  from collections.abc import Mapping, Sequence
7
8
  from typing import Any
@@ -85,8 +86,15 @@ class Session:
85
86
  if self.instructions:
86
87
  self.messages.append(SystemMessage(self.instructions))
87
88
 
88
- def ask(self, prompt: str, model: BaseChatModel) -> None:
89
- """Run one user turn with the explicitly supplied model."""
89
+ def send(self, prompt: str, model: BaseChatModel) -> None:
90
+ """Send one user message synchronously."""
91
+ try:
92
+ asyncio.get_running_loop()
93
+ except RuntimeError:
94
+ pass
95
+ else:
96
+ raise RuntimeError("send() cannot run inside an active event loop; use await asend().")
97
+
90
98
  text = prompt.strip()
91
99
  if not text:
92
100
  raise ValueError("prompt cannot be empty")
@@ -117,8 +125,8 @@ class Session:
117
125
  )
118
126
  )
119
127
 
120
- async def aask(self, prompt: str, model: BaseChatModel) -> None:
121
- """Run one user turn asynchronously for notebook and event-loop frontends."""
128
+ async def asend(self, prompt: str, model: BaseChatModel) -> None:
129
+ """Send one user message asynchronously."""
122
130
  text = prompt.strip()
123
131
  if not text:
124
132
  raise ValueError("prompt cannot be empty")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codebind
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: A frontend-neutral model loop for persistent IPython sessions.
5
5
  Keywords: ai,ipython,llm,repl,agents
6
6
  Author: Giovanni Gravili
@@ -51,7 +51,7 @@ It opens standard IPython with `chat` and `Models` in the user namespace. All no
51
51
  ```python
52
52
  models = Models({"openai": "OPENAI_API_KEY"})
53
53
 
54
- chat.ask(
54
+ chat.send(
55
55
  "Inspect this project and tell me what to implement first.",
56
56
  models.chat("openai/gpt-5", reasoning_effort="medium"),
57
57
  )
@@ -75,7 +75,7 @@ Load Codebind in a notebook:
75
75
 
76
76
  models = Models({"openai": "OPENAI_API_KEY"})
77
77
  model = models.chat("openai/gpt-5")
78
- await chat.aask("Inspect the current notebook state.", model)
78
+ await chat.asend("Inspect the current notebook state.", model)
79
79
  ```
80
80
 
81
81
  Codebind publishes cells, assistant Markdown, stdout, tracebacks, and rich results through IPython's MIME display system. The active frontend decides how to render HTML, Markdown, images, SVG, audio, tables, and plain text.
@@ -94,7 +94,7 @@ authorization = await models.sign_in("openai")
94
94
  webbrowser.open(authorization.url)
95
95
  await authorization.complete()
96
96
 
97
- chat.ask(
97
+ chat.send(
98
98
  "Inspect this project.",
99
99
  models.chat("openai/gpt-5", authorization=authorization),
100
100
  )
@@ -4,9 +4,9 @@ codebind/display.py,sha256=IpxcElyNcr5olRIatEduN_d-sRwpsMlaq1UtrOXocQA,494
4
4
  codebind/execution.py,sha256=Md2bv_oIp4rwjMhf8W4b4azA6a0aj-4b6J64cErPP1A,2876
5
5
  codebind/extension.py,sha256=zt30o59tynJhat5OMi_u2rci1VDhq8ZOm202hZRwFp8,1055
6
6
  codebind/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- codebind/session.py,sha256=NrxB9NLRpT_k0f56xaXgLGjEP6s2IdzF8QILCNBkLbA,6967
8
- codebind-0.2.0.dist-info/licenses/LICENSE,sha256=ujX46e0LFBIBTnCDY0u3Q7LV363B7CiI7QJZxIkEXlk,1073
9
- codebind-0.2.0.dist-info/WHEEL,sha256=R1d3uUTbmXM1FHXH_itQashbrqrOSVj-hvBCpmkIIGE,81
10
- codebind-0.2.0.dist-info/entry_points.txt,sha256=GiPcU63sULDlywJSKigAS4M3vaziYIrubXOb3fAg2_c,48
11
- codebind-0.2.0.dist-info/METADATA,sha256=wdK2mZ5n9dR9Bt9Nn7vL-U4SNDo_-ocVhiWsdIjBhNM,3685
12
- codebind-0.2.0.dist-info/RECORD,,
7
+ codebind/session.py,sha256=Q7HabKcjHUmawLKhoNc2Rdx2-pkTPM0sh1A-tApXQsU,7146
8
+ codebind-0.3.0.dist-info/licenses/LICENSE,sha256=ujX46e0LFBIBTnCDY0u3Q7LV363B7CiI7QJZxIkEXlk,1073
9
+ codebind-0.3.0.dist-info/WHEEL,sha256=R1d3uUTbmXM1FHXH_itQashbrqrOSVj-hvBCpmkIIGE,81
10
+ codebind-0.3.0.dist-info/entry_points.txt,sha256=GiPcU63sULDlywJSKigAS4M3vaziYIrubXOb3fAg2_c,48
11
+ codebind-0.3.0.dist-info/METADATA,sha256=wPZj3RGdkOU_mJLuUGsq3Du_C76P_t0jGMdtLwugeMw,3688
12
+ codebind-0.3.0.dist-info/RECORD,,