Skip to content

Commit 9364ba5

Browse files
author
Enias Cailliau
committed
fix imports
1 parent d4d83ea commit 9364ba5

13 files changed

+33
-27
lines changed
1.39 MB
Binary file not shown.

main.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import logging
22
import sys
3+
4+
sys.path.insert(0, "src")
35
from functools import partial
46
from typing import List
57

68
from steamship.experimental.transports.chat import ChatMessage
7-
8-
from api import LangChainTelegramChatbot
9-
10-
sys.path.insert(0, "src")
119
from steamship import Steamship, SteamshipError
1210
from steamship.cli.ship_spinner import ship_spinner
1311
from termcolor import colored
12+
from api import LangChainTelegramChatbot
1413

1514

1615
def show_results(response_messages: List[ChatMessage]):
@@ -36,7 +35,10 @@ def main():
3635
Steamship()
3736

3837
with Steamship.temporary_workspace() as client:
39-
run = partial(run_agent, agent=LangChainTelegramChatbot(client=client, config={"bot_token": "test"}))
38+
run = partial(
39+
run_agent,
40+
agent=LangChainTelegramChatbot(client=client, config={"bot_token": "test"}),
41+
)
4042
print(f"Starting Agent...")
4143

4244
print(
@@ -60,9 +62,13 @@ def run_agent(agent, prompt: str, as_api: bool = False) -> None:
6062
if not agent.is_verbose_logging_enabled(): # display progress when verbose is False
6163
print("Running: ", end="")
6264
with ship_spinner():
63-
response = agent.create_response(incoming_message=ChatMessage(text=prompt, chat_id="123"))
65+
response = agent.create_response(
66+
incoming_message=ChatMessage(text=prompt, chat_id="123")
67+
)
6468
else:
65-
response = agent.create_response(incoming_message=ChatMessage(text=prompt, chat_id="123"))
69+
response = agent.create_response(
70+
incoming_message=ChatMessage(text=prompt, chat_id="123")
71+
)
6672

6773
show_results(response)
6874

src/__pycache__/api.cpython-38.pyc

2.3 KB
Binary file not shown.
159 Bytes
Binary file not shown.
3.38 KB
Binary file not shown.
1.29 KB
Binary file not shown.

src/agent/base.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414

1515
class LangChainAgentBot(TelegramBot):
16-
1716
@abstractmethod
1817
def get_agent(self, chat_id: str) -> AgentExecutor:
1918
raise NotImplementedError()
@@ -40,7 +39,7 @@ def _invoke_later(self, delay_ms: int, message: str, chat_id: str):
4039
)
4140

4241
def create_response(
43-
self, incoming_message: ChatMessage
42+
self, incoming_message: ChatMessage
4443
) -> Optional[List[ChatMessage]]:
4544
"""Use the LLM to prepare the next response by appending the user input to the file and then generating."""
4645
if incoming_message.text == "/start":
@@ -62,7 +61,7 @@ def create_response(
6261
)
6362

6463
def agent_output_to_chat_messages(
65-
self, chat_id: str, agent_output: List[str]
64+
self, chat_id: str, agent_output: List[str]
6665
) -> List[ChatMessage]:
6766
"""Transform the output of the Multi-Modal Agent into a list of ChatMessage objects.
6867
165 Bytes
Binary file not shown.
2.12 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.

src/api.py

+17-16
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,34 @@ class LangChainTelegramChatbot(LangChainAgentBot):
3131
"""Deploy LangChain chatbots and connect them to Telegram."""
3232

3333
def get_agent(self, chat_id: str) -> AgentExecutor:
34-
llm = OpenAIChat(client=self.client,
35-
temperature=TEMPERATURE,
36-
verbose=True)
34+
llm = OpenAIChat(client=self.client, temperature=TEMPERATURE, verbose=True)
3735

3836
tools = self.get_tools(chat_id=chat_id)
3937

4038
my_instance_handle = "local-also-remind-me-will-not-work"
4139

42-
memory = ConversationBufferMemory(memory_key="chat_history",
43-
chat_memory=ChatMessageHistory(
44-
client=self.client,
45-
key=f"history-{chat_id}-{my_instance_handle}"
46-
),
47-
return_messages=True)
40+
memory = ConversationBufferMemory(
41+
memory_key="chat_history",
42+
chat_memory=ChatMessageHistory(
43+
client=self.client, key=f"history-{chat_id}-{my_instance_handle}"
44+
),
45+
return_messages=True,
46+
)
4847

49-
return initialize_agent(tools,
50-
llm,
51-
agent=AgentType.CHAT_CONVERSATIONAL_REACT_DESCRIPTION,
52-
verbose=True,
53-
# agent_kwargs={"output_parser":MultiModalParser()},
54-
memory=memory)
48+
return initialize_agent(
49+
tools,
50+
llm,
51+
agent=AgentType.CHAT_CONVERSATIONAL_REACT_DESCRIPTION,
52+
verbose=True,
53+
# agent_kwargs={"output_parser":MultiModalParser()},
54+
memory=memory,
55+
)
5556

5657
def get_tools(self, chat_id: str) -> List[Tool]:
5758
return [
5859
SearchTool(self.client),
5960
# MyTool(self.client),
6061
GenerateImageTool(self.client),
6162
# GenerateAlbumArtTool(self.client)
62-
RemindMe(invoke_later=self.invoke_later, chat_id=chat_id)
63+
RemindMe(invoke_later=self.invoke_later, chat_id=chat_id),
6364
]

steamship.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"type": "package",
33
"handle": "gymbro-bot",
4-
"version": "0.3.0-rc.19",
4+
"version": "0.3.0-rc.21",
55
"description": "Deploy your LangChain chatbots to Telegram.",
66
"author": "",
77
"entrypoint": "Unused",

0 commit comments

Comments
 (0)