feat: add chat_tui example for FastGPT with Textual interface
- Introduced a new example script `chat_tui.py` that provides a full-screen Textual interface for interacting with FastGPT. - Implemented streaming chat updates, workflow logging, and modal handling for interactive nodes. - Enhanced FastGPT client with new streaming capabilities and structured event types for better interaction handling. - Normalized base URL handling in the client to prevent duplicate `/api` paths. - Added tests for streaming event parsing and interaction handling.
This commit is contained in:
@@ -8,6 +8,15 @@ from typing import Any
|
||||
class BaseClientMixin:
|
||||
"""Mixin class providing retry logic, validation, and logging for FastGPT clients."""
|
||||
|
||||
@staticmethod
|
||||
def _normalize_base_url(base_url: str) -> str:
|
||||
"""Normalize FastGPT base URLs so '/api' is not duplicated by endpoint paths."""
|
||||
|
||||
normalized = str(base_url or "").strip().rstrip("/")
|
||||
if normalized.endswith("/api"):
|
||||
normalized = normalized[:-4]
|
||||
return normalized
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
api_key: str,
|
||||
@@ -28,7 +37,7 @@ class BaseClientMixin:
|
||||
enable_logging: Whether to enable request logging
|
||||
"""
|
||||
self.api_key = api_key
|
||||
self.base_url = base_url
|
||||
self.base_url = self._normalize_base_url(base_url)
|
||||
self.timeout = timeout
|
||||
self.max_retries = max_retries
|
||||
self.retry_delay = retry_delay
|
||||
|
||||
Reference in New Issue
Block a user