-
Notifications
You must be signed in to change notification settings - Fork 397
Phi 3 Android app Update #465
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4eae3f5
Update phi-3 Android app layout and add logs
vraspar 4df9ab2
Update Android app layout and add settings functionality
vraspar d276879
Update logging in MainActivity
vraspar 86c84ff
Log prompt processing time and add screenshot
vraspar f67f7e3
add popup to display token generation rates and apply feedback
vraspar 14ebe59
add link to gen ai reference docs
vraspar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
mobile/examples/phi-3/android/app/src/main/java/ai/onnxruntime/genai/demo/BottomSheet.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package ai.onnxruntime.genai.demo; | ||
|
|
||
| import android.os.Bundle; | ||
| import android.view.LayoutInflater; | ||
| import android.view.View; | ||
| import android.view.ViewGroup; | ||
| import android.widget.Button; | ||
| import android.widget.EditText; | ||
| import androidx.annotation.NonNull; | ||
| import androidx.annotation.Nullable; | ||
| import com.google.android.material.bottomsheet.BottomSheetDialogFragment; | ||
|
|
||
| public class BottomSheet extends BottomSheetDialogFragment { | ||
| private EditText maxLengthEditText; | ||
| private EditText lengthPenaltyEditText; | ||
| private SettingsListener settingsListener; | ||
|
|
||
| public interface SettingsListener { | ||
| void onSettingsApplied(int maxLength, float lengthPenalty); | ||
| } | ||
|
|
||
| public void setSettingsListener(SettingsListener listener) { | ||
| this.settingsListener = listener; | ||
| } | ||
|
|
||
| @Nullable | ||
| @Override | ||
| public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | ||
| View view = inflater.inflate(R.layout.bottom_sheet, container, false); | ||
|
|
||
| maxLengthEditText = view.findViewById(R.id.idEdtMaxLength); | ||
| lengthPenaltyEditText = view.findViewById(R.id.idEdtLengthPenalty); | ||
|
|
||
| Button applyButton = view.findViewById(R.id.applySettingsButton); | ||
|
|
||
| applyButton.setOnClickListener(v -> { | ||
| if (settingsListener != null) { | ||
| int maxLength = Integer.parseInt(maxLengthEditText.getText().toString()); | ||
| float lengthPenalty = Float.parseFloat(lengthPenaltyEditText.getText().toString()); | ||
| settingsListener.onSettingsApplied(maxLength, lengthPenalty); | ||
| dismiss(); | ||
| } | ||
| }); | ||
|
|
||
| return view; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
mobile/examples/phi-3/android/app/src/main/res/drawable/rounded_corner2.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
mobile/examples/phi-3/android/app/src/main/res/layout/bottom_sheet.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| xmlns:tools="http://schemas.android.com/tools" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:orientation="vertical" | ||
| android:padding="16dp"> | ||
|
|
||
| <!-- Max Response Length --> | ||
| <TextView | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:text="Max Response Length" | ||
| android:textSize="16sp" | ||
| android:textColor="@color/black" | ||
| android:layout_marginBottom="8dp"/> | ||
|
|
||
| <EditText | ||
| android:id="@+id/idEdtMaxLength" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:inputType="number" | ||
| android:hint="Enter max response length" | ||
| android:text="100" | ||
| android:padding="8dp" /> | ||
|
|
||
| <!-- Length Penalty --> | ||
| <TextView | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:text="Length Penalty" | ||
| android:textSize="16sp" | ||
| android:textColor="@color/black" | ||
| android:layout_marginTop="16dp" | ||
| android:layout_marginBottom="8dp"/> | ||
|
|
||
| <EditText | ||
| android:id="@+id/idEdtLengthPenalty" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:hint="Enter length penalty" | ||
| android:inputType="number|numberDecimal" | ||
| android:padding="8dp" | ||
| android:text="1.0" /> | ||
|
|
||
| <!-- Save Button --> | ||
| <Button | ||
| android:id="@+id/applySettingsButton" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_gravity="center_horizontal" | ||
| android:layout_marginTop="24dp" | ||
| android:background="#89CC04" | ||
| android:backgroundTint="#89CC04" | ||
| android:tint="@color/white" | ||
| android:padding="8dp" | ||
| android:text="Apply" | ||
| android:textAppearance="@style/TextAppearance.AppCompat.Body1" | ||
| android:visibility="visible" | ||
| tools:visibility="visible" /> | ||
| </LinearLayout> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.