Commit 576af3f
committed
fast_llm: Fix UnboundLocalError, add docstring
Previously, fast_llm was trying to access 'response' in the finally
block, which would fail with UnboundLocalError if the chat call raised
an exception (because of missing API key, etc.)
UnboundLocalError: cannot access local variable 'response' where it is
not associated with a value
Moved the return statement into the try block while keeping state
restoration in finally, ensuring proper error propagation while
maintaining conversation state.
This way, if there's an API key issue or any other problem, any errors
from `llm.interpreter.chat()` propagate up and can be handled at the
appropriate level in the call stack.
Added a detailed docstring to clarify the purpose, behavior, and usage
of the `fast_llm` function.1 parent 21babb1 commit 576af3f
1 file changed
+21
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
81 | 100 | | |
82 | 101 | | |
83 | 102 | | |
84 | 103 | | |
85 | 104 | | |
86 | 105 | | |
| 106 | + | |
87 | 107 | | |
| 108 | + | |
88 | 109 | | |
89 | 110 | | |
90 | | - | |
91 | 111 | | |
92 | 112 | | |
93 | 113 | | |
| |||
0 commit comments