2using Microsoft.Extensions.Configuration;
8 [CreateAssetMenu(fileName =
"ActorConfig", menuName =
"EchoTrio/ActorConfig")]
14 [TextArea(minLines: 4, maxLines: 8)]
public string instruction =
string.Empty;
35 [Header(
"Instructions")]
36 [SerializeField, TextArea(minLines: 16, maxLines: 32)]
private string generalInstructions =
string.Empty;
54 string instructions = $
"You will be playing a character named {this.persona}.\n\n";
70 string filePath = $
"{Application.streamingAssetsPath}/Configs/{OverrideFileName}";
71 IConfiguration config =
new ConfigurationBuilder().AddIniFile(filePath).Build();
72 IConfigurationSection section = config.GetSection(
persona.ToString());
75 if (section ==
null) {
76 Debug.LogWarning($
"Section {persona.ToString()} not found in {filePath}!");
77 return overriddenConfig;
81 Func<string, string> GetValue = (
string key) => {
return section[key] ==
null ? string.Empty : section[key].Trim(); };
82 string value =
string.Empty;
85 value = GetValue(
"openai_vector_store_id");
86 if (!
string.IsNullOrEmpty(value)) {
87 Debug.Log($
"Overrode {persona.ToString()}'s OpenAI Vector Store ID.");
88 overriddenConfig.openAIVectorStoreId = value;
92 value = GetValue(
"elevenlabs_voice_id");
93 if (!
string.IsNullOrEmpty(value)) {
94 Debug.Log($
"Overrode {persona.ToString()}'s ElevenLabs Voice ID.");
95 overriddenConfig.elevenLabsVoiceId = value.Trim();
99 value = GetValue(
"feature_web_search");
100 if (!
string.IsNullOrEmpty(value)) {
101 if (value.ToUpper() ==
"TRUE") {
102 Debug.Log($
"Overrode {persona.ToString()}'s Web Search Feature Setting To TRUE.");
103 overriddenConfig.enabledFeatures |=
Feature.WebSearch;
104 }
else if (value.ToUpper() ==
"FALSE") {
105 Debug.Log($
"Overrode {persona.ToString()}'s Web Search Feature Setting To TRUE.");
106 overriddenConfig.enabledFeatures &=
~Feature.WebSearch;
110 value = GetValue(
"feature_file_search");
111 if (!
string.IsNullOrEmpty(value)) {
112 if (value.ToUpper() ==
"TRUE") {
113 Debug.Log($
"Overrode {persona.ToString()}'s File Search Feature Setting To TRUE.");
114 overriddenConfig.enabledFeatures |=
Feature.FileSearch;
115 }
else if (value.ToUpper() ==
"FALSE") {
116 Debug.Log($
"Overrode {persona.ToString()}'s File Search Feature Setting To FALSE.");
117 overriddenConfig.enabledFeatures &=
~Feature.FileSearch;
121 value = GetValue(
"feature_reasoning");
122 if (!
string.IsNullOrEmpty(value)) {
123 if (value.ToUpper() ==
"TRUE") {
124 Debug.Log($
"Overrode {persona.ToString()}'s Reasoning Feature Setting To TRUE.");
125 overriddenConfig.enabledFeatures |=
Feature.Reasoning;
126 }
else if (value.ToUpper() ==
"FALSE") {
127 Debug.Log($
"Overrode {persona.ToString()}'s Reasoning Feature Setting To FALSE.");
128 overriddenConfig.enabledFeatures &=
~Feature.Reasoning;
132 value = GetValue(
"feature_audio_tags");
133 if (!
string.IsNullOrEmpty(value)) {
134 if (value.ToUpper() ==
"TRUE") {
135 Debug.Log($
"Overrode {persona.ToString()}'s Audio Tags Feature Setting To TRUE.");
136 overriddenConfig.enabledFeatures |=
Feature.AudioTags;
137 }
else if (value.ToUpper() ==
"FALSE") {
138 Debug.Log($
"Overrode {persona.ToString()}'s Audio Tags Feature Setting To FALSE.");
139 overriddenConfig.enabledFeatures &=
~Feature.AudioTags;
143 return overriddenConfig;
149 bool hasValidSnippets =
false;
151 if (snippet ==
null) {
continue; }
152 hasValidSnippets = hasValidSnippets || snippet.
enabled;
154 if (!hasValidSnippets) {
return string.Empty; }
157 string instructions = $
"{prefix}\n";
159 if (snippet ==
null) {
continue; }
160 if (!snippet.
enabled) {
continue; }
161 instructions += $
"{snippet.instruction}\n";
163 return instructions +
"\n";
ActorConfig Override()
Overrides any actor config if value is set in ActorOverrides.ini.
string generalInstructions
InstructionSnippet[] exampleResponses
InstructionSnippet[] backgroundInfos
bool IsAnyFeatureEnabled(Feature features)
bool AreAllFeaturesEnabled(Feature features)
Feature
Flags to enable or disable actor features.
@ FileSearch
Allow the actor's OpenAI model to access files uploaded into the vector store. https://platform....
@ AudioTags
Allow the actor's ElevenLabs model to use audio tags to generate more expressive dialouge....
@ Reasoning
Allow the actor's OpenAI model to provide its reasoning when generating a response.
@ WebSearch
Allow the actor's OpenAI model to access the internet and search for information.
InstructionSnippet[] personalityInfos
string GetOpenAIVectorStoreID()
const string OverrideFileName
string GetSnippetsInstructions(string prefix, InstructionSnippet[] snippets)
string openAIVectorStoreId
string GetElevenLabsVoiceID()
InstructionSnippet[] contextInfos
const Persona DefaultValue
Persona
Personas the actors will role-play.