Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLM example --> Phi-2 model implementation: _uiState function error #336

Open
mhyeonsoo opened this issue Mar 13, 2024 · 0 comments
Open

Comments

@mhyeonsoo
Copy link

Hi, thanks for providing a great examples. It is amazing indeed.

While I am deploying the test app for LLM chat, I tried two models which are Gemma and phi-2.
For Gemma, it worked perfectly. But for phi-2, I changed the code depending on your guide in comment

// `GemmaUiState()` is optimized for the Gemma model.
// Replace `GemmaUiState` with `ChatUiState()` if you're using a different model
private val _uiState: MutableStateFlow<ChatUiState> = MutableStateFlow(ChatUiState())

When I changed the code like above, error happens in the below part.

try {
                val fullPrompt = _uiState.value.fullPrompt
                inferenceModel.generateResponseAsync(fullPrompt)
                inferenceModel.partialResults
                    .collectIndexed { index, (partialResult, done) ->
                        currentMessageId?.let {
                            if (index == 0) {
                                _uiState.value.appendFirstMessage(it, partialResult) // <-- this is the error part
                            } else {
                                _uiState.value.appendMessage(it, partialResult, done)
                            }
                            if (done) {
                                currentMessageId = null
                                // Re-enable text input
                                setInputEnabled(true)
                            }
                        }
                    }
            } catch (e: Exception) {
                _uiState.value.addMessage(e.localizedMessage ?: "Unknown Error", MODEL_PREFIX)
                setInputEnabled(true)
            }

The error message is

Unresolved reference: appendFirstMessage

can you give me a feedback for this issue?

Thanks!

@mhyeonsoo mhyeonsoo changed the title _uiState function error LLM example --> Phi-2 model implementation: _uiState function error Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant