Skip to content

Commit 07578a1

Browse files
committed
refactor(app): pass thread to start()
1 parent 38ffc73 commit 07578a1

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

npi/app/discord/app.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from npi.config import config
99
from npi.error.auth import UnauthorizedError
1010
from .schema import *
11+
from ...core.thread import Thread
1112

1213
client = discord.Client(intents=discord.Intents.default())
1314

@@ -47,8 +48,8 @@ def __init__(self, llm=None):
4748
self.client = discord.Client(intents=discord.Intents.default())
4849
self._access_token = cred.access_token
4950

50-
async def start(self):
51-
await super().start()
51+
async def start(self, thread: Thread = None):
52+
await super().start(thread)
5253
await self.client.login(self._access_token)
5354

5455
async def dispose(self):

npi/browser_app/twitter/app.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
'home': 'https://twitter.com/home'
4646
}
4747

48+
from ...core.thread import Thread
49+
4850

4951
class ImageFilterConverter(MarkdownConverter):
5052
def process_text(self, el):
@@ -117,9 +119,9 @@ def __init__(self, llm=None, headless: bool = True):
117119

118120
self.register(Navigator(playwright=self.playwright))
119121

120-
async def start(self):
122+
async def start(self, thread: Thread = None):
121123
if not self._started:
122-
await super().start()
124+
await super().start(thread)
123125
await self._login()
124126

125127
async def _login(self):

npi/core/app.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def __init__(
150150
self.fn_map = {}
151151
_register_tools(self)
152152

153-
async def start(self):
153+
async def start(self, thread: Thread = None):
154154
"""Start the app"""
155155
self._started = True
156156

npi/core/browser_app.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ def __init__(
4343
self.use_screenshot = use_screenshot
4444
self.playwright = playwright or PlaywrightContext(headless)
4545

46-
async def start(self):
46+
async def start(self, thread: Thread = None):
4747
"""Start the Browser App"""
4848
if not self._started:
49-
await super().start()
49+
await super().start(thread)
5050
await self.playwright.start()
5151

5252
async def dispose(self):

npi/server/app.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ async def run(self, thread: Thread):
161161
app = None
162162
try:
163163
app = self.get_app(thread.app_type)
164-
await app.start()
164+
await app.start(thread)
165165
result = await app.chat(thread.instruction, thread)
166166
thread.finish(result)
167167
except UnauthorizedError as e:

0 commit comments

Comments
 (0)