Skip to content

Commit

Permalink
Merge pull request #7 from Uralstech/unstable
Browse files Browse the repository at this point in the history
UGemini v1.2.1
  • Loading branch information
Uralstech authored Jul 9, 2024
2 parents de5c70a + d71b21d commit ff9bb47
Show file tree
Hide file tree
Showing 8 changed files with 1,667 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public async void OnChat()
};

GeminiChatResponse response;
GeminiFunctionCall functionCall = null;
GeminiFunctionCall functionCall;
do
{
response = await GeminiManager.Instance.Request<GeminiChatResponse>(new GeminiChatRequest(useBetaApi: true)
Expand All @@ -102,13 +102,10 @@ public async void OnChat()

contents.Add(response.Candidates[0].Content);

_chatResponse.text = Array.Find(response.Parts, part => !string.IsNullOrEmpty(part.Text))?.Text;
GeminiContentPart[] allFunctionCalls = Array.FindAll(response.Parts, part => part.FunctionCall != null);
functionCall = null;

int textIndex = Array.FindIndex(response.Parts, part => !string.IsNullOrEmpty(part.Text));
if (textIndex > -1)
_chatResponse.text = response.Parts[textIndex].Text;

functionCall = null;
for (int i = 0; i < allFunctionCalls.Length; i++)
{
functionCall = allFunctionCalls[i].FunctionCall;
Expand Down Expand Up @@ -140,11 +137,12 @@ public async void OnChat()
break;
}

contents.Add(GeminiContent.GetContent(functionCall.GetResponse(functionResponse)));
contents.Add(GeminiContent.GetContent(functionCall.GetResponse(functionResponse ?? new JObject()
{
["result"] = "Completed executing function successfully."
})));
}
} while (functionCall != null);

_chatResponse.text = response.Parts[0].Text;
}

private bool TryChangeTextColor(string color)
Expand Down

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

Loading

0 comments on commit ff9bb47

Please sign in to comment.