|
14 | 14 | # limitations under the License. |
15 | 15 |
|
16 | 16 | import contextvars |
17 | | -from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union |
18 | | - |
19 | | -from nemoguardrails.logging.explain import LLMCallInfo |
| 17 | +from typing import TYPE_CHECKING, Any, Dict, List, Optional |
20 | 18 |
|
21 | 19 | if TYPE_CHECKING: |
22 | 20 | from nemoguardrails.logging.explain import ExplainInfo |
23 | | - from nemoguardrails.logging.stats import LLMStats |
24 | | - from nemoguardrails.rails.llm.options import GenerationOptions |
| 21 | + from nemoguardrails.rails.llm.options import GenerationOptions, LLMStats |
25 | 22 | from nemoguardrails.streaming import StreamingHandler |
26 | 23 |
|
27 | 24 | streaming_handler_var: contextvars.ContextVar[ |
|
34 | 31 | ] = contextvars.ContextVar("explain_info", default=None) |
35 | 32 |
|
36 | 33 | # The current LLM call. |
37 | | -llm_call_info_var: contextvars.ContextVar[ |
38 | | - Optional[LLMCallInfo] |
39 | | -] = contextvars.ContextVar("llm_call_info", default=None) |
| 34 | +llm_call_info_var: contextvars.ContextVar[Optional[str]] = contextvars.ContextVar( |
| 35 | + "llm_call_info", default=None |
| 36 | +) |
40 | 37 |
|
41 | 38 | # All the generation options applicable to the current context. |
42 | 39 | generation_options_var: contextvars.ContextVar[ |
|
50 | 47 |
|
51 | 48 | # The raw LLM request that comes from the user. |
52 | 49 | # This is used in passthrough mode. |
53 | | -raw_llm_request: contextvars.ContextVar[ |
54 | | - Optional[Union[str, List[Dict[str, Any]]]] |
55 | | -] = contextvars.ContextVar("raw_llm_request", default=None) |
| 50 | +raw_llm_request: contextvars.ContextVar[Optional[Any]] = contextvars.ContextVar( |
| 51 | + "raw_llm_request", default=None |
| 52 | +) |
56 | 53 |
|
57 | 54 | reasoning_trace_var: contextvars.ContextVar[Optional[str]] = contextvars.ContextVar( |
58 | 55 | "reasoning_trace", default=None |
|
0 commit comments