Replies: 1 comment 1 reply
-
🤖 Hi there, Thanks for reaching out with your question about integrating VertexAI models with Streamlit callbacks in the LangChain framework. From your code, it seems like you're trying to use the To make the Streamlit callback work with VertexAI models, you need to modify the def _stream(
self,
prompt: str,
stop: Optional[List[str]] = None,
run_manager: Optional[CallbackManagerForLLMRun] = None,
**kwargs: Any,
) -> Iterator[GenerationChunk]:
params = self._prepare_params(stop=stop, **kwargs)
for stream_resp in stream_completion_with_retry(
self, prompt, run_manager=run_manager, **params
):
chunk = _response_to_generation(stream_resp)
yield chunk
if run_manager:
run_manager.on_llm_new_token(
chunk.text,
chunk=chunk,
verbose=self.verbose,
) In this method, the To make the Streamlit callback work with VertexAI models, you need to modify the Please note that the exact modifications you need to make will depend on the specifics of how the Streamlit callback and the VertexAI model are supposed to interact. I hope this helps! Let me know if you have any other questions. Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Issues with getting Vertex AI models to work with Streamlit callbacks
Hi, I've got a Streamlit app that can switch between OpenAI and VertexAI models.
One little issue was the Streamlit integrations (StreamlitCallbackHandler) - VertexAI models does not output into the Streamlit container as expected. OpenAI models seems to work fine.
My work around is to manually call st.write if using VertexAI - just wondering if there is a way to make the Streamlit callback work?
Many thanks!
Here is extract for the code:
Beta Was this translation helpful? Give feedback.
All reactions