tech-envision commited on
Commit
297db18
·
unverified ·
2 Parent(s): 79f2753 385fdad

Merge pull request #10 from tech-envision/codex/remove-add-two-numbers-tool

Browse files
Files changed (4) hide show
  1. README.md +1 -2
  2. src/__init__.py +2 -2
  3. src/chat.py +3 -5
  4. src/tools.py +1 -14
README.md CHANGED
@@ -3,9 +3,8 @@
3
  This project provides a simple async interface to interact with an Ollama model
4
  and demonstrates basic tool usage. Chat histories are stored in a local SQLite
5
  database using Peewee. Histories are persisted per user and session so
6
- conversations can be resumed with context. Two example tools are included:
7
 
8
- * **add_two_numbers** – Adds two integers.
9
  * **execute_python** – Executes Python code in a sandbox with selected built-ins
10
  and allows importing safe modules like ``math``. The result is returned from a
11
  ``result`` variable or captured output.
 
3
  This project provides a simple async interface to interact with an Ollama model
4
  and demonstrates basic tool usage. Chat histories are stored in a local SQLite
5
  database using Peewee. Histories are persisted per user and session so
6
+ conversations can be resumed with context. One example tool is included:
7
 
 
8
  * **execute_python** – Executes Python code in a sandbox with selected built-ins
9
  and allows importing safe modules like ``math``. The result is returned from a
10
  ``result`` variable or captured output.
src/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
  from .chat import ChatSession
2
- from .tools import add_two_numbers, execute_python
3
 
4
- __all__ = ["ChatSession", "add_two_numbers", "execute_python"]
 
1
  from .chat import ChatSession
2
+ from .tools import execute_python
3
 
4
+ __all__ = ["ChatSession", "execute_python"]
src/chat.py CHANGED
@@ -15,7 +15,7 @@ from .config import (
15
  from .db import Conversation, Message as DBMessage, User, _db, init_db
16
  from .log import get_logger
17
  from .schema import Msg
18
- from .tools import add_two_numbers, execute_python
19
 
20
  _LOG = get_logger(__name__)
21
 
@@ -93,7 +93,7 @@ class ChatSession:
93
  self._model,
94
  messages=messages,
95
  think=think,
96
- tools=[add_two_numbers, execute_python],
97
  options={"num_ctx": NUM_CTX},
98
  )
99
 
@@ -108,9 +108,7 @@ class ChatSession:
108
  return response
109
 
110
  for call in response.message.tool_calls:
111
- if call.function.name == "add_two_numbers":
112
- result = add_two_numbers(**call.function.arguments)
113
- elif call.function.name == "execute_python":
114
  result = execute_python(**call.function.arguments)
115
  else:
116
  continue
 
15
  from .db import Conversation, Message as DBMessage, User, _db, init_db
16
  from .log import get_logger
17
  from .schema import Msg
18
+ from .tools import execute_python
19
 
20
  _LOG = get_logger(__name__)
21
 
 
93
  self._model,
94
  messages=messages,
95
  think=think,
96
+ tools=[execute_python],
97
  options={"num_ctx": NUM_CTX},
98
  )
99
 
 
108
  return response
109
 
110
  for call in response.message.tool_calls:
111
+ if call.function.name == "execute_python":
 
 
112
  result = execute_python(**call.function.arguments)
113
  else:
114
  continue
src/tools.py CHANGED
@@ -1,19 +1,6 @@
1
  from __future__ import annotations
2
 
3
- __all__ = ["add_two_numbers", "execute_python"]
4
-
5
-
6
- def add_two_numbers(a: int, b: int) -> int: # noqa: D401
7
- """Add two numbers together.
8
-
9
- Args:
10
- a (int): First number to add.
11
- b (int): Second number to add.
12
-
13
- Returns:
14
- int: The sum of the two numbers.
15
- """
16
- return a + b
17
 
18
 
19
  def execute_python(code: str) -> str:
 
1
  from __future__ import annotations
2
 
3
+ __all__ = ["execute_python"]
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
 
6
  def execute_python(code: str) -> str: