Skip to content

Commit

Permalink
Merge pull request #75 from undreamai/feature/embedding
Browse files Browse the repository at this point in the history
Embedding and search functionality (RAG system)
  • Loading branch information
amakropoulos authored Feb 15, 2024
2 parents 2c98af5 + 9993494 commit f9679a6
Show file tree
Hide file tree
Showing 112 changed files with 18,825 additions and 106 deletions.
File renamed without changes.
1 change: 1 addition & 0 deletions .github/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
git config core.hooksPath .github/hooks
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ obj/
obj.meta
bin/
bin.meta

*.api
*.api.meta
36 changes: 36 additions & 0 deletions Editor/EmbeddingEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using UnityEditor;

namespace LLMUnity
{
[CustomEditor(typeof(Embedding))]
public class EmbeddingEditor : Editor
{

void ShowProgress(float progress, string progressText)
{
if (progress != 1) EditorGUI.ProgressBar(EditorGUILayout.GetControlRect(), progress, progressText);
}

public override void OnInspectorGUI()
{
Embedding embdeddingScript = (Embedding)target;
SerializedObject embdeddingScriptSO = new SerializedObject(embdeddingScript);
embdeddingScriptSO.Update();

embdeddingScriptSO.ApplyModifiedProperties();
string[] options = new string[embdeddingScript.options.Length];
for (int i = 0; i < embdeddingScript.options.Length; i++)
{
options[i] = embdeddingScript.options[i].Item1;
}

int newIndex = EditorGUILayout.Popup("Model", embdeddingScript.SelectedOption, options);
if (newIndex != embdeddingScript.SelectedOption)
{
embdeddingScript.SelectModel(newIndex);
}
ShowProgress(embdeddingScript.downloadProgress, "Downloading model");
embdeddingScriptSO.ApplyModifiedProperties();
}
}
}
11 changes: 11 additions & 0 deletions Editor/EmbeddingEditor.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions Editor/LLMEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@ public class LLMEditor : LLMClientEditor
public void AddModelLoaders(SerializedObject llmScriptSO, LLM llmScript)
{
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("Download model", GUILayout.Width(buttonWidth)))

string[] options = new string[llmScript.modelOptions.Length];
for (int i = 0; i < llmScript.modelOptions.Length; i++)
{
llmScript.DownloadModel();
options[i] = llmScript.modelOptions[i].Item1;
}

int newIndex = EditorGUILayout.Popup("Model", llmScript.SelectedOption, options);
if (newIndex != llmScript.SelectedOption)
{
llmScript.DownloadModel(newIndex);
}

if (GUILayout.Button("Load model", GUILayout.Width(buttonWidth)))
{
EditorApplication.delayCall += () =>
Expand Down
Loading

0 comments on commit f9679a6

Please sign in to comment.