Spaces:
Runtime error
Runtime error
Commit
·
0c384f5
1
Parent(s):
db167ca
chore: gamic
Browse files- main.py +4 -4
- src/agent/base.py +1 -2
- src/agent/tools/conversation.py +0 -1
- src/api.py +4 -5
main.py
CHANGED
|
@@ -9,7 +9,7 @@ os.environ['TRANSFORMERS_CACHE'] = '/tmp'
|
|
| 9 |
from telegram.ext import (
|
| 10 |
Application,
|
| 11 |
)
|
| 12 |
-
from api import
|
| 13 |
from functools import partial
|
| 14 |
from typing import List
|
| 15 |
from telegram import Update
|
|
@@ -41,12 +41,12 @@ class LoggingDisabled:
|
|
| 41 |
logging.disable(logging.NOTSET)
|
| 42 |
|
| 43 |
|
| 44 |
-
def main():
|
| 45 |
app = Application.builder().token(
|
| 46 |
'5998527257:AAFolKz-AIXDzaSj3UOmxaLZSyDVp_3LoYw',).build()
|
| 47 |
|
| 48 |
run_agent(
|
| 49 |
-
agent=
|
| 50 |
token="hello",
|
| 51 |
application=app
|
| 52 |
)
|
|
@@ -54,7 +54,7 @@ def main():
|
|
| 54 |
print(f"Starting Agent...")
|
| 55 |
|
| 56 |
|
| 57 |
-
def run_agent(agent:
|
| 58 |
agent.handlers()
|
| 59 |
|
| 60 |
|
|
|
|
| 9 |
from telegram.ext import (
|
| 10 |
Application,
|
| 11 |
)
|
| 12 |
+
from api import BuddyPanda
|
| 13 |
from functools import partial
|
| 14 |
from typing import List
|
| 15 |
from telegram import Update
|
|
|
|
| 41 |
logging.disable(logging.NOTSET)
|
| 42 |
|
| 43 |
|
| 44 |
+
def main() -> None:
|
| 45 |
app = Application.builder().token(
|
| 46 |
'5998527257:AAFolKz-AIXDzaSj3UOmxaLZSyDVp_3LoYw',).build()
|
| 47 |
|
| 48 |
run_agent(
|
| 49 |
+
agent=BuddyPanda(
|
| 50 |
token="hello",
|
| 51 |
application=app
|
| 52 |
)
|
|
|
|
| 54 |
print(f"Starting Agent...")
|
| 55 |
|
| 56 |
|
| 57 |
+
def run_agent(agent: BuddyPanda, as_api: bool = False) -> None:
|
| 58 |
agent.handlers()
|
| 59 |
|
| 60 |
|
src/agent/base.py
CHANGED
|
@@ -3,7 +3,6 @@ import re
|
|
| 3 |
from abc import abstractmethod
|
| 4 |
|
| 5 |
from telegram import Update
|
| 6 |
-
import telegram
|
| 7 |
from telegram.ext import (
|
| 8 |
ConversationHandler,
|
| 9 |
CallbackContext,
|
|
@@ -15,7 +14,7 @@ from agent.tools.conversation import Conversation
|
|
| 15 |
SELECT_COMMAND, GET_TEXT = range(2)
|
| 16 |
|
| 17 |
|
| 18 |
-
class
|
| 19 |
def is_verbose_logging_enabled(self):
|
| 20 |
return True
|
| 21 |
|
|
|
|
| 3 |
from abc import abstractmethod
|
| 4 |
|
| 5 |
from telegram import Update
|
|
|
|
| 6 |
from telegram.ext import (
|
| 7 |
ConversationHandler,
|
| 8 |
CallbackContext,
|
|
|
|
| 14 |
SELECT_COMMAND, GET_TEXT = range(2)
|
| 15 |
|
| 16 |
|
| 17 |
+
class BuddyAgentBot(ConversationSummary, Conversation):
|
| 18 |
def is_verbose_logging_enabled(self):
|
| 19 |
return True
|
| 20 |
|
src/agent/tools/conversation.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import logging
|
| 2 |
from telegram import Update
|
| 3 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 4 |
-
import torch
|
| 5 |
from telegram.ext import (
|
| 6 |
CallbackContext,
|
| 7 |
)
|
|
|
|
| 1 |
import logging
|
| 2 |
from telegram import Update
|
| 3 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
|
|
|
| 4 |
from telegram.ext import (
|
| 5 |
CallbackContext,
|
| 6 |
)
|
src/api.py
CHANGED
|
@@ -4,12 +4,11 @@ from typing import List, Optional, Type
|
|
| 4 |
from pydantic import Field
|
| 5 |
|
| 6 |
|
| 7 |
-
from agent.base import
|
| 8 |
-
from telegram.ext import
|
| 9 |
from telegram import Update
|
| 10 |
from telegram.ext import (
|
| 11 |
CommandHandler,
|
| 12 |
-
ConversationHandler,
|
| 13 |
CallbackContext,
|
| 14 |
MessageHandler,
|
| 15 |
filters
|
|
@@ -24,7 +23,7 @@ async def hello(update: Update, context: CallbackContext) -> None:
|
|
| 24 |
await update.message.reply_text(intro_text)
|
| 25 |
|
| 26 |
|
| 27 |
-
class
|
| 28 |
"""Deploy LangChain chatbots and connect them to Telegram."""
|
| 29 |
|
| 30 |
token: str
|
|
@@ -45,4 +44,4 @@ class GirlfriendGPT(LangChainAgentBot, ):
|
|
| 45 |
self.application.add_handler(summary_handler)
|
| 46 |
self.application.add_handler(CommandHandler('start', hello))
|
| 47 |
|
| 48 |
-
|
|
|
|
| 4 |
from pydantic import Field
|
| 5 |
|
| 6 |
|
| 7 |
+
from agent.base import BuddyAgentBot
|
| 8 |
+
from telegram.ext import CommandHandler, CallbackContext, Application, ContextTypes
|
| 9 |
from telegram import Update
|
| 10 |
from telegram.ext import (
|
| 11 |
CommandHandler,
|
|
|
|
| 12 |
CallbackContext,
|
| 13 |
MessageHandler,
|
| 14 |
filters
|
|
|
|
| 23 |
await update.message.reply_text(intro_text)
|
| 24 |
|
| 25 |
|
| 26 |
+
class BuddyPanda(BuddyAgentBot, ):
|
| 27 |
"""Deploy LangChain chatbots and connect them to Telegram."""
|
| 28 |
|
| 29 |
token: str
|
|
|
|
| 44 |
self.application.add_handler(summary_handler)
|
| 45 |
self.application.add_handler(CommandHandler('start', hello))
|
| 46 |
|
| 47 |
+
self.application.run_polling()
|