|
6 | 6 | from typing import AsyncGenerator, Callable |
7 | 7 |
|
8 | 8 | import httpx |
9 | | -from common.agent import get_remote_data, reasoning_step, remote_function_call |
| 9 | +from openbb_ai import reasoning_step, get_widget_data |
10 | 10 | from dotenv import load_dotenv |
11 | 11 | from fastapi import FastAPI |
12 | 12 | from fastapi.middleware.cors import CORSMiddleware |
@@ -94,7 +94,7 @@ async def perplexity_web_search(query: str) -> str: |
94 | 94 | } |
95 | 95 |
|
96 | 96 | try: |
97 | | - async with httpx.AsyncClient() as client: |
| 97 | + async with httpx.AsyncClient(timeout=30.0) as client: |
98 | 98 | response = await client.post(url, headers=headers, json=data) |
99 | 99 | response.raise_for_status() |
100 | 100 | response_json = response.json() |
@@ -258,9 +258,6 @@ def get_widget_data(widget_collection: WidgetCollection) -> Callable: |
258 | 258 | else [] |
259 | 259 | ) |
260 | 260 |
|
261 | | - @remote_function_call( |
262 | | - function="get_widget_data", output_formatter=handle_widget_data |
263 | | - ) |
264 | 261 | async def _get_widget_data( |
265 | 262 | widget_uuid: str, |
266 | 263 | ) -> AsyncGenerator[FunctionCallSSE | StatusUpdateSSE, None]: |
@@ -289,14 +286,15 @@ async def _get_widget_data( |
289 | 286 | details={"widget_uuid": widget_uuid}, |
290 | 287 | ) |
291 | 288 |
|
292 | | - # Request the widget data |
293 | | - yield get_remote_data( |
294 | | - widget=widget, |
295 | | - # Use the current values of widget parameters |
296 | | - input_arguments={ |
297 | | - param.name: param.current_value for param in widget.params |
298 | | - }, |
| 289 | + # Request the widget data using the new API |
| 290 | + from openbb_ai.models import WidgetRequest |
| 291 | + widget_request = WidgetRequest( |
| 292 | + widget_uuid=widget.uuid, |
| 293 | + origin=widget.origin, |
| 294 | + id=widget.widget_id, |
| 295 | + input_args={param.name: param.current_value for param in widget.params}, |
299 | 296 | ) |
| 297 | + yield get_widget_data([widget_request]).model_dump() |
300 | 298 |
|
301 | 299 | return _get_widget_data |
302 | 300 |
|
@@ -583,7 +581,7 @@ async def direct_response(): |
583 | 581 | logger.info( |
584 | 582 | f"Making initial request to detect tool calls with messages: {formatted_messages}" |
585 | 583 | ) |
586 | | - async with httpx.AsyncClient() as client: |
| 584 | + async with httpx.AsyncClient(timeout=30.0) as client: |
587 | 585 | response = await client.post(url, headers=headers, json=data) |
588 | 586 | response.raise_for_status() |
589 | 587 | result = response.json() |
|
0 commit comments