Spaces:
Sleeping
Sleeping
Fixed tool name for get_feed().
Browse files- client/gradio_functions.py +2 -0
- client/interface.py +5 -2
- rss_client.py +10 -9
client/gradio_functions.py
CHANGED
|
@@ -6,6 +6,7 @@ import logging
|
|
| 6 |
from pathlib import Path
|
| 7 |
from logging.handlers import RotatingFileHandler
|
| 8 |
|
|
|
|
| 9 |
def get_dialog_logger(name: str = 'dialog', clear: bool = True) -> logging.Logger:
|
| 10 |
'''Sets up logger for model's internal dialog.'''
|
| 11 |
|
|
@@ -37,6 +38,7 @@ def get_dialog_logger(name: str = 'dialog', clear: bool = True) -> logging.Logge
|
|
| 37 |
|
| 38 |
return new_dialog_logger
|
| 39 |
|
|
|
|
| 40 |
def update_dialog(n: int = 10):
|
| 41 |
'''Gets updated internal dialog logging output from disk to display to user.
|
| 42 |
|
|
|
|
| 6 |
from pathlib import Path
|
| 7 |
from logging.handlers import RotatingFileHandler
|
| 8 |
|
| 9 |
+
|
| 10 |
def get_dialog_logger(name: str = 'dialog', clear: bool = True) -> logging.Logger:
|
| 11 |
'''Sets up logger for model's internal dialog.'''
|
| 12 |
|
|
|
|
| 38 |
|
| 39 |
return new_dialog_logger
|
| 40 |
|
| 41 |
+
|
| 42 |
def update_dialog(n: int = 10):
|
| 43 |
'''Gets updated internal dialog logging output from disk to display to user.
|
| 44 |
|
client/interface.py
CHANGED
|
@@ -23,6 +23,7 @@ async def agent_input(
|
|
| 23 |
'''Handles model interactions.'''
|
| 24 |
|
| 25 |
logger = logging.getLogger(__name__ + '.agent_input')
|
|
|
|
| 26 |
|
| 27 |
user_query = chat_history[-1]['content']
|
| 28 |
dialog.info('User: %s', user_query)
|
|
@@ -33,11 +34,13 @@ async def agent_input(
|
|
| 33 |
input_messages
|
| 34 |
)
|
| 35 |
|
|
|
|
|
|
|
| 36 |
if result['tool_result']:
|
| 37 |
tool_call = result['tool_call']
|
| 38 |
tool_name = tool_call['name']
|
| 39 |
|
| 40 |
-
if tool_name == '
|
| 41 |
|
| 42 |
tool_parameters = tool_call['parameters']
|
| 43 |
website = tool_parameters['website']
|
|
@@ -93,7 +96,7 @@ async def agent_input(
|
|
| 93 |
|
| 94 |
logger.info('Direct, no-tool reply: %s', reply)
|
| 95 |
|
| 96 |
-
dialog.info('LLM: %s ...', reply[:
|
| 97 |
output_queue.put(reply)
|
| 98 |
output_queue.put('bot-finished')
|
| 99 |
|
|
|
|
| 23 |
'''Handles model interactions.'''
|
| 24 |
|
| 25 |
logger = logging.getLogger(__name__ + '.agent_input')
|
| 26 |
+
reply = 'No reply from LLM'
|
| 27 |
|
| 28 |
user_query = chat_history[-1]['content']
|
| 29 |
dialog.info('User: %s', user_query)
|
|
|
|
| 34 |
input_messages
|
| 35 |
)
|
| 36 |
|
| 37 |
+
logger.debug(result)
|
| 38 |
+
|
| 39 |
if result['tool_result']:
|
| 40 |
tool_call = result['tool_call']
|
| 41 |
tool_name = tool_call['name']
|
| 42 |
|
| 43 |
+
if tool_name == 'get_feed':
|
| 44 |
|
| 45 |
tool_parameters = tool_call['parameters']
|
| 46 |
website = tool_parameters['website']
|
|
|
|
| 96 |
|
| 97 |
logger.info('Direct, no-tool reply: %s', reply)
|
| 98 |
|
| 99 |
+
dialog.info('LLM: %s ...', reply[:75])
|
| 100 |
output_queue.put(reply)
|
| 101 |
output_queue.put('bot-finished')
|
| 102 |
|
rss_client.py
CHANGED
|
@@ -31,7 +31,7 @@ logging.basicConfig(
|
|
| 31 |
backupCount=10,
|
| 32 |
mode='w'
|
| 33 |
)],
|
| 34 |
-
level=logging.
|
| 35 |
format='%(levelname)s - %(name)s - %(message)s'
|
| 36 |
)
|
| 37 |
|
|
@@ -40,7 +40,8 @@ logger = logging.getLogger(__name__)
|
|
| 40 |
|
| 41 |
# Handle MCP server connection and interactions
|
| 42 |
RSS_CLIENT = MCPClientWrapper(
|
| 43 |
-
'https://agents-mcp-hackathon-rss-mcp-server.hf.space/gradio_api/mcp/sse'
|
|
|
|
| 44 |
)
|
| 45 |
logger.info('Started MCP client')
|
| 46 |
|
|
@@ -146,12 +147,12 @@ with gr.Blocks(title='MCP RSS client') as demo:
|
|
| 146 |
|
| 147 |
if __name__ == '__main__':
|
| 148 |
|
| 149 |
-
current_directory = os.getcwd()
|
| 150 |
|
| 151 |
-
if 'pyrite' in current_directory:
|
| 152 |
-
|
| 153 |
-
|
| 154 |
|
| 155 |
-
else:
|
| 156 |
-
|
| 157 |
-
|
|
|
|
| 31 |
backupCount=10,
|
| 32 |
mode='w'
|
| 33 |
)],
|
| 34 |
+
level=logging.DEBUG,
|
| 35 |
format='%(levelname)s - %(name)s - %(message)s'
|
| 36 |
)
|
| 37 |
|
|
|
|
| 40 |
|
| 41 |
# Handle MCP server connection and interactions
|
| 42 |
RSS_CLIENT = MCPClientWrapper(
|
| 43 |
+
#'https://agents-mcp-hackathon-rss-mcp-server.hf.space/gradio_api/mcp/sse',
|
| 44 |
+
'http://127.0.0.1:7861/gradio_api/mcp/sse'
|
| 45 |
)
|
| 46 |
logger.info('Started MCP client')
|
| 47 |
|
|
|
|
| 147 |
|
| 148 |
if __name__ == '__main__':
|
| 149 |
|
| 150 |
+
# current_directory = os.getcwd()
|
| 151 |
|
| 152 |
+
# if 'pyrite' in current_directory:
|
| 153 |
+
logger.info('Starting RASS on LAN')
|
| 154 |
+
demo.launch(server_name='0.0.0.0', server_port=7860)
|
| 155 |
|
| 156 |
+
# else:
|
| 157 |
+
# logger.info('Starting RASS')
|
| 158 |
+
# demo.launch()
|