Spaces:
Sleeping
Sleeping
bug fix
Browse files- utils/generator.py +11 -2
- utils/sources.py +1 -1
utils/generator.py
CHANGED
|
@@ -10,7 +10,16 @@ from langchain_core.messages import SystemMessage, HumanMessage
|
|
| 10 |
|
| 11 |
# Local imports
|
| 12 |
from .utils import getconfig, get_auth
|
| 13 |
-
from .
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
# Set up logger
|
| 16 |
logger = logging.getLogger(__name__)
|
|
@@ -116,7 +125,7 @@ async def generate_streaming(query: str, context: Union[str, List[Dict[str, Any]
|
|
| 116 |
|
| 117 |
try:
|
| 118 |
formatted_context, processed_results = _process_context(context)
|
| 119 |
-
messages = _build_messages(query, formatted_context)
|
| 120 |
|
| 121 |
# Stream the response and accumulate for citation parsing (filter out any sources that were not cited)
|
| 122 |
accumulated_response = ""
|
|
|
|
| 10 |
|
| 11 |
# Local imports
|
| 12 |
from .utils import getconfig, get_auth
|
| 13 |
+
from .prompts import system_prompt
|
| 14 |
+
from .sources import (
|
| 15 |
+
_process_context,
|
| 16 |
+
_build_messages,
|
| 17 |
+
_parse_citations,
|
| 18 |
+
_extract_sources,
|
| 19 |
+
_create_sources_list,
|
| 20 |
+
clean_citations
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
|
| 24 |
# Set up logger
|
| 25 |
logger = logging.getLogger(__name__)
|
|
|
|
| 125 |
|
| 126 |
try:
|
| 127 |
formatted_context, processed_results = _process_context(context)
|
| 128 |
+
messages = _build_messages(system_prompt, query, formatted_context)
|
| 129 |
|
| 130 |
# Stream the response and accumulate for citation parsing (filter out any sources that were not cited)
|
| 131 |
accumulated_response = ""
|
utils/sources.py
CHANGED
|
@@ -2,7 +2,7 @@ import re
|
|
| 2 |
from typing import List, Dict, Any, Union
|
| 3 |
import ast
|
| 4 |
from langchain_core.messages import SystemMessage, HumanMessage
|
| 5 |
-
|
| 6 |
|
| 7 |
# ---------------------------------------------------------------------
|
| 8 |
# Core Processing Functions
|
|
|
|
| 2 |
from typing import List, Dict, Any, Union
|
| 3 |
import ast
|
| 4 |
from langchain_core.messages import SystemMessage, HumanMessage
|
| 5 |
+
|
| 6 |
|
| 7 |
# ---------------------------------------------------------------------
|
| 8 |
# Core Processing Functions
|